Commit | Line | Data |
6bc89f92 |
1 | use Test; |
2 | use strict; |
3 | use File::Basename qw(dirname); |
4 | use File::Spec; |
5 | use Digest::SHA; |
6 | |
41c686de |
7 | BEGIN { |
77d2a621 |
8 | if ($ENV{PERL_CORE}) { |
9 | chdir 't' if -d 't'; |
10 | @INC = '../lib'; |
11 | } |
41c686de |
12 | } |
13 | |
6bc89f92 |
14 | # David Ireland's test vector - SHA-256 digest of "a" x 536870912 |
15 | |
16 | # Adapted from Julius Duque's original script (t/24-ireland.tmp) |
17 | # - modified to use state cache via dump()/load() methods |
18 | |
19 | BEGIN { plan tests => 1 } |
20 | |
cccd5831 |
21 | my $file = File::Spec->catfile(dirname($0), "ireland.tmp"); |
22 | open(my $fh, q{>}, $file); while (<DATA>) { print $fh $_ } close($fh); |
6bc89f92 |
23 | |
24 | my $data = "a" x 1000000; |
25 | my $vec = "b9045a713caed5dff3d3b783e98d1ce5778d8bc331ee4119d707072312af06a7"; |
26 | |
27 | my $ctx; |
28 | unless ($ctx = Digest::SHA->load($file)) { |
29 | $ctx = Digest::SHA->new(256); |
30 | for (1 .. 536) { $ctx->add($data) } |
31 | $ctx->add(substr($data, 0, 870910)); |
32 | $ctx->dump($file); |
33 | } |
34 | $ctx->add("aa"); |
35 | ok($ctx->hexdigest, $vec); |
36 | |
37 | unlink($file); |
38 | |
39 | __DATA__ |
40 | alg:256 |
41 | H:dd75eb45:02d4f043:06b41193:6fda751d:73064db9:787d54e1:52dc3fe0:48687dfa |
42 | block:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:61:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 |
43 | blockcnt:496 |
44 | lenhh:0 |
45 | lenhl:0 |
46 | lenlh:0 |
47 | lenll:4294967280 |