1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Make modinv able to return NULL if its inputs are not coprime, and

check for that return value everywhere it is used.

[originally from svn r9990]
This commit is contained in:
Simon Tatham
2013-08-04 19:34:07 +00:00
parent 9c054cf467
commit cb1df53360
4 changed files with 59 additions and 14 deletions

View File

@ -2,6 +2,8 @@
* RSA key generation.
*/
#include <assert.h>
#include "ssh.h"
#define RSA_EXPONENT 37 /* we like this prime */
@ -92,8 +94,10 @@ int rsa_generate(struct RSAKey *key, int bits, progfn_t pfn,
freebn(pm1);
freebn(qm1);
key->private_exponent = modinv(key->exponent, phi_n);
assert(key->private_exponent);
pfn(pfnparam, PROGFN_PROGRESS, 3, 4);
key->iqmp = modinv(key->q, key->p);
assert(key->iqmp);
pfn(pfnparam, PROGFN_PROGRESS, 3, 5);
/*