From b57f9668fcf78bfbc988ec05ff43c7c8fe43f4d9 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 21 Jul 2017 16:52:01 +0200 Subject: [PATCH] More tests --- test/default/aead_aes256gcm.c | 5 +++++ test/default/aead_chacha20poly1305.c | 8 ++++++++ test/default/misuse.c | 22 +++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/default/aead_aes256gcm.c b/test/default/aead_aes256gcm.c index cc1ba3f5..94c9a3e1 100644 --- a/test/default/aead_aes256gcm.c +++ b/test/default/aead_aes256gcm.c @@ -3185,6 +3185,11 @@ tv(void) printf("Verification of test vector #%u with a truncated tag failed\n", (unsigned int) i); } + if (i == 0 && crypto_aead_aes256gcm_decrypt(NULL, NULL, + NULL, ciphertext, ciphertext_len, + ad, ad_len, nonce, key) != 0) { + printf("Verification of test vector #%u's tag failed\n", (unsigned int) i); + } if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len, NULL, ciphertext, ciphertext_len, ad, ad_len, nonce, key) != 0) { diff --git a/test/default/aead_chacha20poly1305.c b/test/default/aead_chacha20poly1305.c index 8d1b3aae..4f867579 100644 --- a/test/default/aead_chacha20poly1305.c +++ b/test/default/aead_chacha20poly1305.c @@ -66,6 +66,10 @@ tv(void) printf("m != m2\n"); } memset(m2, 0, m2len); + assert(crypto_aead_chacha20poly1305_decrypt_detached(NULL, NULL, + c, MLEN, mac, + ad, ADLEN, + nonce, firstkey) == 0); if (crypto_aead_chacha20poly1305_decrypt_detached(m2, NULL, c, MLEN, mac, ad, ADLEN, @@ -239,6 +243,10 @@ tv_ietf(void) printf("m != m2\n"); } memset(m2, 0, m2len); + assert(crypto_aead_chacha20poly1305_ietf_decrypt_detached(NULL, NULL, + c, MLEN, mac, + ad, ADLEN, + nonce, firstkey) == 0); if (crypto_aead_chacha20poly1305_ietf_decrypt_detached(m2, NULL, c, MLEN, mac, ad, ADLEN, diff --git a/test/default/misuse.c b/test/default/misuse.c index d06c8f6a..0a08cd91 100644 --- a/test/default/misuse.c +++ b/test/default/misuse.c @@ -5,12 +5,32 @@ #include static void -sigabrt_handler_3(int sig) +sigabrt_handler_5(int sig) { (void) sig; exit(0); } +static void +sigabrt_handler_4(int sig) +{ + (void) sig; + signal(SIGABRT, sigabrt_handler_5); + assert(crypto_aead_chacha20poly1305_ietf_encrypt(NULL, NULL, NULL, UINT64_MAX, + NULL, 0, NULL, NULL, NULL) == -1); + exit(1); +} + +static void +sigabrt_handler_3(int sig) +{ + (void) sig; + signal(SIGABRT, sigabrt_handler_4); + assert(crypto_aead_chacha20poly1305_encrypt(NULL, NULL, NULL, UINT64_MAX, + NULL, 0, NULL, NULL, NULL) == -1); + exit(1); +} + static void sigabrt_handler_2(int sig) {