X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/3bef8c146b00ba0e71b0db29ef3a5b00a533a10a..42ca150ce7fa024a8fd6a4c9433b613175270eb4:/mars.c diff --git a/mars.c b/mars.c index b427dcd..9240083 100644 --- a/mars.c +++ b/mars.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: mars.c,v 1.1 2001/04/29 18:11:19 mdw Exp $ + * $Id: mars.c,v 1.2 2004/04/08 01:36:15 mdw Exp $ * * The MARS block cipher * * (c) 2001 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,26 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: mars.c,v $ - * Revision 1.1 2001/04/29 18:11:19 mdw - * New block cipher MARS. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -55,7 +47,7 @@ const octet mars_keysz[] = { KSZ_RANGE, MARS_KEYSZ, 0, 56, 4 }; /*----- Useful tables -----------------------------------------------------*/ static const uint32 s[512] = MARS_S; -#define s0 (s + 0) +#define s0 (s + 0) #define s1 (s + 256) #define bb (s + 265) @@ -162,8 +154,8 @@ void mars_init(mars_ctx *k, const void *buf, size_t sz) #define IKSUB(k, a, b, c, d) d -= *--k, c -= *--k, b -= *--k, a -= *--k #define MIX(a, b, c, d) do { \ - b ^= s0[(a >> 0) & 0xff]; \ - b += s1[(a >> 8) & 0xff]; \ + b ^= s0[(a >> 0) & 0xff]; \ + b += s1[(a >> 8) & 0xff]; \ c += s0[(a >> 16) & 0xff]; \ d ^= s1[(a >> 24) & 0xff]; \ a = ROL32(a, 8); \ @@ -173,8 +165,8 @@ void mars_init(mars_ctx *k, const void *buf, size_t sz) a = ROR32(a, 8); \ d ^= s1[(a >> 24) & 0xff]; \ c -= s0[(a >> 16) & 0xff]; \ - b -= s1[(a >> 8) & 0xff]; \ - b ^= s0[(a >> 0) & 0xff]; \ + b -= s1[(a >> 8) & 0xff]; \ + b ^= s0[(a >> 0) & 0xff]; \ } while (0) #define E(x, y, z, k, a) do { \ @@ -198,7 +190,7 @@ void mars_init(mars_ctx *k, const void *buf, size_t sz) E(x, y, z, k, a); \ b += x; c += y; d ^= z; \ } while (0) - + #define IROUND(k, a, b, c, d) do { \ uint32 x, y, z; \ IE(x, y, z, k, a); \