Commit | Line | Data |
6bc89f92 |
1 | use Test; |
2 | use strict; |
3 | use integer; |
4 | use Digest::SHA qw(sha384_hex sha512_hex); |
5 | use File::Basename qw(dirname); |
6 | use File::Spec; |
7 | |
41c686de |
8 | BEGIN { |
77d2a621 |
9 | if ($ENV{PERL_CORE}) { |
10 | chdir 't' if -d 't'; |
11 | @INC = '../lib'; |
12 | } |
41c686de |
13 | } |
14 | |
6bc89f92 |
15 | my(@sharsp); |
16 | |
77d2a621 |
17 | BEGIN { |
6bc89f92 |
18 | @sharsp = ( |
19 | "34aa973cd4c4daa4f61eeb2bdbad27316534016f", |
20 | "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0", |
21 | "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985", |
22 | "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" |
23 | ); |
24 | plan tests => scalar(@sharsp); |
25 | } |
26 | |
27 | my @ext = (1, 256, 384, 512); |
28 | my $data = "a" x 990000; |
29 | my $skip; |
cccd5831 |
30 | my $tmpfile = File::Spec->catfile(dirname($0), "dumpload.tmp"); |
6bc89f92 |
31 | |
32 | for (my $i = 0; $i < @sharsp; $i++) { |
33 | $skip = 0; |
34 | if ($ext[$i] == 384) { |
35 | $skip = sha384_hex("") ? 0 : 1; |
36 | } |
37 | if ($ext[$i] == 512) { |
38 | $skip = sha512_hex("") ? 0 : 1; |
39 | } |
40 | my $digest; |
41 | unless ($skip) { |
42 | my $state; |
cccd5831 |
43 | my $file = File::Spec->catfile(dirname($0), |
77d2a621 |
44 | "state", "state.$ext[$i]"); |
6bc89f92 |
45 | unless ($state = Digest::SHA->load($file)) { |
46 | $state = Digest::SHA->new($ext[$i]); |
47 | $state->add($data); |
48 | $state->dump($file); |
49 | $state->load($file); |
50 | } |
51 | $state->add_bits($data, 79984)->dump($tmpfile); |
52 | $state->load($tmpfile)->add_bits($data, 16); |
53 | unlink($tmpfile); |
54 | $digest = $state->hexdigest; |
55 | } |
56 | skip($skip, $digest, $sharsp[$i]); |
57 | } |