Skip to content

Commit

Permalink
Added some code (commented out) to print details about Camellia test …
Browse files Browse the repository at this point in the history
…failure

(and ditto for SEED)

This is modeled after similar commented-out code in sober128_test(),
but slightly fancier.
  • Loading branch information
Patrick Pelletier committed Sep 26, 2011
1 parent 334fb0a commit c729021
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ciphers/camellia.c
Expand Up @@ -686,6 +686,21 @@ int camellia_test(void)
}
camellia_done(&skey);
if (XMEMCMP(tests[x].ct, buf[0], 16) || XMEMCMP(tests[x].pt, buf[1], 16)) {
#if 0
int i, j;
printf ("\n\nLTC_CAMELLIA failed for x=%d, I got:\n", x);
for (i = 0; i < 2; i++) {
const unsigned char *expected, *actual;
expected = (i ? tests[x].pt : tests[x].ct);
actual = buf[i];
printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
for (j = 0; j < 16; j++) {
const char *eq = (expected[j] == actual[j] ? "==" : "!=");
printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
}
printf ("\n");
}
#endif
return CRYPT_FAIL_TESTVECTOR;
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/ciphers/kseed.c
Expand Up @@ -346,6 +346,21 @@ int kseed_test(void)
kseed_ecb_encrypt(tests[x].pt, buf[0], &skey);
kseed_ecb_decrypt(buf[0], buf[1], &skey);
if (XMEMCMP(buf[0], tests[x].ct, 16) || XMEMCMP(buf[1], tests[x].pt, 16)) {
#if 0
int i, j;
printf ("\n\nLTC_KSEED failed for x=%d, I got:\n", x);
for (i = 0; i < 2; i++) {
const unsigned char *expected, *actual;
expected = (i ? tests[x].pt : tests[x].ct);
actual = buf[i];
printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
for (j = 0; j < 16; j++) {
const char *eq = (expected[j] == actual[j] ? "==" : "!=");
printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
}
printf ("\n");
}
#endif
return CRYPT_FAIL_TESTVECTOR;
}
}
Expand Down

0 comments on commit c729021

Please sign in to comment.