X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/898a4e2555438ff8adb08b4d82690d08715e1048..b817bfc642225b8c3c0b6a7e42d1fb949b61a606:/rsa-gen.c diff --git a/rsa-gen.c b/rsa-gen.c index e3f5fda..951ab9f 100644 --- a/rsa-gen.c +++ b/rsa-gen.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rsa-gen.c,v 1.4 2000/10/08 12:11:22 mdw Exp $ + * $Id: rsa-gen.c,v 1.5 2004/04/08 01:36:15 mdw Exp $ * * RSA parameter generation * @@ -27,38 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: rsa-gen.c,v $ - * Revision 1.4 2000/10/08 12:11:22 mdw - * Use @MP_EQ@ instead of @MP_CMP@. - * - * Revision 1.3 2000/07/01 11:22:22 mdw - * Remove bad type name `rsa_param'. - * - * Revision 1.2 2000/06/17 12:05:15 mdw - * Lots of changes: - * - * * Apply limits on %$\gcd(p - 1, q - 1)$% to reduce the space of - * equivalent decryption exponents. - * - * * Force %$e = F_4 = 2^{16} + 1$% to avoid small-encryption-exponent - * attacks. - * - * * Ensure that %$p > q$% and that %$p - q$% is large to deter - * square-root-based factoring methods. - * - * * Use %$e d \equiv 1 \pmod{\lambda(n)}$%, where %$\lambda(n)$% is - * %$\lcm(p - 1, q - 1)$%, as recommended in PKCS#1, rather than the - * more usual %$\varphi(n) = (p - 1)(q - 1)$%. - * - * * Handle aborts from pgen_jump. - * - * Revision 1.1 1999/12/22 15:50:45 mdw - * Initial RSA support. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -163,7 +131,7 @@ again: /* --- Work out the modulus and the CRT coefficient --- */ rp->n = mp_mul(MP_NEW, rp->p, rp->q); - rp->q_inv = MP_NEW; mp_gcd(0, 0, &rp->q_inv, rp->p, rp->q); + rp->q_inv = mp_modinv(MP_NEW, rp->q, rp->p); /* --- Work out %$\varphi(n) = (p - 1)(q - 1)$% --- * *