1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 10:05:05 -07:00

aead_xchacha20poly1305_ietf_decrypt(): add a test with a NULL message

This commit is contained in:
Frank Denis 2019-05-06 11:15:11 +02:00
parent ed4e053fb0
commit ffdaf6d16b

View File

@ -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");