From 2645422a32a5ea2e68644ae7567e0d3aef8b7d8b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 13 Sep 2014 14:51:21 -0700 Subject: [PATCH] Test crypto_aead with a short ciphertext --- test/default/aead_chacha20poly1305.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/default/aead_chacha20poly1305.c b/test/default/aead_chacha20poly1305.c index 39829c3c..4dadb832 100644 --- a/test/default/aead_chacha20poly1305.c +++ b/test/default/aead_chacha20poly1305.c @@ -91,6 +91,18 @@ int main(void) printf("m != m2 (adlen=0)\n"); } + if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, + crypto_aead_chacha20poly1305_ABYTES / 2, + NULL, 0U, + nonce, firstkey) != -1) { + printf("crypto_aead_chacha20poly1305_decrypt() worked with a short ciphertext\n"); + } + if (crypto_aead_chacha20poly1305_decrypt(m2, &m2len, NULL, c, 0U, + NULL, 0U, + nonce, firstkey) != -1) { + printf("crypto_aead_chacha20poly1305_decrypt() worked with an empty ciphertext\n"); + } + assert(crypto_aead_chacha20poly1305_keybytes() > 0U); assert(crypto_aead_chacha20poly1305_npubbytes() > 0U); assert(crypto_aead_chacha20poly1305_nsecbytes() == 0U);