Mercurial > dropbear
comparison rsa.c @ 340:454a34b2dfd1
Fixes from Erik Hovland:
cli-authpubkey.c:
fix leak of keybuf
cli-kex.c:
fix leak of fingerprint fp
cli-service.c:
remove commented out code
dropbearkey.c:
don't attepmt to free NULL key on failure
common-kex.c:
only free key if it is initialised
keyimport.c:
remove dead encrypted-key code
don't leak a FILE* loading OpenSSH keys
rsa.c, dss.c:
check return values for some libtommath functions
svr-kex.c:
check return value retrieving DH kex mpint
svr-tcpfwd.c:
fix null-dereference if remote tcp forward request fails
tcp-accept.c:
don't incorrectly free the tcpinfo var
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 07 Jul 2006 09:17:18 +0000 |
parents | 3cea9d789cca |
children | ed24dfc44904 a124aff0cbf1 |
comparison
equal
deleted
inserted
replaced
339:31743c9bdf78 | 340:454a34b2dfd1 |
---|---|
283 gen_random_mpint(key->n, &rsa_tmp2); | 283 gen_random_mpint(key->n, &rsa_tmp2); |
284 | 284 |
285 /* rsa_tmp1 is em */ | 285 /* rsa_tmp1 is em */ |
286 /* em' = em * r^e mod n */ | 286 /* em' = em * r^e mod n */ |
287 | 287 |
288 mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s); /* rsa_s used as a temp var*/ | 288 /* rsa_s used as a temp var*/ |
289 mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3); | 289 if (mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s) != MP_OKAY) { |
290 mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2); | 290 dropbear_exit("rsa error"); |
291 } | |
292 if (mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3) != MP_OKAY) { | |
293 dropbear_exit("rsa error"); | |
294 } | |
295 if (mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2) != MP_OKAY) { | |
296 dropbear_exit("rsa error"); | |
297 } | |
291 | 298 |
292 /* rsa_tmp2 is em' */ | 299 /* rsa_tmp2 is em' */ |
293 /* s' = (em')^d mod n */ | 300 /* s' = (em')^d mod n */ |
294 mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1); | 301 if (mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1) != MP_OKAY) { |
302 dropbear_exit("rsa error"); | |
303 } | |
295 | 304 |
296 /* rsa_tmp1 is s' */ | 305 /* rsa_tmp1 is s' */ |
297 /* rsa_tmp3 is r^(-1) mod n */ | 306 /* rsa_tmp3 is r^(-1) mod n */ |
298 /* s = (s')r^(-1) mod n */ | 307 /* s = (s')r^(-1) mod n */ |
299 mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s); | 308 if (mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s) != MP_OKAY) { |
309 dropbear_exit("rsa error"); | |
310 } | |
300 | 311 |
301 #else | 312 #else |
302 | 313 |
303 /* s = em^d mod n */ | 314 /* s = em^d mod n */ |
304 /* rsa_tmp1 is em */ | 315 /* rsa_tmp1 is em */ |