Commit | Line | Data |
6bc89f92 |
1 | use Test; |
2 | use strict; |
3 | use integer; |
4 | use Digest::SHA qw(hmac_sha1_hex); |
5 | |
41c686de |
6 | BEGIN { |
77d2a621 |
7 | if ($ENV{PERL_CORE}) { |
8 | chdir 't' if -d 't'; |
9 | @INC = '../lib'; |
10 | } |
41c686de |
11 | } |
12 | |
6bc89f92 |
13 | my(@vec); |
14 | |
77d2a621 |
15 | BEGIN { |
6bc89f92 |
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 | } |