From ee7c031ddf27bc6a2a4b4a78b8a183b8630e7691 Mon Sep 17 00:00:00 2001 From: Patrick Pelletier Date: Sun, 25 Sep 2011 17:39:04 -0700 Subject: [PATCH] Added some code (commented out) to print details about Camellia test failure (and ditto for SEED) This is modeled after similar commented-out code in sober128_test(), but slightly fancier. --- src/ciphers/camellia.c | 15 +++++++++++++++ src/ciphers/kseed.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/ciphers/camellia.c b/src/ciphers/camellia.c index 0651012..e7b172f 100644 --- a/src/ciphers/camellia.c +++ b/src/ciphers/camellia.c @@ -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; } } diff --git a/src/ciphers/kseed.c b/src/ciphers/kseed.c index a163c95..1065d8c 100644 --- a/src/ciphers/kseed.c +++ b/src/ciphers/kseed.c @@ -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; } }