Uprating of the passphrase pixie.
[u/mdw/catacomb] / gkcdsa.c
index f7119f5..a67ab0d 100644 (file)
--- a/gkcdsa.c
+++ b/gkcdsa.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: gkcdsa.c,v 1.1 2004/04/04 19:42:59 mdw Exp $
+ * $Id$
  *
  * Generalized version of KCDSA
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: gkcdsa.c,v $
- * Revision 1.1  2004/04/04 19:42:59  mdw
- * Add set -e.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include "gkcdsa.h"
@@ -45,9 +37,9 @@
 
 /*----- Main code ---------------------------------------------------------*/
 
-/* --- @gdsa_beginhash@ --- *
+/* --- @gkcdsa_beginhash@ --- *
  *
- * Arguments:  @const gdsa *c@ = pointer to the context structure
+ * Arguments:  @const gkcdsa *c@ = pointer to the context structure
  *
  * Returns:    A hashing context for you to hash the message.
  *
@@ -61,7 +53,6 @@ ghash *gkcdsa_beginhash(const gkcdsa *c)
   mp *v = G_TOINT(c->g, MP_NEW, c->p);
   size_t sz = c->h->bufsz;
   void *p = xmalloc(sz);
-
   if (/*ouch*/ !v) memset(p, 0, sz);
   else mp_storeb(v, p, sz);
   GH_HASH(h, p, sz);
@@ -81,7 +72,7 @@ ghash *gkcdsa_beginhash(const gkcdsa *c)
  *             isn't finalized.
  */
 
-void gkcdsa_endhash(gkcdsa *c, ghash *h) { ; }
+void gkcdsa_endhash(const gkcdsa *c, ghash *h) { ; }
 
 /* --- @hashge@ --- *
  *
@@ -138,7 +129,7 @@ void gkcdsa_sign(const gkcdsa *c, gkcdsa_sig *s, const void *m, mp *k)
 new_k:
   k = mprand_range(k, g->r, c->r, 0);
 have_k:
-  if (MP_ISZERO(k)) goto new_k;
+  if (MP_ZEROP(k)) goto new_k;
   G_EXP(g, z, g->g, k);
   if (!s->r) s->r = xmalloc(hsz);
   h = hashge(g, c->h, z); GH_DONE(h, s->r);
@@ -238,7 +229,7 @@ static int tsign(dstr *v)
   DENSURE(&d, c.h->hashsz); d.len = c.h->hashsz; memset(d.buf, 0, d.len);
   ss.r = (octet *)d.buf;
 
-  x = MP_NEW; mp_gcd(0, 0, &x, c.g->r, c.u);
+  x = mp_modinv(MP_NEW, c.u, c.g->r);
   c.p = G_CREATE(c.g); G_EXP(c.g, c.p, c.g->g, x);
   h = gkcdsa_beginhash(&c);
   GH_HASH(h, v[3].buf, v[3].len);