/* -*-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.
*
* 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 <assert.h>
/*----- 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)
#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); \
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 { \
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); \