/* -*-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
*
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)
{
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);
}
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);
}