summaryrefslogtreecommitdiff
path: root/t/cipher_xtea_test_vectors_bc.t
diff options
context:
space:
mode:
Diffstat (limited to 't/cipher_xtea_test_vectors_bc.t')
-rw-r--r--t/cipher_xtea_test_vectors_bc.t28
1 files changed, 28 insertions, 0 deletions
diff --git a/t/cipher_xtea_test_vectors_bc.t b/t/cipher_xtea_test_vectors_bc.t
new file mode 100644
index 00000000..4a4dbb87
--- /dev/null
+++ b/t/cipher_xtea_test_vectors_bc.t
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+use Crypt::Cipher::XTEA;
+
+my $line = 1;
+while (my $l = <DATA>) {
+ chomp($l);
+ $l =~ s/[\s\t]+/ /g;
+ my $d = {};
+ for my $pair (split / /, $l) {
+ my ($k, $v) = split /:/, $pair;
+ $d->{$k} = $v;
+ }
+
+ my $c = Crypt::Cipher::XTEA->new(pack('H*',$d->{key}));
+ my $result = pack('H*', $d->{pt});
+ $result = $c->encrypt($result) for(1..$d->{iter});
+ is(unpack('H*', $result), lc($d->{ct}), "line=$line");
+ $line++;
+}
+
+__DATA__
+iter:1 key:00000000000000000000000000000000 pt:0000000000000000 ct:dee9d4d8f7131ed9
+iter:1 key:00000000000000000000000000000000 pt:0102030405060708 ct:065c1b8975c6a816
+iter:1 key:0123456712345678234567893456789A pt:0000000000000000 ct:1ff9a0261ac64264
+iter:1 key:0123456712345678234567893456789A pt:0102030405060708 ct:8c67155b2ef91ead