Add support for Twofish family keys.
[u/mdw/catacomb] / twofish.h
index 42736bd..79c697b 100644 (file)
--- a/twofish.h
+++ b/twofish.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: twofish.h,v 1.3 2001/04/29 18:12:43 mdw Exp $
+ * $Id: twofish.h,v 1.4 2002/01/13 13:37:59 mdw Exp $
  *
  * The Twofish block cipher
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: twofish.h,v $
+ * Revision 1.4  2002/01/13 13:37:59  mdw
+ * Add support for Twofish family keys.
+ *
  * Revision 1.3  2001/04/29 18:12:43  mdw
  * Fix formatting.
  *
@@ -79,8 +82,30 @@ typedef struct twofish_ctx {
   uint32 g[4][256];
 } twofish_ctx;
 
+typedef struct twofish_fk {
+  uint32 t0[8], t23[8], t4[2];
+  octet t1[32];
+} twofish_fk;
+
 /*----- Functions provided ------------------------------------------------*/
 
+/* --- @twofish_initfk@ --- *
+ *
+ * Arguments:  @twofish_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
+ *             @const twofish_fk *fk@ = family-key information
+ *
+ * Returns:    ---
+ *
+ * Use:                Does the underlying Twofish key initialization with family
+ *             key.  Pass in a family-key structure initialized to
+ *             all-bits-zero for a standard key schedule.
+ */
+
+extern void twofish_initfk(twofish_ctx */*k*/, const void */*buf*/,
+                          size_t /*sz*/, const twofish_fk */*fk*/);
+
 /* --- @twofish_init@ --- *
  *
  * Arguments:  @twofish_ctx *k@ = pointer to key block to fill in
@@ -96,6 +121,21 @@ typedef struct twofish_ctx {
 extern void twofish_init(twofish_ctx */*k*/,
                         const void */*buf*/, size_t /*sz*/);
 
+/* --- @twofish_fkinit@ --- *
+ *
+ * Arguments:  @twofish_fk *fk@ = pointer to family key block
+ *             @const void *buf@ = pointer to buffer of key material
+ *             @size_t sz@ = size of key material
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes a family-key buffer.  This implementation allows
+ *             family keys of any size acceptable to the Twofish algorithm.
+ */
+
+extern void twofish_fkinit(twofish_fk */*fk*/,
+                          const void */*buf*/, size_t /*sz*/);
+
 /* --- @twofish_eblk@, @twofish_dblk@ --- *
  *
  * Arguments:  @const twofish_ctx *k@ = pointer to key block