Upgrade to Digest-SHA-5.43
[p5sagit/p5-mst-13.2.git] / ext / Digest / SHA / t / 5-hmac-fips198.t
1 use Test;
2 use strict;
3 use integer;
4 use Digest::SHA qw(hmac_sha1_hex);
5
6 BEGIN {
7         if ($ENV{PERL_CORE}) {
8                 chdir 't' if -d 't';
9                 @INC = '../lib';
10         }
11 }
12
13 my(@vec);
14
15 BEGIN {
16         @vec = (
17                 "Sample #1",
18                 "Sample #2",
19                 "Sample #3",
20                 "Sample #4"
21         );
22         plan tests => scalar(@vec);
23 }
24
25 my @keys = ("", "", "", "");
26
27 my $i = 0;
28 $keys[0] .= chr($i++) while (length($keys[0]) < 64);
29
30 $i = 0x30;
31 $keys[1] .= chr($i++) while (length($keys[1]) < 20);
32
33 $i = 0x50;
34 $keys[2] .= chr($i++) while (length($keys[2]) < 100);
35
36 $i = 0x70;
37 $keys[3] .= chr($i++) while (length($keys[3]) < 49);
38
39 my @hmac1rsp = (
40         "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
41         "0922d3405faa3d194f82a45830737d5cc6c75d24",
42         "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa",
43         "9ea886efe268dbecce420c7524df32e0751a2a26"
44 );
45
46 for ($i = 0; $i < @vec; $i++) {
47         ok(
48                 hmac_sha1_hex($vec[$i], $keys[$i]),
49                 $hmac1rsp[$i]
50         );
51 }