Add AES256-GCM tests for decryption of truncated ciphertext

This commit is contained in:
Frank Denis
2015-10-30 19:47:47 +01:00
parent a56274b9ee
commit a1e4d3df3f
+14
View File
@@ -3145,6 +3145,20 @@ tv(void)
sodium_free(hex);
}
decrypted = (unsigned char *) sodium_malloc(message_len);
if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
NULL, ciphertext,
randombytes_uniform(ciphertext_len),
ad, ad_len, nonce, key) != -1) {
printf("Verification of test vector #%u after truncation succeeded\n",
(unsigned int) i);
}
if (crypto_aead_aes256gcm_decrypt(decrypted, &found_message_len,
NULL, ciphertext,
randombytes_uniform(crypto_aead_aes256gcm_ABYTES),
ad, ad_len, nonce, key) != -1) {
printf("Verification of test vector #%u with a truncated 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) {