1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

More tests

This commit is contained in:
Frank Denis 2017-07-21 16:52:01 +02:00
parent cc51916072
commit b57f9668fc
3 changed files with 34 additions and 1 deletions

View File

@ -3185,6 +3185,11 @@ tv(void)
printf("Verification of test vector #%u with a truncated tag failed\n", printf("Verification of test vector #%u with a truncated tag failed\n",
(unsigned int) i); (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, if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
NULL, ciphertext, ciphertext_len, NULL, ciphertext, ciphertext_len,
ad, ad_len, nonce, key) != 0) { ad, ad_len, nonce, key) != 0) {

View File

@ -66,6 +66,10 @@ tv(void)
printf("m != m2\n"); printf("m != m2\n");
} }
memset(m2, 0, m2len); 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, if (crypto_aead_chacha20poly1305_decrypt_detached(m2, NULL,
c, MLEN, mac, c, MLEN, mac,
ad, ADLEN, ad, ADLEN,
@ -239,6 +243,10 @@ tv_ietf(void)
printf("m != m2\n"); printf("m != m2\n");
} }
memset(m2, 0, m2len); 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, if (crypto_aead_chacha20poly1305_ietf_decrypt_detached(m2, NULL,
c, MLEN, mac, c, MLEN, mac,
ad, ADLEN, ad, ADLEN,

View File

@ -5,12 +5,32 @@
#include <signal.h> #include <signal.h>
static void static void
sigabrt_handler_3(int sig) sigabrt_handler_5(int sig)
{ {
(void) sig; (void) sig;
exit(0); 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 static void
sigabrt_handler_2(int sig) sigabrt_handler_2(int sig)
{ {