Upgrade to Digest-SHA-5.43
[p5sagit/p5-mst-13.2.git] / ext / Digest / SHA / t / 5-hmac-fips198.t
CommitLineData
6bc89f92 1use Test;
2use strict;
3use integer;
4use Digest::SHA qw(hmac_sha1_hex);
5
41c686de 6BEGIN {
77d2a621 7 if ($ENV{PERL_CORE}) {
8 chdir 't' if -d 't';
9 @INC = '../lib';
10 }
41c686de 11}
12
6bc89f92 13my(@vec);
14
77d2a621 15BEGIN {
6bc89f92 16 @vec = (
17 "Sample #1",
18 "Sample #2",
19 "Sample #3",
20 "Sample #4"
21 );
22 plan tests => scalar(@vec);
23}
24
25my @keys = ("", "", "", "");
26
27my $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
39my @hmac1rsp = (
40 "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a",
41 "0922d3405faa3d194f82a45830737d5cc6c75d24",
42 "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa",
43 "9ea886efe268dbecce420c7524df32e0751a2a26"
44);
45
46for ($i = 0; $i < @vec; $i++) {
47 ok(
48 hmac_sha1_hex($vec[$i], $keys[$i]),
49 $hmac1rsp[$i]
50 );
51}