comparison rsa.c @ 594:a98a2138364a

Improve capitalisation for all logged strings
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Feb 2011 15:50:30 +0000
parents b50f0107e505
children 2b1bb792cd4d 9a5438271556 f336d232fc63
comparison
equal deleted inserted replaced
593:ea103e4476ce 594:a98a2138364a
65 TRACE(("leave buf_get_rsa_pub_key: failure")) 65 TRACE(("leave buf_get_rsa_pub_key: failure"))
66 goto out; 66 goto out;
67 } 67 }
68 68
69 if (mp_count_bits(key->n) < MIN_RSA_KEYLEN) { 69 if (mp_count_bits(key->n) < MIN_RSA_KEYLEN) {
70 dropbear_log(LOG_WARNING, "rsa key too short"); 70 dropbear_log(LOG_WARNING, "RSA key too short");
71 goto out; 71 goto out;
72 } 72 }
73 73
74 TRACE(("leave buf_get_rsa_pub_key: success")) 74 TRACE(("leave buf_get_rsa_pub_key: success"))
75 ret = DROPBEAR_SUCCESS; 75 ret = DROPBEAR_SUCCESS;
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 /* rsa_s used as a temp var*/ 303 /* rsa_s used as a temp var*/
304 if (mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s) != MP_OKAY) { 304 if (mp_exptmod(&rsa_tmp2, key->e, key->n, &rsa_s) != MP_OKAY) {
305 dropbear_exit("rsa error"); 305 dropbear_exit("RSA error");
306 } 306 }
307 if (mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3) != MP_OKAY) { 307 if (mp_invmod(&rsa_tmp2, key->n, &rsa_tmp3) != MP_OKAY) {
308 dropbear_exit("rsa error"); 308 dropbear_exit("RSA error");
309 } 309 }
310 if (mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2) != MP_OKAY) { 310 if (mp_mulmod(&rsa_tmp1, &rsa_s, key->n, &rsa_tmp2) != MP_OKAY) {
311 dropbear_exit("rsa error"); 311 dropbear_exit("RSA error");
312 } 312 }
313 313
314 /* rsa_tmp2 is em' */ 314 /* rsa_tmp2 is em' */
315 /* s' = (em')^d mod n */ 315 /* s' = (em')^d mod n */
316 if (mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1) != MP_OKAY) { 316 if (mp_exptmod(&rsa_tmp2, key->d, key->n, &rsa_tmp1) != MP_OKAY) {
317 dropbear_exit("rsa error"); 317 dropbear_exit("RSA error");
318 } 318 }
319 319
320 /* rsa_tmp1 is s' */ 320 /* rsa_tmp1 is s' */
321 /* rsa_tmp3 is r^(-1) mod n */ 321 /* rsa_tmp3 is r^(-1) mod n */
322 /* s = (s')r^(-1) mod n */ 322 /* s = (s')r^(-1) mod n */
323 if (mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s) != MP_OKAY) { 323 if (mp_mulmod(&rsa_tmp1, &rsa_tmp3, key->n, &rsa_s) != MP_OKAY) {
324 dropbear_exit("rsa error"); 324 dropbear_exit("RSA error");
325 } 325 }
326 326
327 #else 327 #else
328 328
329 /* s = em^d mod n */ 329 /* s = em^d mod n */
330 /* rsa_tmp1 is em */ 330 /* rsa_tmp1 is em */
331 if (mp_exptmod(&rsa_tmp1, key->d, key->n, &rsa_s) != MP_OKAY) { 331 if (mp_exptmod(&rsa_tmp1, key->d, key->n, &rsa_s) != MP_OKAY) {
332 dropbear_exit("rsa error"); 332 dropbear_exit("RSA error");
333 } 333 }
334 334
335 #endif /* RSA_BLINDING */ 335 #endif /* RSA_BLINDING */
336 336
337 mp_clear_multi(&rsa_tmp1, &rsa_tmp2, &rsa_tmp3, NULL); 337 mp_clear_multi(&rsa_tmp1, &rsa_tmp2, &rsa_tmp3, NULL);
349 for (i = 0; i < nsize-ssize; i++) { 349 for (i = 0; i < nsize-ssize; i++) {
350 buf_putbyte(buf, 0x00); 350 buf_putbyte(buf, 0x00);
351 } 351 }
352 352
353 if (mp_to_unsigned_bin(&rsa_s, buf_getwriteptr(buf, ssize)) != MP_OKAY) { 353 if (mp_to_unsigned_bin(&rsa_s, buf_getwriteptr(buf, ssize)) != MP_OKAY) {
354 dropbear_exit("rsa error"); 354 dropbear_exit("RSA error");
355 } 355 }
356 buf_incrwritepos(buf, ssize); 356 buf_incrwritepos(buf, ssize);
357 mp_clear(&rsa_s); 357 mp_clear(&rsa_s);
358 358
359 #if defined(DEBUG_RSA) && defined(DEBUG_TRACE) 359 #if defined(DEBUG_RSA) && defined(DEBUG_TRACE)