This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix typos (spelling errors) in cpan/Params-Check/*.
[perl5.git] / cpan / Digest-SHA / t / rfc2202.t
1 use strict;
2
3 my $MODULE;
4
5 BEGIN {
6         $MODULE = (-d "src") ? "Digest::SHA" : "Digest::SHA::PurePerl";
7         eval "require $MODULE" || die $@;
8         $MODULE->import(qw(hmac_sha1_hex));
9 }
10
11 BEGIN {
12         if ($ENV{PERL_CORE}) {
13                 chdir 't' if -d 't';
14                 @INC = '../lib';
15         }
16 }
17
18 my @data = map { eval } <DATA>;
19
20 my $numtests = scalar @data;
21 print "1..$numtests\n";
22
23 my @keys = (
24         chr(0x0b) x 20,
25         "Jefe",
26         chr(0xaa) x 20,
27         join("", map { chr } (1 .. 25)),
28         chr(0x0c) x 20,
29         chr(0xaa) x 80,
30         chr(0xaa) x 80
31 );
32
33 my @out = (
34         "b617318655057264e28bc0b6fb378c8ef146be00",
35         "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79",
36         "125d7342b9ac11cd91a39af48aa17b4f63f175d3",
37         "4c9007f4026250c6bc8414f9bf50c86c2d7235da",
38         "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04",
39         "aa4ae5e15272d00e95705637ce8a3b55ed402112",
40         "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
41 );
42
43 my $testnum = 1;
44 while (@data) {
45         print "not " unless hmac_sha1_hex(shift @data, shift @keys)
46                 eq shift @out;
47         print "ok ", $testnum++, "\n";
48 }
49
50 __DATA__
51 "Hi There"
52 "what do ya want for nothing?"
53 chr(0xdd) x 50
54 chr(0xcd) x 50
55 "Test With Truncation"
56 "Test Using Larger Than Block-Size Key - Hash Key First"
57 "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"