Rename ext/Digest/SHA to ext/Digest-SHA
[perl.git] / ext / Digest-SHA / t / ireland.t
1 use strict;
2 use FileHandle;
3
4 my $MODULE;
5
6 BEGIN {
7         $MODULE = ($ENV{PERL_CORE} || -d "src") ? "Digest::SHA" : "Digest::SHA::PurePerl";
8         eval "require $MODULE" || die $@;
9         $MODULE->import(qw());
10 }
11
12 BEGIN {
13         if ($ENV{PERL_CORE}) {
14                 chdir 't' if -d 't';
15                 @INC = '../lib';
16         }
17 }
18
19 # David Ireland's test vector - SHA-256 digest of "a" x 536870912
20
21 # Adapted from Julius Duque's original script (t/24-ireland.tmp)
22 #       - modified to use state cache via dump()/load() methods
23
24 print "1..1\n";
25
26 my $tempfile = "ireland.tmp";
27 END { 1 while unlink $tempfile }
28
29 my $fh = FileHandle->new($tempfile, "w");
30 while (<DATA>) { print $fh $_ }  close($fh);
31
32 my $rsp = "b9045a713caed5dff3d3b783e98d1ce5778d8bc331ee4119d707072312af06a7";
33
34 my $sha;
35 if ($sha = $MODULE->load($tempfile)) {
36         $sha->add("aa");
37         print "not " unless $sha->hexdigest eq $rsp;
38         print "ok 1\n";
39 }
40 else { print "not ok 1\n" }
41
42 __DATA__
43 alg:256
44 H:dd75eb45:02d4f043:06b41193:6fda751d:73064db9:787d54e1:52dc3fe0:48687dfa
45 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
46 blockcnt:496
47 lenhh:0
48 lenhl:0
49 lenlh:0
50 lenll:4294967280