From ffdaf6d16bdc73b932bba2988ae7bfe0a52d0fad Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 6 May 2019 11:15:11 +0200 Subject: [PATCH] aead_xchacha20poly1305_ietf_decrypt(): add a test with a NULL message --- test/default/aead_xchacha20poly1305.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/default/aead_xchacha20poly1305.c b/test/default/aead_xchacha20poly1305.c index 9c51623a..12059b6e 100644 --- a/test/default/aead_xchacha20poly1305.c +++ b/test/default/aead_xchacha20poly1305.c @@ -20,7 +20,7 @@ tv(void) }; #undef MESSAGE #define MESSAGE "Ladies and Gentlemen of the class of '99: If I could offer you " \ -"only one tip for the future, sunscreen would be it." + "only one tip for the future, sunscreen would be it." unsigned char *m = (unsigned char *) sodium_malloc(MLEN); static const unsigned char nonce[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, @@ -64,6 +64,10 @@ tv(void) printf("detached ciphertext is bogus\n"); } + if (crypto_aead_xchacha20poly1305_ietf_decrypt(NULL, 0, NULL, c, CLEN, ad, + ADLEN, nonce, firstkey) != 0) { + printf("crypto_aead_xchacha20poly1305_ietf_decrypt() tag-only verification failed\n"); + } if (crypto_aead_xchacha20poly1305_ietf_decrypt(m2, &m2len, NULL, c, CLEN, ad, ADLEN, nonce, firstkey) != 0) { printf("crypto_aead_xchacha20poly1305_ietf_decrypt() failed\n");