New block cipher MARS.
[u/mdw/catacomb] / mars.h
diff --git a/mars.h b/mars.h
new file mode 100644 (file)
index 0000000..91d79e1
--- /dev/null
+++ b/mars.h
@@ -0,0 +1,114 @@
+/* -*-c-*-
+ *
+ * $Id: mars.h,v 1.1 2001/04/29 18:11:19 mdw Exp $
+ *
+ * The MARS block cipher
+ *
+ * (c) 2001 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------* 
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * 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.h,v $
+ * Revision 1.1  2001/04/29 18:11:19  mdw
+ * New block cipher MARS.
+ *
+ */
+
+/*----- Notes on the MARS block cipher ------------------------------------*
+ *
+ * MARS was IBM's submission to the AES contest.  It was designed by a number
+ * of clever people at the T. J. Watson labs, and made it to the second round
+ * of the contest.  Unfortunately, MARS is rather messy.  There are some
+ * awkward corner cases in the key schedule algorithm, for example, that show
+ * up very rarely.
+ */
+
+#ifndef CATACOMB_MARS_H
+#define CATACOMB_MARS_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stddef.h>
+
+#include <mLib/bits.h>
+
+/*----- Magical numbers ---------------------------------------------------*/
+
+#define MARS_BLKSZ 16
+#define MARS_KEYSZ 32
+#define MARS_CLASS (N, L, 128)
+
+extern const octet mars_keysz[];
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct mars_ctx {
+  uint32 k[40];
+} mars_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @mars_init@ --- *
+ *
+ * Arguments:  @mars_ctx *k@ = pointer to key block to fill in
+ *             @const void *buf@ = pointer to buffer of key material
+ *             @size_t sz@ = size of key material
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes a MARS key buffer.  MARS accepts key sizes
+ *             between 128 and 448 bits which are a multiple of 32 bits.
+ */
+
+extern void mars_init(mars_ctx */*k*/,
+                     const void */*buf*/, size_t /*sz*/);
+
+/* --- @mars_eblk@, @mars_dblk@ --- *
+ *
+ * Arguments:  @const mars_ctx *k@ = pointer to key block
+ *             @const uint32 s[4]@ = pointer to source block
+ *             @uint32 d[4]@ = pointer to destination block
+ *
+ * Returns:    ---
+ *
+ * Use:                Low-level block encryption and decryption.
+ */
+
+extern void mars_eblk(const mars_ctx */*k*/,
+                     const uint32 */*s*/, uint32 */*d*/);
+
+extern void mars_dblk(const mars_ctx */*k*/,
+                     const uint32 */*s*/, uint32 */*d*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif