ref: 908dba2489d98dab1f1e9a3e8ba9d45aa65a3511
parent: 8f9953893cf7b27b364ba7c9bd062a65aef6b149
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Feb 5 23:25:38 EST 2017
rsagen: prefer 65537 as the default exponent when elen == 0, otherwise pick randomly
--- a/sys/src/cmd/auth/rsagen.c
+++ b/sys/src/cmd/auth/rsagen.c
@@ -42,7 +42,7 @@
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",--- a/sys/src/libsec/port/rsagen.c
+++ b/sys/src/libsec/port/rsagen.c
@@ -26,9 +26,13 @@
// 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
--
⑨