use print_hex() in rsa_test()

This commit is contained in:
Steffen Jaeckel 2017-06-08 12:32:15 +02:00
parent e45e02d635
commit ad45277745

View File

@ -274,29 +274,15 @@ int rsa_test(void)
len = mp_unsigned_bin_size(key.N); len = mp_unsigned_bin_size(key.N);
mp_to_unsigned_bin(key.N, tmp); mp_to_unsigned_bin(key.N, tmp);
fprintf(stderr, "N == \n"); print_hex("N", tmp, len);
for (cnt = 0; cnt < len; ) {
fprintf(stderr, "%02x ", tmp[cnt]);
if (!(++cnt & 15)) fprintf(stderr, "\n");
}
len = mp_unsigned_bin_size(key.p); len = mp_unsigned_bin_size(key.p);
mp_to_unsigned_bin(key.p, tmp); mp_to_unsigned_bin(key.p, tmp);
fprintf(stderr, "p == \n"); print_hex("p", tmp, len);
for (cnt = 0; cnt < len; ) {
fprintf(stderr, "%02x ", tmp[cnt]);
if (!(++cnt & 15)) fprintf(stderr, "\n");
}
len = mp_unsigned_bin_size(key.q); len = mp_unsigned_bin_size(key.q);
mp_to_unsigned_bin(key.q, tmp); mp_to_unsigned_bin(key.q, tmp);
fprintf(stderr, "\nq == \n"); print_hex("q", tmp, len);
for (cnt = 0; cnt < len; ) {
fprintf(stderr, "%02x ", tmp[cnt]);
if (!(++cnt & 15)) fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
return 1; return 1;
} }
@ -539,14 +525,8 @@ for (cnt = 0; cnt < len; ) {
/* (3) */ /* (3) */
DO(ltc_mp.rsa_me(p2, len2, p3, &len3, PK_PUBLIC, &key)); DO(ltc_mp.rsa_me(p2, len2, p3, &len3, PK_PUBLIC, &key));
/* (4) */ /* (4) */
#ifdef LTC_TEST_DBG #if defined(LTC_TEST_DBG) && LTC_TEST_DBG > 1
cnt = rsa_get_size(&key); print_hex("Original signature", p3, len3);
printf("\nBefore:");
for (cnt = 0; cnt < len3; ++cnt) {
if (cnt%32 == 0)
printf("\n%3lu:", cnt);
printf(" %02x", p3[cnt]);
}
#endif #endif
/* (4.1) */ /* (4.1) */
for (cnt = 0; cnt < len3; ++cnt) { for (cnt = 0; cnt < len3; ++cnt) {
@ -563,14 +543,8 @@ for (cnt = 0; cnt < len; ) {
for (cnt = cnt + len3-cnt2+i; cnt < len; ++cnt) { for (cnt = cnt + len3-cnt2+i; cnt < len; ++cnt) {
p3[cnt] = 0; p3[cnt] = 0;
} }
#ifdef LTC_TEST_DBG #if defined(LTC_TEST_DBG) && LTC_TEST_DBG > 1
printf("\nAfter:"); print_hex("Forged signature", p3, len3);
for (cnt = 0; cnt < len3; ++cnt) {
if (cnt%32 == 0)
printf("\n%3lu:", cnt);
printf(" %02x", p3[cnt]);
}
printf("\n");
#endif #endif
len2 = sizeof(out); len2 = sizeof(out);