--- /n/sources/plan9/sys/src/cmd/auth/rsagen.c Wed Mar 26 06:00:01 2003 +++ /sys/src/cmd/auth/rsagen.c Mon Feb 6 04:25:38 2017 @@ -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", --- /n/sources/plan9/sys/src/libsec/port/rsagen.c Wed May 12 06:00:02 2004 +++ /sys/src/libsec/port/rsagen.c Mon Feb 6 04:25:38 2017 @@ -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