X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/32fec2a25d06af77ab7ed91fd3047ef638d8d883..ed22931396c81bd562f1ce7dc85a86ea4dd49cd2:/pgen-safe.c diff --git a/pgen-safe.c b/pgen-safe.c index 03ba35a..bd644dc 100644 --- a/pgen-safe.c +++ b/pgen-safe.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: pgen-safe.c,v 1.4 2000/07/03 18:09:27 mdw Exp $ + * $Id: pgen-safe.c,v 1.5 2004/04/08 01:36:15 mdw Exp $ * * Safe prime generation * @@ -27,24 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: pgen-safe.c,v $ - * Revision 1.4 2000/07/03 18:09:27 mdw - * Bug fix to the GCD check. With any luck, this is the last of these to - * need nailing to the wall. - * - * Revision 1.3 2000/06/17 11:52:36 mdw - * Signal a pgen abort if the jump and base share a common factor. - * - * Revision 1.2 2000/02/12 18:21:03 mdw - * Overhaul of key management (again). - * - * Revision 1.1 1999/12/22 16:01:34 mdw - * Find `safe' primes (i.e., %$p = 2q + 1$%). - * - */ - /*----- Header files ------------------------------------------------------*/ #include "mp.h" @@ -198,10 +180,12 @@ int pgen_safetest(int rq, pgen_event *ev, void *p) rc = PGEN_TRY; break; case PGEN_TRY: { - mp *m = mprand_range(MP_NEW, c->c.q.m, ev->r, 0); + mp *m = mprand_range(MP_NEW, c->c.p.m, ev->r, 0); rc = rabin_test(&c->p, m); - if (rc == PGEN_PASS) + if (rc == PGEN_PASS) { + m = mprand_range(m, c->c.q.m, ev->r, 0); rc = rabin_test(&c->q, m); + } mp_drop(m); } break; case PGEN_DONE: