diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-02-06 04:25:38 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-02-06 04:25:38 +0100 |
commit | bbce9c0566da28911f0ce444d0fdca0fe4eb77b9 (patch) | |
tree | 159b5fd063d16539ea661052f8a48e6387b8295d /sys/src/libsec | |
parent | 5256f4063e381bb7a6f175ea397202e93f8be4b1 (diff) |
rsagen: prefer 65537 as the default exponent when elen == 0, otherwise pick randomly
Diffstat (limited to 'sys/src/libsec')
-rw-r--r-- | sys/src/libsec/port/rsagen.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/src/libsec/port/rsagen.c b/sys/src/libsec/port/rsagen.c index 31c06241c..01d242681 100644 --- a/sys/src/libsec/port/rsagen.c +++ b/sys/src/libsec/port/rsagen.c @@ -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 |