New functions for freeing public and private keys. Remove bad type name
[u/mdw/catacomb] / rsa-recover.c
index 14b67bd..18b6c6a 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: rsa-recover.c,v 1.2 2000/06/17 12:07:19 mdw Exp $
+ * $Id: rsa-recover.c,v 1.3 2000/06/22 19:03:14 mdw Exp $
  *
  * Recover RSA parameters
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: rsa-recover.c,v $
+ * Revision 1.3  2000/06/22 19:03:14  mdw
+ * Use the new @mp_odd@ function.
+ *
  * Revision 1.2  2000/06/17 12:07:19  mdw
  * Fix a bug in argument validation.  Force %$p > q$% in output.  Use
  * %$\lambda(n) = \lcm(p - 1, q - 1)$% rather than the more traditional
@@ -93,8 +96,7 @@ int rsa_recover(rsa_param *rp)
       return (-1);
     else {
       mp *t;
-      unsigned s;
-      mpscan ms;
+      size_t s;
       mp a; mpw aw;
       mp *m1;
       mpmont mm;
@@ -109,15 +111,7 @@ int rsa_recover(rsa_param *rp)
 
       t = mp_mul(MP_NEW, rp->e, rp->d);
       t = mp_sub(t, t, MP_ONE);
-      s = 0;
-      mp_scan(&ms, t);
-      for (;;) {
-       MP_STEP(&ms);
-       if (MP_BIT(&ms))
-         break;
-       s++;
-      }
-      t = mp_lsr(t, t, s);
+      t = mp_odd(t, t, &s);
 
       /* --- Set up for the exponentiation --- */