comparison rsa.c @ 378:a124aff0cbf1

merge of '182c2d8dbd5321ef4d1df8758936f4dc7127015f' and '31dcd7a22983ef19d6c63248e415e71d292dd0ec'
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Dec 2006 13:11:41 +0000
parents 9a789fc03f40 454a34b2dfd1
children b50f0107e505 76097ec1a29a
comparison
equal deleted inserted replaced
377:1bfa65fed772 378:a124aff0cbf1
298 gen_random_mpint(key->n, &rsa_tmp2); 298 gen_random_mpint(key->n, &rsa_tmp2);
299 299
300 /* rsa_tmp1 is em */ 300 /* rsa_tmp1 is em */
301 /* em' = em * r^e mod n */ 301 /* em' = em * r^e mod n */
302 302
303 mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s); /* rsa_s used as a temp var*/ 303 /* rsa_s used as a temp var*/
304 mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3); 304 if (mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s) != MP_OKAY) {
305 mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2); 305 dropbear_exit("rsa error");
306 }
307 if (mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3) != MP_OKAY) {
308 dropbear_exit("rsa error");
309 }
310 if (mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2) != MP_OKAY) {
311 dropbear_exit("rsa error");
312 }
306 313
307 /* rsa_tmp2 is em' */ 314 /* rsa_tmp2 is em' */
308 /* s' = (em')^d mod n */ 315 /* s' = (em')^d mod n */
309 mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1); 316 if (mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1) != MP_OKAY) {
317 dropbear_exit("rsa error");
318 }
310 319
311 /* rsa_tmp1 is s' */ 320 /* rsa_tmp1 is s' */
312 /* rsa_tmp3 is r^(-1) mod n */ 321 /* rsa_tmp3 is r^(-1) mod n */
313 /* s = (s')r^(-1) mod n */ 322 /* s = (s')r^(-1) mod n */
314 mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s); 323 if (mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s) != MP_OKAY) {
324 dropbear_exit("rsa error");
325 }
315 326
316 #else 327 #else
317 328
318 /* s = em^d mod n */ 329 /* s = em^d mod n */
319 /* rsa_tmp1 is em */ 330 /* rsa_tmp1 is em */