diff options
author | Rob Austein <sra@hactrn.net> | 2015-05-24 15:20:53 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-05-24 15:20:53 -0400 |
commit | b7956f3c5a660e6115cc67a593b38fbd8d8aba4f (patch) | |
tree | 46bb7b3d5fb475fb3f111a9dfed16b206cc3d2f4 /tests | |
parent | b932b1976b8c288686accf14e13cd499877408f9 (diff) |
Typing "!" when one meant "~" has interesting effects when bit masking.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-aes-key-wrap.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/test-aes-key-wrap.c b/tests/test-aes-key-wrap.c index 1af9a2f..2db1802 100644 --- a/tests/test-aes-key-wrap.c +++ b/tests/test-aes-key-wrap.c @@ -92,33 +92,41 @@ static int run_test(const uint8_t * const K, const size_t K_len, * Wrap and compare results. */ + printf("Wrapping with %lu-bit KEK...\n", (unsigned long) K_len * 8); if ((err = hal_aes_keywrap(K, K_len, Q, Q_len, c, &c_len)) != HAL_OK) { - printf("couldn't wrap with %lu-bit KEK: %s\n", + printf("Couldn't wrap with %lu-bit KEK: %s\n", (unsigned long) K_len * 8, hal_error_string(err)); ok1 = 0; } else if (C_len != c_len || memcmp(C, c, C_len) != 0) { - printf("ciphertext mismatch:\n Want: %s\n Got: %s\n", + printf("Ciphertext mismatch:\n Want: %s\n Got: %s\n", format_hex(C, C_len, h1, sizeof(h1)), format_hex(c, c_len, h2, sizeof(h2))); ok1 = 0; } + else { + printf("OK\n"); + } /* * Unwrap and compare results. */ + printf("Unwrapping with %lu-bit KEK...\n", (unsigned long) K_len * 8); if ((err = hal_aes_keyunwrap(K, K_len, C, C_len, q, &q_len)) != HAL_OK) { - printf("couldn't unwrap with %lu-bit KEK: %s\n", + printf("Couldn't unwrap with %lu-bit KEK: %s\n", (unsigned long) K_len * 8, hal_error_string(err)); ok2 = 0; } else if (Q_len != q_len || memcmp(Q, q, Q_len) != 0) { - printf("plaintext mismatch:\n Want: %s\n Got: %s\n", + printf("Plaintext mismatch:\n Want: %s\n Got: %s\n", format_hex(Q, Q_len, h1, sizeof(h1)), format_hex(q, q_len, h2, sizeof(h2))); ok2 = 0; } + else { + printf("OK\n"); + } return ok1 && ok2; } @@ -135,16 +143,10 @@ int main (int argc, char *argv[]) hal_io_set_debug(1); - printf("Testing 128-bit KEK..."); - if (run_test(K_128, sizeof(K_128), C_128, sizeof(C_128))) - printf("OK\n"); - else + if (!run_test(K_128, sizeof(K_128), C_128, sizeof(C_128))) failures++; - printf("Testing 256-bit KEK..."); - if (run_test(K_256, sizeof(K_256), C_256, sizeof(C_256))) - printf("OK\n"); - else + if (!run_test(K_256, sizeof(K_256), C_256, sizeof(C_256))) failures++; return failures; |