X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/40d5a1129b6c5d4ede995970e969b79db8d7577a..f4f8e305f12b252b02f405657fc7277a61a3e755:/keyutil.c diff --git a/keyutil.c b/keyutil.c index 3a23a85..25be851 100644 --- a/keyutil.c +++ b/keyutil.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: keyutil.c,v 1.8 2000/07/29 09:59:13 mdw Exp $ + * $Id: keyutil.c,v 1.12 2001/02/03 11:58:22 mdw Exp $ * * Simple key manager program * @@ -30,6 +30,20 @@ /*----- Revision history --------------------------------------------------* * * $Log: keyutil.c,v $ + * Revision 1.12 2001/02/03 11:58:22 mdw + * Store the correct seed information and count for DSA keys now that it's + * available. + * + * Revision 1.11 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * + * Revision 1.10 2000/10/08 12:02:21 mdw + * Use @MP_EQ@ instead of @MP_CMP@. + * + * Revision 1.9 2000/08/15 21:40:49 mdw + * Minor formatting change in listing attributes. + * * Revision 1.8 2000/07/29 09:59:13 mdw * Support Lim-Lee primes in Diffie-Hellman parameter generation. * @@ -176,13 +190,11 @@ typedef struct keyopts { key *p; /* Parameters key-data */ } keyopts; -enum { - f_bogus = 1, /* Error in parsing */ - f_lock = 2, /* Passphrase-lock private key */ - f_quiet = 4, /* Don't show a progress indicator */ - f_limlee = 8, /* Generate Lim-Lee primes */ - f_subgroup = 16 /* Generate a subgroup */ -}; +#define f_bogus 1u /* Error in parsing */ +#define f_lock 2u /* Passphrase-lock private key */ +#define f_quiet 4u /* Don't show a progress indicator */ +#define f_limlee 8u /* Generate Lim-Lee primes */ +#define f_subgroup 16u /* Generate a subgroup */ /* --- @dolock@ --- * * @@ -422,7 +434,7 @@ static void alg_rsa(keyopts *k) c = rsa_qpubop(&rpp, MP_NEW, m); c = rsa_qprivop(&rp, c, c, g); - if (MP_CMP(c, !=, m)) + if (!MP_EQ(c, m)) die(EXIT_FAILURE, "test encryption failed"); mp_drop(c); mp_drop(m); @@ -459,6 +471,7 @@ static void alg_dsaparam(keyopts *k) dstr d = DSTR_INIT; base64_ctx c; key_data *kd = &k->k->k; + dsa_seed ds; /* --- Choose appropriate bit lengths if necessary --- */ @@ -475,7 +488,7 @@ static void alg_dsaparam(keyopts *k) /* --- Allocate the parameters --- */ - if (dsa_gen(&dp, k->qbits, k->bits, 0, p, sz, + if (dsa_gen(&dp, k->qbits, k->bits, 0, p, sz, &ds, (k->f & f_quiet) ? 0 : pgen_ev, 0)) die(EXIT_FAILURE, "DSA parameter generation failed"); @@ -494,9 +507,13 @@ static void alg_dsaparam(keyopts *k) base64_init(&c); c.maxline = 0; c.indent = ""; - base64_encode(&c, p, sz, &d); + base64_encode(&c, ds.p, ds.sz, &d); base64_encode(&c, 0, 0, &d); key_putattr(k->kf, k->k, "seed", d.buf); + DRESET(&d); + dstr_putf(&d, "%u", ds.count); + key_putattr(k->kf, k->k, "count", d.buf); + xfree(ds.p); sub_free(p, sz); dstr_destroy(&d); } @@ -906,11 +923,9 @@ typedef struct listopts { /* --- Listing flags --- */ -enum { - f_newline = 2, /* Write newline before next entry */ - f_attr = 4, /* Written at least one attribute */ - f_utc = 8 /* Emit UTC time, not local time */ -}; +#define f_newline 2u /* Write newline before next entry */ +#define f_attr 4u /* Written at least one attribute */ +#define f_utc 8u /* Emit UTC time, not local time */ /* --- @showkeydata@ --- * * @@ -1097,7 +1112,7 @@ static void showkey(key *k, listopts *o) o->f &= ~f_attr; printf("attributes:"); for (key_mkattriter(&i, k); key_nextattr(&i, &an, &av); ) { - printf("\n\t%s = %s", an, av); + printf("\n %s = %s", an, av); o->f |= f_attr; } if (o->f & f_attr) @@ -1621,9 +1636,7 @@ int main(int argc, char *argv[]) { unsigned f = 0; - enum { - f_bogus = 1 - }; +#define f_bogus 1u /* --- Initialization --- */