Upgrade to Digest-SHA-5.43
[p5sagit/p5-mst-13.2.git] / ext / Digest / SHA / t / 7-ireland.t
CommitLineData
6bc89f92 1use Test;
2use strict;
3use File::Basename qw(dirname);
4use File::Spec;
5use Digest::SHA;
6
41c686de 7BEGIN {
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
19BEGIN { plan tests => 1 }
20
cccd5831 21my $file = File::Spec->catfile(dirname($0), "ireland.tmp");
22open(my $fh, q{>}, $file); while (<DATA>) { print $fh $_ } close($fh);
6bc89f92 23
24my $data = "a" x 1000000;
25my $vec = "b9045a713caed5dff3d3b783e98d1ce5778d8bc331ee4119d707072312af06a7";
26
27my $ctx;
28unless ($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");
35ok($ctx->hexdigest, $vec);
36
37unlink($file);
38
39__DATA__
40alg:256
41H:dd75eb45:02d4f043:06b41193:6fda751d:73064db9:787d54e1:52dc3fe0:48687dfa
42block: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
43blockcnt:496
44lenhh:0
45lenhl:0
46lenlh:0
47lenll:4294967280