summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/auth_enc_ccm.t8
-rw-r--r--t/auth_enc_chacha20poly1305.t8
-rw-r--r--t/auth_enc_eax.t8
-rw-r--r--t/auth_enc_gcm.t8
-rw-r--r--t/auth_enc_ocb.t8
5 files changed, 35 insertions, 5 deletions
diff --git a/t/auth_enc_ccm.t b/t/auth_enc_ccm.t
index 1f32583e..19b9902e 100644
--- a/t/auth_enc_ccm.t
+++ b/t/auth_enc_ccm.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 13;
+use Test::More tests => 15;
use Crypt::AuthEnc::CCM qw( ccm_encrypt_authenticate ccm_decrypt_verify );
@@ -42,6 +42,9 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "9485c6d5709b43431a4f05370cc22603", "ccm_encrypt_authenticate: tag");
my $pt = ccm_decrypt_verify('AES', $key, $nonce, "header-abc", $ct, $tag);
is($pt, "plain_halfplain_half", "ccm_decrypt_verify: plaintext");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = ccm_decrypt_verify('AES', $key, $nonce, "header-abc", $ct, $tag);
+ is($pt, undef, "ccm_decrypt_verify: plaintext / bad tag");
}
{
@@ -52,4 +55,7 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "9e9cba5dd4939d0d8e2687c85c5d3b89", "ccm_encrypt_authenticate: tag (no header)");
my $pt = ccm_decrypt_verify('AES', $key, $nonce, "", $ct, $tag);
is($pt, "plain_halfplain_half", "ccm_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = ccm_decrypt_verify('AES', $key, $nonce, "", $ct, $tag);
+ is($pt, undef, "ccm_decrypt_verify: plaintext (no header) / bad tag");
}
diff --git a/t/auth_enc_chacha20poly1305.t b/t/auth_enc_chacha20poly1305.t
index b2ccfe95..94b4056c 100644
--- a/t/auth_enc_chacha20poly1305.t
+++ b/t/auth_enc_chacha20poly1305.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 14;
use Crypt::AuthEnc::ChaCha20Poly1305 qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify );
@@ -44,6 +44,9 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "d081beb3c3fe560c77f6c4e0da1d0dac", "chacha20poly1305_encrypt_authenticate: tag (no header)");
my $pt = chacha20poly1305_decrypt_verify($key, "123456789012", "", $ct, $tag);
is($pt, "plain_halfplain_half", "chacha20poly1305_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = chacha20poly1305_decrypt_verify($key, "123456789012", "", $ct, $tag);
+ is($pt, undef, "chacha20poly1305_decrypt_verify: plaintext (no header) / bad tag");
}
{
@@ -52,4 +55,7 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "e6f20b492b7bf34c914c72717af6f232", "chacha20poly1305_encrypt_authenticate: tag (no header)");
my $pt = chacha20poly1305_decrypt_verify($key, "123456789012", "adata-123456789012", $ct, $tag);
is($pt, "plain_halfplain_half", "chacha20poly1305_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = chacha20poly1305_decrypt_verify($key, "123456789012", "adata-123456789012", $ct, $tag);
+ is($pt, undef, "chacha20poly1305_decrypt_verify: plaintext (no header) / bad tag");
}
diff --git a/t/auth_enc_eax.t b/t/auth_enc_eax.t
index ad9c110f..f3c5d434 100644
--- a/t/auth_enc_eax.t
+++ b/t/auth_enc_eax.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 14;
use Crypt::AuthEnc::EAX qw( eax_encrypt_authenticate eax_decrypt_verify );
@@ -49,6 +49,9 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "f83d77e5cf20979b3325266ff2fe342c", "eax_encrypt_authenticate: tag");
my $pt = eax_decrypt_verify('AES', $key, $nonce, "abc", $ct, $tag);
is($pt, "plain_halfplain_half", "eax_decrypt_verify: plaintext");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = eax_decrypt_verify('AES', $key, $nonce, "abc", $ct, $tag);
+ is($pt, undef, "eax_decrypt_verify: plaintext / bad tag");
}
{
@@ -57,4 +60,7 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "e5ad22aa2ba3b30cd50eb59593364f1b", "eax_encrypt_authenticate: tag (no header)");
my $pt = eax_decrypt_verify('AES', $key, $nonce, "", $ct, $tag);
is($pt, "plain_halfplain_half", "eax_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = eax_decrypt_verify('AES', $key, $nonce, "", $ct, $tag);
+ is($pt, undef, "eax_decrypt_verify: plaintext (no header) / bad tag");
}
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");
}
diff --git a/t/auth_enc_ocb.t b/t/auth_enc_ocb.t
index df242cdd..d42ee7fd 100644
--- a/t/auth_enc_ocb.t
+++ b/t/auth_enc_ocb.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 12;
use Crypt::AuthEnc::OCB qw( ocb_encrypt_authenticate ocb_decrypt_verify );
@@ -35,6 +35,9 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "dfdfab80aca060268c0cc467040af4f9", "ocb_encrypt_authenticate: tag (no header)");
my $pt = ocb_decrypt_verify('AES', $key, "123456789012", "", $ct, $tag);
is($pt, "plain_half_12345plain_half_12345", "ocb_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = ocb_decrypt_verify('AES', $key, "123456789012", "", $ct, $tag);
+ is($pt, undef, "ocb_decrypt_verify: plaintext (no header) / bad tag");
}
{
@@ -43,4 +46,7 @@ my $key = "12345678901234561234567890123456";
is(unpack('H*', $tag), "bd7a6a0aaf24420f97bf239ea5740a40", "ocb_encrypt_authenticate: tag (no header)");
my $pt = ocb_decrypt_verify('AES', $key, "123456789012", "adata-123456789012", $ct, $tag);
is($pt, "plain_half_12345plain_half_12345", "ocb_decrypt_verify: plaintext (no header)");
+ substr($tag, 0, 1) = pack("H2", "AA");
+ $pt = ocb_decrypt_verify('AES', $key, "123456789012", "adata-123456789012", $ct, $tag);
+ is($pt, undef, "ocb_decrypt_verify: plaintext (no header) / bad tag");
}