Commit | Line | Data |
---|---|---|
747da336 RGS |
1 | use strict; |
2 | use FileHandle; | |
3 | ||
4 | my $MODULE; | |
5 | ||
6 | BEGIN { | |
7 | $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; | |
8 | eval "require $MODULE" || die $@; | |
9 | $MODULE->import(qw(sha384_hex sha512_hex)); | |
10 | } | |
11 | ||
12 | BEGIN { | |
13 | if ($ENV{PERL_CORE}) { | |
14 | chdir 't' if -d 't'; | |
15 | @INC = '../lib'; | |
16 | } | |
17 | } | |
18 | ||
19 | my @sharsp = ( | |
20 | "34aa973cd4c4daa4f61eeb2bdbad27316534016f", | |
21 | "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0", | |
22 | "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985", | |
23 | "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" | |
24 | ); | |
25 | ||
26 | my $numtests = scalar @sharsp; | |
27 | print "1..$numtests\n"; | |
28 | ||
29 | my @tempfiles; | |
30 | END { 1 while unlink @tempfiles } | |
31 | ||
32 | my @statefiles = ("dl001.tmp", "dl256.tmp", "dl384.tmp", "dl512.tmp"); | |
33 | for (@statefiles) { | |
34 | push @tempfiles, $_; | |
35 | my $fh = FileHandle->new($_, "w"); | |
36 | for (1 .. 8) { my $line = <DATA>; print $fh $line } | |
37 | $fh->close; | |
38 | } | |
39 | my $tmpfile = "dumpload.tmp"; | |
40 | push @tempfiles, $tmpfile; | |
41 | ||
42 | my @alg = (1, 256, 384, 512); | |
43 | my $data = "a" x 990000; | |
44 | ||
45 | my $testnum = 1; | |
46 | while (@sharsp) { | |
47 | my $skip = 0; | |
48 | my $alg = shift @alg; | |
49 | my $rsp = shift @sharsp; | |
50 | my $file = shift @statefiles; push(@statefiles, $file); | |
51 | if ($alg == 384) { $skip = sha384_hex("") ? 0 : 1 } | |
52 | if ($alg == 512) { $skip = sha512_hex("") ? 0 : 1 } | |
53 | if ($skip) { | |
54 | print "ok ", $testnum++, " # skip: no 64 bit\n"; | |
55 | next; | |
56 | } | |
57 | my $digest; | |
58 | my $state; | |
59 | unless ($state = $MODULE->load($file)) { | |
60 | print "not ok ", $testnum++, "\n"; | |
61 | next; | |
62 | } | |
63 | $state->add_bits($data, 79984)->dump($tmpfile); | |
64 | $state->load($tmpfile)->add_bits($data, 16); | |
65 | $digest = $state->hexdigest; | |
66 | print "not " unless $digest eq $rsp; | |
67 | print "ok ", $testnum++, "\n"; | |
68 | } | |
69 | ||
70 | __DATA__ | |
71 | alg:1 | |
72 | H:9d6f7d2f:65e21307:c6f41af6:7c7fd3a9:8dec6058:00000000:00000000:00000000 | |
73 | 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:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 | |
74 | blockcnt:384 | |
75 | lenhh:0 | |
76 | lenhl:0 | |
77 | lenlh:0 | |
78 | lenll:7920000 | |
79 | alg:256 | |
80 | H:2d6c0def:4244ade7:fc8c121c:108f4493:ec3fbec2:91425a6e:b8d30d2a:9db24273 | |
81 | 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:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 | |
82 | blockcnt:384 | |
83 | lenhh:0 | |
84 | lenhl:0 | |
85 | lenlh:0 | |
86 | lenll:7920000 | |
87 | alg:384 | |
88 | H:598147f4583a61f7:8d194a4d7c9008cb:39725c96557d600f:d7f2079ce8251f19:bd735d446f9a3c7c:234de90b9060898d:a5b481b9d635d190:81c6e74ee4556125 | |
89 | 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: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:00:00:00:00:00:00:00:00:00:00:00:00:00:00 | |
90 | blockcnt:384 | |
91 | lenhh:0 | |
92 | lenhl:0 | |
93 | lenlh:0 | |
94 | lenll:7920000 | |
95 | alg:512 | |
96 | H:0442fe29a02b8c30:13553e6dbedc2aa0:8f891a0cb2ac3107:6fa1762b40ac04dd:dcbf420d729eea79:34703e9672dcf145:7bf9aaa14d400433:2aa65f044825466d | |
97 | 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: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:00:00:00:00:00:00:00:00:00:00:00:00:00:00 | |
98 | blockcnt:384 | |
99 | lenhh:0 | |
100 | lenhl:0 | |
101 | lenlh:0 | |
102 | lenll:7920000 |