mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Add AES256-GCM tests for decryption of truncated ciphertext
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user