Make tables of standard encryption schemes etc.
[u/mdw/catacomb] / rijndael.h
index 155f7a6..282cef8 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: rijndael.h,v 1.1 2000/06/17 11:56:07 mdw Exp $
+ * $Id: rijndael.h,v 1.3 2001/05/07 17:31:53 mdw Exp $
  *
  * The Rijndael block cipher
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: rijndael.h,v $
+ * Revision 1.3  2001/05/07 17:31:53  mdw
+ * Separate out key scheduling.
+ *
+ * Revision 1.2  2000/10/08 15:48:58  mdw
+ * Update comments now that AES has been chosen.
+ *
  * Revision 1.1  2000/06/17 11:56:07  mdw
  * New cipher.
  *
 
 /*----- Notes on the Rijndael block cipher --------------------------------*
  *
- * Invented by Joan Daemen and Vincent Rijmen, Rijndael is a fast and
- * relatively simple 128-bit block cipher proposed by the designers as an AES
- * candidate.  At the time of writing, the AES winner hasn't been decided.
- * Rijnadel is fast, but has a low security margin.  I recommend waiting
+ * Invented by Joan Daemen and Vincent Rijmen, Rijndael is a fast, elegant
+ * and relatively simple 128-bit block cipher.  It was chosen by NIST to be
+ * the new Advanced Encryption Standard (AES) algorithm.
+ *
+ * Rijnadel appears to have a low security margin.  I recommend waiting
  * before using Rijndael for any sensitive applications.
  */
 
@@ -67,8 +74,8 @@ extern const octet rijndael_keysz[];
 
 /*----- Data structures ---------------------------------------------------*/
 
-#define RIJNDAEL_MAXROUNDS 32
-#define RIJNDAEL_KWORDS ((RIJNDAEL_MAXROUNDS + 1) * (RIJNDAEL_BLKSZ / 4))
+#define RIJNDAEL_MAXROUNDS 16
+#define RIJNDAEL_KWORDS ((RIJNDAEL_MAXROUNDS + 1) * 8)
 
 typedef struct rijndael_ctx {
   unsigned nr;
@@ -78,6 +85,21 @@ typedef struct rijndael_ctx {
 
 /*----- Functions provided ------------------------------------------------*/
 
+/* --- @rijndael_setup@ --- *
+ *
+ * Arguments:  @rijndael_ctx *k@ = pointer to context to initialize
+ *             @unsigned nb@ = number of words in the block
+ *             @const void *buf@ = pointer to buffer of key material
+ *             @size_t sz@ = size of the key material
+ *
+ * Returns:    ---
+ *
+ * Use:                Low-level key-scheduling.  Don't call this directly.
+ */
+
+extern void rijndael_setup(rijndael_ctx */*k*/, unsigned /*nb*/,
+                          const void */*buf*/, size_t /*sz*/);
+
 /* --- @rijndael_init@ --- *
  *
  * Arguments:  @rijndael_ctx *k@ = pointer to context to initialize