Add an internal-representation no-op function.
[u/mdw/catacomb] / rspit.c
diff --git a/rspit.c b/rspit.c
index 4622d90..7896ead 100644 (file)
--- a/rspit.c
+++ b/rspit.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: rspit.c,v 1.10 2000/08/11 21:34:59 mdw Exp $
+ * $Id: rspit.c,v 1.16 2001/04/29 18:11:32 mdw Exp $
  *
  * Spit out random numbers
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: rspit.c,v $
+ * Revision 1.16  2001/04/29 18:11:32  mdw
+ * New block ciphers.
+ *
+ * Revision 1.15  2001/04/19 18:26:13  mdw
+ * Use the new MAC keysize names.
+ *
+ * Revision 1.14  2001/02/21 20:03:22  mdw
+ * Added support for MD2 hash function.
+ *
+ * Revision 1.13  2000/12/06 20:33:27  mdw
+ * Make flags be macros rather than enumerations, to ensure that they're
+ * unsigned.
+ *
+ * Revision 1.12  2000/10/08 15:49:18  mdw
+ * Remove failed kludge for shutting up a warning.
+ *
+ * Revision 1.11  2000/10/08 12:10:32  mdw
+ * Make table have external linkage to bodge around deficiency in C.  The
+ * problem is that @static gen generators[];@ is considered to be a
+ * `tentative definition', and therefore mustn't have incomplete type,
+ * which it obviously has.
+ *
  * Revision 1.10  2000/08/11 21:34:59  mdw
  * New restartable interface to Maurer testing.
  *
 #include "des3-ofb.h"
 #include "rc2-ofb.h"
 #include "rc5-ofb.h"
+#include "mars-ofb.h"
 #include "skipjack-ofb.h"
 #include "tea-ofb.h"
 #include "xtea-ofb.h"
 #include "cast128-ofb.h"
 #include "cast256-ofb.h"
 #include "rijndael-ofb.h"
+#include "safer-ofb.h"
+#include "safersk-ofb.h"
 #include "square-ofb.h"
 #include "serpent-ofb.h"
 
 #include "des3-counter.h"
 #include "rc2-counter.h"
 #include "rc5-counter.h"
+#include "mars-counter.h"
 #include "skipjack-counter.h"
 #include "tea-counter.h"
 #include "xtea-counter.h"
 #include "cast128-counter.h"
 #include "cast256-counter.h"
 #include "rijndael-counter.h"
+#include "safer-counter.h"
+#include "safersk-counter.h"
 #include "square-counter.h"
 #include "serpent-counter.h"
 
+#include "md2-mgf.h"
 #include "md4-mgf.h"
 #include "md5-mgf.h"
 #include "sha-mgf.h"
@@ -157,13 +186,14 @@ typedef struct gen {
   const char *help;
 } gen;
 
-static gen generators[];
+extern gen generators[];
 
 #define CIPHERS                                                                \
   E(DES, des)                                                          \
   E(DES3, des3)                                                                \
   E(RC2, rc2)                                                          \
   E(RC5, rc5)                                                          \
+  E(MARS, mars)                                                                \
   E(SKIPJACK, skipjack)                                                        \
   E(TEA, tea)                                                          \
   E(XTEA, xtea)                                                                \
@@ -173,10 +203,13 @@ static gen generators[];
   E(CAST128, cast128)                                                  \
   E(CAST256, cast256)                                                  \
   E(SQUARE, square)                                                    \
+  E(SAFER, safer)                                                      \
+  E(SAFERSK, safersk)                                                  \
   E(RIJNDAEL, rijndael)                                                        \
   E(SERPENT, serpent)
 
 #define HASHES                                                         \
+  E(MD2, md2)                                                          \
   E(MD4, md4)                                                          \
   E(MD5, md5)                                                          \
   E(SHA, sha)                                                          \
@@ -228,14 +261,12 @@ static char **argv;
 
 static unsigned flags = 0;
 
-enum {
-  f_progress = 1,
-  f_file = 2,
-  f_fips = 4,
-  f_maurer = 8,
-  f_timer = 16,
-  f_discard = 32
-};
+#define f_progress 1u
+#define f_file 2u
+#define f_fips 4u
+#define f_maurer 8u
+#define f_timer 16u
+#define f_discard 32u
 
 /*----- Help options ------------------------------------------------------*/
 
@@ -711,7 +742,7 @@ static grand *gen_rand(unsigned i)
     switch (o) {
       case 'k':
        DRESET(&d);
-       textkey(&d, optarg, rmd160_mackeysz);
+       textkey(&d, optarg, rmd160_hmackeysz);
        r->ops->misc(r, RAND_KEY, d.buf, d.len);
        break;
       case 't':
@@ -719,7 +750,7 @@ static grand *gen_rand(unsigned i)
        break;
       case 'H':
        DRESET(&d);
-       hexkey(&d, optarg, rmd160_mackeysz);
+       hexkey(&d, optarg, rmd160_hmackeysz);
        r->ops->misc(r, GRAND_SEEDBLOCK, d.buf, d.len);
        break;
     }
@@ -1069,7 +1100,7 @@ static grand *gen_opts(unsigned i)
 
 /*----- Generators table --------------------------------------------------*/
 
-static gen generators[] = {
+gen generators[] = {
   { "fibonacci",       gen_fib,        0,
     "[-s SEED]" },
   { "lc",              gen_lc,         0,
@@ -1083,12 +1114,12 @@ static gen generators[] = {
   { #pre "-counter",   gen_counter,    CIPHER_##PRE,                   \
     "[-k KEY-PHRASE] [-H HEX-KEY] [-i HEX-IV]" },
   CIPHERS
-#undef E(PRE, pre)
+#undef E
 #define E(PRE, pre)                                                    \
   { #pre "-mgf",       gen_mgf,        HASH_##PRE,                     \
     "[-k KEY-PHRASE] [-H HEX-KEY] [-i INDEX]" },
   HASHES
-#undef E(PRE, pre)
+#undef E
   { "rc4",             gen_rc4,        0,
     "[-k KEY-PHRASE] [-H HEX-KEY]" },
   { "seal",            gen_seal,       0,