projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Random number generator for finding DSA parameters.
[u/mdw/catacomb]
/
dh-prime.c
diff --git
a/dh-prime.c
b/dh-prime.c
index
81dc423
..
ebe3a33
100644
(file)
--- a/
dh-prime.c
+++ b/
dh-prime.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: dh-prime.c,v 1.
1 1999/11/20 22:24:44
mdw Exp $
+ * $Id: dh-prime.c,v 1.
2 1999/12/10 23:18:38
mdw Exp $
*
* Generate (safe) Diffie-Hellman primes
*
*
* Generate (safe) Diffie-Hellman primes
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: dh-prime.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: dh-prime.c,v $
+ * Revision 1.2 1999/12/10 23:18:38 mdw
+ * Change interface for suggested destinations.
+ *
* Revision 1.1 1999/11/20 22:24:44 mdw
* Add Diffie-Hellman support.
*
* Revision 1.1 1999/11/20 22:24:44 mdw
* Add Diffie-Hellman support.
*
@@
-42,7
+45,9
@@
#include <string.h>
#include "dh.h"
#include <string.h>
#include "dh.h"
+#include "fibrand.h"
#include "mp.h"
#include "mp.h"
+#include "mprand.h"
#include "pgen.h"
#include "rabin.h"
#include "pgen.h"
#include "rabin.h"
@@
-70,14
+75,14
@@
mp *dh_prime(mp *s, size_t n,
{
pgen pq, pp;
int rc_q, rc_p;
{
pgen pq, pp;
int rc_q, rc_p;
- mpw bw;
- mp b;
+ grand *gr = fibrand_create(0);
+ mp *b = MP_NEW;
+ size_t sz = mp_bits(s);
/* --- Initialize prime generators --- */
rc_q = pgen_create(&pq, s);
rc_p = pgen_muladd(&pp, &pq, 2, 1);
/* --- Initialize prime generators --- */
rc_q = pgen_create(&pq, s);
rc_p = pgen_muladd(&pp, &pq, 2, 1);
- mp_build(&b, &bw, &bw + 1);
/* --- Now step along until something crops up --- */
/* --- Now step along until something crops up --- */
@@
-106,12
+111,12
@@
mp *dh_prime(mp *s, size_t n,
*/
for (i = 0; i < 5; i++) {
*/
for (i = 0; i < 5; i++) {
- b
w = ptab[i]
;
+ b
= mprand(b, sz, gr, 1)
;
if (rc_q == PGEN_MAYBE &&
if (rc_q == PGEN_MAYBE &&
- (rc_q = rabin_test(&rq,
&
b)) == PGEN_COMPOSITE)
+ (rc_q = rabin_test(&rq, b)) == PGEN_COMPOSITE)
break;
if (rc_p == PGEN_MAYBE &&
break;
if (rc_p == PGEN_MAYBE &&
- (rc_p = rabin_test(&rp,
&
b)) == PGEN_COMPOSITE)
+ (rc_p = rabin_test(&rp, b)) == PGEN_COMPOSITE)
break;
if (proc && proc(DHEV_PASS, arg))
break;
break;
if (proc && proc(DHEV_PASS, arg))
break;
@@
-146,6
+151,8
@@
mp *dh_prime(mp *s, size_t n,
mp *p = MP_COPY(pp.m);
pgen_destroy(&pq);
pgen_destroy(&pp);
mp *p = MP_COPY(pp.m);
pgen_destroy(&pq);
pgen_destroy(&pp);
+ mp_drop(b);
+ gr->ops->destroy(gr);
return (p);
}
return (p);
}
@@
-154,6
+161,8
@@
mp *dh_prime(mp *s, size_t n,
fail:
pgen_destroy(&pq);
pgen_destroy(&pp);
fail:
pgen_destroy(&pq);
pgen_destroy(&pp);
+ mp_drop(b);
+ gr->ops->destroy(gr);
return (0);
}
return (0);
}