From 72a6efc4d59568868fc6bbe05d343f777fc1a159 Mon Sep 17 00:00:00 2001 From: mdw Date: Thu, 8 Apr 2004 16:27:49 +0000 Subject: [PATCH] Slightly better factoring. --- dsig.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/dsig.c b/dsig.c index 6e624c6..5a60444 100644 --- a/dsig.c +++ b/dsig.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: dsig.c,v 1.10 2004/04/08 01:36:15 mdw Exp $ + * $Id: dsig.c,v 1.11 2004/04/08 16:27:49 mdw Exp $ * * Verify signatures on distribuitions of files * @@ -266,6 +266,15 @@ typedef struct dsa_sigctx { gdsa g; } dsa_sigctx; +static void dsa_initcommon(dsa_sigctx *ds, const gchash *hc, + const char *ktag) +{ + ds->g.r = &rand_global; + ds->g.h = hc; + ds->g.u = MP_NEW; + ds->s.h = 0; +} + static dsa_sigctx *dsa_doinit(key *k, const gprime_param *gp, mp *y, const gchash *hc) { @@ -275,13 +284,10 @@ static dsa_sigctx *dsa_doinit(key *k, const gprime_param *gp, key_fulltag(k, &t); if ((ds->g.g = group_prime(gp)) == 0) die(EXIT_FAILURE, "bad prime group in key `%s'", t.buf); - ds->g.u = MP_NEW; ds->g.p = G_CREATE(ds->g.g); if (G_FROMINT(ds->g.g, ds->g.p, y)) die(EXIT_FAILURE, "bad public key in key `%s'", t.buf); - ds->g.r = &rand_global; - ds->g.h = hc; - ds->s.h = 0; + dsa_initcommon(ds, hc, t.buf); dstr_destroy(&t); return (ds); } @@ -298,13 +304,10 @@ static dsa_sigctx *ecdsa_doinit(key *k, const char *cstr, if ((e = ec_getinfo(&ei, cstr)) != 0) die(EXIT_FAILURE, "bad curve in key `%s': %s", t.buf, e); ds->g.g = group_ec(&ei); - ds->g.u = MP_NEW; ds->g.p = G_CREATE(ds->g.g); if (G_FROMEC(ds->g.g, ds->g.p, y)) die(EXIT_FAILURE, "bad public key in key `%s'", t.buf); - ds->g.r = &rand_global; - ds->g.h = hc; - ds->s.h = 0; + dsa_initcommon(ds, hc, t.buf); dstr_destroy(&t); return (ds); } -- 2.11.0