X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/e3dc2d225ea40a7453ae19ef4d12cf4c001076bd..cc3ca08f22460b15423bb88632f3a12741b19003:/rspit.c diff --git a/rspit.c b/rspit.c index 4622d90..e471508 100644 --- a/rspit.c +++ b/rspit.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: rspit.c,v 1.10 2000/08/11 21:34:59 mdw Exp $ + * $Id$ * * Spit out random numbers * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,56 +15,18 @@ * 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: rspit.c,v $ - * Revision 1.10 2000/08/11 21:34:59 mdw - * New restartable interface to Maurer testing. - * - * Revision 1.9 2000/08/04 23:24:15 mdw - * Add a timer and a discard option. - * - * Revision 1.8 2000/07/29 22:05:47 mdw - * Fix error in help message about Maurer test syntax. - * - * Revision 1.7 2000/07/18 23:01:26 mdw - * Improve progress indications, and allow user to choose chunk sizes for - * Maurer's test. - * - * Revision 1.6 2000/07/15 20:53:35 mdw - * Add a load of new ciphers and hashes. - * - * Revision 1.5 2000/07/01 11:27:03 mdw - * Portability fix: don't assume that `stdout' is a constant expression. - * Remove old type name `bbs_param'. - * - * Revision 1.4 2000/06/17 12:08:28 mdw - * Restructure handling of cipher-based generators. Add counter-mode - * ciphers and MGF-1 hash functions. Add FIPS 140-1 and Maurer's tests. - * - * Revision 1.3 2000/02/12 18:21:03 mdw - * Overhaul of key management (again). - * - * Revision 1.2 1999/12/22 15:59:51 mdw - * New prime-search system. Read BBS keys from key files. - * - * Revision 1.1 1999/12/10 23:29:13 mdw - * Emit random numbers for statistical tests. - * - */ - /*----- Header files ------------------------------------------------------*/ #include "config.h" @@ -109,6 +71,7 @@ #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" @@ -117,7 +80,12 @@ #include "idea-ofb.h" #include "cast128-ofb.h" #include "cast256-ofb.h" +#include "noekeon-ofb.h" #include "rijndael-ofb.h" +#include "rijndael192-ofb.h" +#include "rijndael256-ofb.h" +#include "safer-ofb.h" +#include "safersk-ofb.h" #include "square-ofb.h" #include "serpent-ofb.h" @@ -125,6 +93,7 @@ #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" @@ -133,10 +102,16 @@ #include "idea-counter.h" #include "cast128-counter.h" #include "cast256-counter.h" +#include "noekeon-counter.h" #include "rijndael-counter.h" +#include "rijndael192-counter.h" +#include "rijndael256-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 +132,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 +149,16 @@ static gen generators[]; E(CAST128, cast128) \ E(CAST256, cast256) \ E(SQUARE, square) \ + E(SAFER, safer) \ + E(SAFERSK, safersk) \ + E(NOEKEON, noekeon) \ E(RIJNDAEL, rijndael) \ + E(RIJNDAEL192, rijndael192) \ + E(RIJNDAEL256, rijndael256) \ E(SERPENT, serpent) #define HASHES \ + E(MD2, md2) \ E(MD4, md4) \ E(MD5, md5) \ E(SHA, sha) \ @@ -228,14 +210,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 ------------------------------------------------------*/ @@ -515,7 +495,7 @@ static grand *gen_bbs(unsigned i) * The factors of this number are * * @p = 1229936431484295969649886203367009966370895964206162032259292413@ - * @7754313537966036459299022912838407755462506416274551744201653277@ + * @7754313537966036459299022912838407755462506416274551744201653277@ * @313130311731673973886822067@ * * @q = 9798171783943489959487301695884963889684294764514008432498259742@ @@ -533,7 +513,11 @@ static grand *gen_bbs(unsigned i) */ const char *mt = - "120511284390135742513572142094334711443073194119732569353820828435640527418092392240366088035509890969913081816369160298961490135716255689660470370755013177656905237112577648090277537209936078171554274553448103698084782669252936352843649980105109850503830397166360721262431179505917248447259735253684659338653"; + "12051128439013574251357214209433471144307319411973256935382082" + "84356405274180923922403660880355098909699130818163691602989614" + "90135716255689660470370755013177656905237112577648090277537209" + "93607817155427455344810369808478266925293635284364998010510985" + "0503830397166360721262431179505917248447259735253684659338653"; /* --- Other things --- */ @@ -635,12 +619,12 @@ static grand *gen_bbs(unsigned i) /* --- Read the key data --- */ - if ((kk->k.e & KF_ENCMASK) != KENC_STRUCT) + if ((kk->k->e & KF_ENCMASK) != KENC_STRUCT) die(EXIT_FAILURE, "key is not structured"); - if ((kd = key_structfind(&kk->k, "n")) == 0) + if ((kd = key_structfind(kk->k, "n")) == 0) die(EXIT_FAILURE, "key has no subkey `n'"); if ((kd->e & KF_ENCMASK) != KENC_MP) - die(EXIT_FAILURE, "incomatible subkey encoding"); + die(EXIT_FAILURE, "incompatible subkey encoding"); m = MP_COPY(kd->u.m); key_close(&kf); } else { @@ -711,7 +695,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 +703,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 +1053,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 +1067,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,