projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use mpmul for the multiplication.
[u/mdw/catacomb]
/
pgen-safe.c
diff --git
a/pgen-safe.c
b/pgen-safe.c
index
a8c5ac7
..
03ba35a
100644
(file)
--- a/
pgen-safe.c
+++ b/
pgen-safe.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: pgen-safe.c,v 1.
2 2000/02/12 18:21:03
mdw Exp $
+ * $Id: pgen-safe.c,v 1.
4 2000/07/03 18:09:27
mdw Exp $
*
* Safe prime generation
*
*
* Safe prime generation
*
@@
-30,6
+30,13
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: pgen-safe.c,v $
/*----- 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.2 2000/02/12 18:21:03 mdw
* Overhaul of key management (again).
*
@@
-119,17
+126,27
@@
int pgen_safejump(int rq, pgen_event *ev, void *p)
*
* The jump in @j.q@ is congruent to 2 (mod 4); see @strongprime_setup@.
* If @p@ is initially 1 (mod 4) then add @j.q@. Then double @j.q@ to
*
* The jump in @j.q@ is congruent to 2 (mod 4); see @strongprime_setup@.
* If @p@ is initially 1 (mod 4) then add @j.q@. Then double @j.q@ to
- * ensure that the step is 0 (mod 4).
+ * ensure that the step is 0 (mod 4). Ensure that @jq@ and @q@ don't
+ * have any common factors.
*/
case PGEN_BEGIN: {
mp *p = ev->m;
mp *q;
*/
case PGEN_BEGIN: {
mp *p = ev->m;
mp *q;
+ mp *g = MP_NEW;
if ((p->v[0] & 3) != 3)
p = mp_add(p, p, j->jq.m);
if ((p->v[0] & 3) != 3)
p = mp_add(p, p, j->jq.m);
+ q = mp_lsr(MP_NEW, p, 1);
+ mp_gcd(&g, 0, 0, p, j->jq.m);
+ if (MP_CMP(g, >, MP_ONE)) {
+ ev->m = p;
+ mp_drop(q);
+ mp_drop(g);
+ return (PGEN_ABORT);
+ }
+ mp_drop(g);
rc = pfilt_create(&j->p, p);
pfilt_muladd(&j->jp, &j->jq, 2, 0);
rc = pfilt_create(&j->p, p);
pfilt_muladd(&j->jp, &j->jq, 2, 0);
- q = mp_lsr(MP_NEW, p, 1);
qrc = pfilt_create(&j->q, q);
mp_drop(p);
mp_drop(q);
qrc = pfilt_create(&j->q, q);
mp_drop(p);
mp_drop(q);