don't use print_hex() from library

This commit is contained in:
Steffen Jaeckel
2017-06-08 11:55:07 +02:00
parent fe0b72ef51
commit 4e971a8518
5 changed files with 31 additions and 120 deletions
+8 -44
View File
@@ -165,27 +165,10 @@ int ccm_test(void)
}
}
if (XMEMCMP(buf, tests[x].ct, tests[x].ptlen)) {
#if defined(LTC_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
print_hex("ct is ", buf, tests[x].ptlen);
print_hex("ct should", tests[x].ct, tests[x].ptlen);
#endif
if (compare_testvector(buf, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "CCM encrypt data", x)) {
return CRYPT_FAIL_TESTVECTOR;
}
if (tests[x].taglen != taglen) {
#if defined(LTC_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
printf("taglen %lu (is) %lu (should)\n", taglen, tests[x].taglen);
#endif
return CRYPT_FAIL_TESTVECTOR;
}
if (XMEMCMP(tag, tests[x].tag, tests[x].taglen)) {
#if defined(LTC_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
print_hex("tag is ", tag, tests[x].taglen);
print_hex("tag should", tests[x].tag, tests[x].taglen);
#endif
if (compare_testvector(tag, taglen, tests[x].tag, tests[x].taglen, "CCM encrypt tag", x)) {
return CRYPT_FAIL_TESTVECTOR;
}
@@ -220,12 +203,8 @@ int ccm_test(void)
}
}
if (XMEMCMP(buf2, tests[x].pt, tests[x].ptlen)) {
#if defined(LTC_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
print_hex("pt is ", buf2, tests[x].ptlen);
print_hex("pt should", tests[x].pt, tests[x].ptlen);
#endif
if (compare_testvector(buf2, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "CCM decrypt data", x)) {
return CRYPT_FAIL_TESTVECTOR;
}
if (y == 0) {
@@ -243,27 +222,12 @@ int ccm_test(void)
tag3, &taglen, 1 )) != CRYPT_ERROR) {
return CRYPT_FAIL_TESTVECTOR;
}
if (XMEMCMP(buf2, zero, tests[x].ptlen)) {
#if defined(LTC_CCM_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
print_hex("pt is ", buf2, tests[x].ptlen);
print_hex("pt should", zero, tests[x].ptlen);
#endif
return CRYPT_FAIL_TESTVECTOR;
if (compare_testvector(buf2, tests[x].ptlen, zero, tests[x].ptlen, "CCM decrypt wrong tag", x)) {
return CRYPT_FAIL_TESTVECTOR;
}
} else {
/* FIXME: Only check the tag if ccm_memory was not called: ccm_memory already
validates the tag. ccm_process and ccm_done should somehow do the same,
although with current setup it is impossible to keep the plaintext hidden
if the tag is incorrect.
*/
if (XMEMCMP(tag2, tests[x].tag, tests[x].taglen)) {
#if defined(LTC_TEST_DBG)
printf("\n%d: x=%lu y=%lu\n", __LINE__, x, y);
print_hex("tag is ", tag2, tests[x].taglen);
print_hex("tag should", tests[x].tag, tests[x].taglen);
#endif
return CRYPT_FAIL_TESTVECTOR;
if (compare_testvector(tag2, taglen, tests[x].tag, tests[x].taglen, "CCM decrypt tag", x)) {
return CRYPT_FAIL_TESTVECTOR;
}
}