X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/a69a3efddbe1261f55e90d4ff477053ab80663a5..e74e12bc7c899a47d3f0e28420f6502b8f70a5a9:/gdsa.c diff --git a/gdsa.c b/gdsa.c index 751bcce..83f4d06 100644 --- a/gdsa.c +++ b/gdsa.c @@ -7,7 +7,7 @@ * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,12 +15,12 @@ * 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, @@ -57,11 +57,11 @@ ghash *gdsa_beginhash(const gdsa *c) { return (GH_INIT(c->h)); } * Returns: --- * * Use: Does any final thing that DSA wants to do when hashing a - * message. (Actually, there's nothing.) The hashing context + * message. (Actually, there's nothing.) The hashing context * isn't finalized. */ -void gdsa_endhash(gdsa *c, ghash *h) { ; } +void gdsa_endhash(const gdsa *c, ghash *h) { ; } /* --- @gdsa_sign@ --- * * @@ -79,7 +79,7 @@ void gdsa_endhash(gdsa *c, ghash *h) { ; } void gdsa_sign(const gdsa *c, gdsa_sig *s, const void *m, mp *k) { group *g = c->g; - mp *mr = mp_loadb(MP_NEW, m, c->h->hashsz); + mp *mr = dsa_h2n(MP_NEW, g->r, m, c->h->hashsz); ge *z = G_CREATE(g); mp *sr = s->r, *ss = s->s; mpbarrett b; @@ -128,7 +128,7 @@ int gdsa_verify(const gdsa *c, const gdsa_sig *s, const void *m) return (-1); mpbarrett_create(&b, g->r); h = mp_modinv(MP_NEW, s->s, g->r); e[0].base = g->g; e[1].base = c->p; - t = mp_loadb(MP_NEW, m, c->h->hashsz); mp_div(0, &t, t, g->r); + t = dsa_h2n(MP_NEW, g->r, m, c->h->hashsz); mp_div(0, &t, t, g->r); t = mp_mul(t, t, h); e[0].exp = t = mpbarrett_reduce(&b, t, t); h = mp_mul(h, s->r, h); e[1].exp = h = mpbarrett_reduce(&b, h, h); w = G_CREATE(g); G_MEXP(g, w, e, 2); @@ -167,7 +167,7 @@ static void showge(group *g, const char *p, ge *x) { } static void showmp(const char *p, mp *x, int r) { - fprintf(stderr, "*** %s = ", p); mp_writefile(x, stderr, r); + fprintf(stderr, "*** %s = ", p); mp_writefile(x, stderr, r); putc('\n', stderr); }