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 | "Hi There", |
18 | "what do ya want for nothing?", |
19 | chr(0xdd) x 50, |
20 | chr(0xcd) x 50, |
21 | "Test With Truncation", |
22 | "Test Using Larger Than Block-Size Key - Hash Key First", |
23 | "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" |
24 | ); |
25 | plan tests => scalar(@vec); |
26 | } |
27 | |
28 | my @keys = ( |
29 | chr(0x0b) x 20, |
30 | "Jefe", |
31 | chr(0xaa) x 20, |
32 | "", |
33 | chr(0x0c) x 20, |
34 | chr(0xaa) x 80, |
35 | chr(0xaa) x 80 |
36 | ); |
37 | |
38 | my @hmac1rsp = ( |
39 | "b617318655057264e28bc0b6fb378c8ef146be00", |
40 | "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", |
41 | "125d7342b9ac11cd91a39af48aa17b4f63f175d3", |
42 | "4c9007f4026250c6bc8414f9bf50c86c2d7235da", |
43 | "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04", |
44 | "aa4ae5e15272d00e95705637ce8a3b55ed402112", |
45 | "e8e99d0f45237d786d6bbaa7965c7808bbff1a91" |
46 | ); |
47 | |
48 | my $i = 0x01; |
49 | $keys[3] .= chr($i++) while (length($keys[3]) < 25); |
50 | |
51 | for ($i = 0; $i < @vec; $i++) { |
52 | ok( |
53 | hmac_sha1_hex($vec[$i], $keys[$i]), |
54 | $hmac1rsp[$i] |
55 | ); |
56 | } |