diff options
author | Karel Miko <karel.miko@gmail.com> | 2018-10-26 09:55:27 +0200 |
---|---|---|
committer | Karel Miko <karel.miko@gmail.com> | 2018-10-26 09:55:27 +0200 |
commit | f244a0530d4493d1f8ccf2b3b268d48fedf2e522 (patch) | |
tree | 06095d6c1ff256a78838ddce3de91d505538a730 /t/auth_enc_gcm.t | |
parent | 08be313a7b9c04b5ff64b10f9dce470db70a66a6 (diff) |
add encauth tests with invalid tag
Diffstat (limited to 't/auth_enc_gcm.t')
-rw-r--r-- | t/auth_enc_gcm.t | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/t/auth_enc_gcm.t b/t/auth_enc_gcm.t index 1ff09fee..36b9b5a0 100644 --- a/t/auth_enc_gcm.t +++ b/t/auth_enc_gcm.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 14; use Crypt::AuthEnc::GCM qw( gcm_encrypt_authenticate gcm_decrypt_verify ); @@ -47,6 +47,9 @@ my $key = "12345678901234561234567890123456"; is(unpack('H*', $tag), "1685ba0eda059ace4aab6539980c30c0", "gcm_encrypt_authenticate: tag (no header)"); my $pt = gcm_decrypt_verify('AES', $key, "123456789012", "", $ct, $tag); is($pt, "plain_halfplain_half", "gcm_decrypt_verify: plaintext (no header)"); + substr($tag, 0, 1) = pack("H2", "AA"); + $pt = gcm_decrypt_verify('AES', $key, "123456789012", "", $ct, $tag); + is($pt, undef, "gcm_decrypt_verify: plaintext (no header) / bad tag"); } { @@ -55,4 +58,7 @@ my $key = "12345678901234561234567890123456"; is(unpack('H*', $tag), "d225e849d4d076cf9e85d5303450e793", "gcm_encrypt_authenticate: tag (no header)"); my $pt = gcm_decrypt_verify('AES', $key, "123456789012", "adata-123456789012", $ct, $tag); is($pt, "plain_halfplain_half", "gcm_decrypt_verify: plaintext (no header)"); + substr($tag, 0, 1) = pack("H2", "AA"); + $pt = gcm_decrypt_verify('AES', $key, "123456789012", "adata-123456789012", $ct, $tag); + is($pt, undef, "gcm_decrypt_verify: plaintext (no header) / bad tag"); } |