rsagen: prefer 65537 as the default exponent when elen == 0, otherwise pick randomly
This commit is contained in:
parent
5256f4063e
commit
bbce9c0566
|
@ -42,7 +42,7 @@ main(int argc, char **argv)
|
|||
do{
|
||||
if(key)
|
||||
rsaprivfree(key);
|
||||
key = rsagen(bits, 6, 0);
|
||||
key = rsagen(bits, 0, 0);
|
||||
}while(mpsignif(key->pub.n) != bits);
|
||||
|
||||
s = smprint("key proto=rsa %s%ssize=%d ek=%B !dk=%B n=%B !p=%B !q=%B !kp=%B !kq=%B !c2=%B\n",
|
||||
|
|
|
@ -26,9 +26,13 @@ rsagen(int nlen, int elen, int rounds)
|
|||
// find an e relatively prime to phi
|
||||
t1 = mpnew(0);
|
||||
t2 = mpnew(0);
|
||||
mprand(elen, genrandom, e);
|
||||
if(mpcmp(e,mptwo) <= 0)
|
||||
itomp(3, e);
|
||||
if(elen == 0)
|
||||
itomp(65537, e);
|
||||
else {
|
||||
mprand(elen, genrandom, e);
|
||||
if(mpcmp(e,mptwo) <= 0)
|
||||
itomp(3, e);
|
||||
}
|
||||
// See Menezes et al. p.291 "8.8 Note (selecting primes)" for discussion
|
||||
// of the merits of various choices of primes and exponents. e=3 is a
|
||||
// common and recommended exponent, but doesn't necessarily work here
|
||||
|
|
Loading…
Reference in a new issue