ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Spritz/t/01_spritz.t
(Generate patch)

Comparing Crypt-Spritz/t/01_spritz.t (file contents):
Revision 1.5 by root, Sat Jan 10 07:48:30 2015 UTC vs.
Revision 1.6 by root, Sat Jan 10 09:14:53 2015 UTC

1BEGIN { $| = 1; print "1..82\n"; } 1BEGIN { $| = 1; print "1..100\n"; }
2 2
3use Crypt::Spritz; 3use Crypt::Spritz;
4 4
5my $n = 0; 5my $n = 0;
6 6
37 my $mac1 = new Crypt::Spritz::MAC $a; 37 my $mac1 = new Crypt::Spritz::MAC $a;
38 $mac1->add ("schmorp"); 38 $mac1->add ("schmorp");
39 $mac1 = unpack "H*", substr $mac1->finish (13), -8; 39 $mac1 = unpack "H*", substr $mac1->finish (13), -8;
40 print $m eq $mac1 ? "" : "not ", "ok ", ++$n, " # M $a => $mac1 (= $m)\n"; 40 print $m eq $mac1 ? "" : "not ", "ok ", ++$n, " # M $a => $mac1 (= $m)\n";
41 41
42 my $ci = new Crypt::Spritz::Cipher $a;
43 my $ci1 = $ci->encrypt ($m);
44 my $ci = new Crypt::Spritz::Cipher $a;
45 $ci1 = $ci->decrypt ($ci1);
46 print $m eq $ci1 ? "" : "not ", "ok ", ++$n, " # CI1 $a => $ci1 (= $m)\n";
47
42 my $cx1 = new Crypt::Spritz::Cipher::XOR $a; 48 my $cx1 = new Crypt::Spritz::Cipher::XOR $a;
43 $cx1 = unpack "H*", $cx1->crypt ("12345678") ^ "12345678"; 49 $cx1 = unpack "H*", $cx1->crypt ("12345678") ^ "12345678";
44 print $r eq $cx1 ? "" : "not ", "ok ", ++$n, " # CX1 $a => $cx1 (= $r)\n"; 50 print $r eq $cx1 ? "" : "not ", "ok ", ++$n, " # CX1 $a => $cx1 (= $r)\n";
45 51
46 my $cx2 = "98765432"; 52 my $cx2 = "98765432";
47 Crypt::Spritz::Cipher::XOR->new ($a)->crypt_inplace ($cx2); 53 Crypt::Spritz::Cipher::XOR->new ($a)->crypt_inplace ($cx2);
48 $cx2 = unpack "H*", $cx2 ^ "98765432"; 54 $cx2 = unpack "H*", $cx2 ^ "98765432";
49 print $r eq $cx2 ? "" : "not ", "ok ", ++$n, " # CX2 $a => $cx2 (= $r)\n"; 55 print $r eq $cx2 ? "" : "not ", "ok ", ++$n, " # CX2 $a => $cx2 (= $r)\n";
56
57 my $ae = new Crypt::Spritz::AEAD $a; $ae->nonce (45); $ae->associated_data (67);
58 my $ar1 = $ae->encrypt ($m);
59 my $ae = new Crypt::Spritz::AEAD $a; $ae->nonce (45); $ae->associated_data (67);
60 $ar1 = $ae->decrypt ($ar1);
61 print $m eq $ar1 ? "" : "not ", "ok ", ++$n, " # AR1 $a => $ar1 (= $m)\n";
50 62
51 my $ae = new Crypt::Spritz::AEAD::XOR $a; 63 my $ae = new Crypt::Spritz::AEAD::XOR $a;
52 $ae->nonce (12); 64 $ae->nonce (12);
53 $ae->associated_data (34); 65 $ae->associated_data (34);
54 my $ar = unpack "H*", $ae->crypt ("A2345678") ^ "A2345678"; 66 my $ar = unpack "H*", $ae->crypt ("A2345678") ^ "A2345678";
56 $ae = unpack "H*", $ae->finish (8); 68 $ae = unpack "H*", $ae->finish (8);
57 print $em eq $ae ? "" : "not ", "ok ", ++$n, " # AE2 $a => $ae (= $em)\n"; 69 print $em eq $ae ? "" : "not ", "ok ", ++$n, " # AE2 $a => $ae (= $em)\n";
58 } 70 }
59} 71}
60 72
61print "ok 82\n"; 73print "ok 100\n";
62 74

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines