1 # Test against short bitwise vectors from Jim Gillogly and Francois Grieu
3 # http://www.chiark.greenend.org.uk/pipermail/ukcrypto/1999-February/003538.html
10 $MODULE = ($ENV{PERL_CORE} || -e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl";
11 eval "require $MODULE" || die $@;
12 $MODULE->import(qw());
16 if ($ENV{PERL_CORE}) {
24 # In the following we use the notation bitstring#n to mean a bitstring
25 # repeated n (in decimal) times, and we use | for concatenation.
26 # Therefore 110#3|1 is 1101101101.
28 # 110#148|11 : CE7387AE 577337BE 54EA94F8 2C842E8B E76BC3E1
29 # 110#149 : DE244F06 3142CB2F 4C903B7F 7660577F 9E0D8791
30 # 110#149|1 : A3D29824 27AE39C8 920CA5F4 99D6C2BD 71EBF03C
31 # 110#149|11 : 351AAB58 FF93CF12 AF7D5A58 4CFC8F7D 81023D10
33 # 110#170 : 99638692 1E480D4E 2955E727 5DF3522C E8F5AB6E
34 # 110#170|1 : BB5F4AD4 8913F51B 157EB985 A5C2034B 8243B01B
35 # 110#170|11 : 9E92C554 2237B957 BA2244E8 141FDB66 DEC730A5
36 # 110#171 : 2103E454 DA4491F4 E32DD425 A3341DC9 C2A90848
38 # 011#490 : B4B18049 DE405027 528CD9E7 4B2EC540 D4E6F06B
39 # 011#490|0 : 34C63356 B3087427 20AB9669 14EB0FC9 26E4294B
40 # 011#490|01 : 75FACE18 02B9F84F 326368AB 06E73E05 02E9EA34
41 # 011#491 : 7C2C3D62 F6AEC28D 94CDF93F 02E739E7 490698A1
44 "110",148,"11","ce7387ae577337be54ea94f82c842e8be76bc3e1",
45 "110",149,"","de244f063142cb2f4c903b7f7660577f9e0d8791",
46 "110",149,"1","a3d2982427ae39c8920ca5f499d6c2bd71ebf03c",
47 "110",149,"11","351aab58ff93cf12af7d5a584cfc8f7d81023d10",
48 "110",170,"","996386921e480d4e2955e7275df3522ce8f5ab6e",
49 "110",170,"1","bb5f4ad48913f51b157eb985a5c2034b8243b01b",
50 "110",170,"11","9e92c5542237b957ba2244e8141fdb66dec730a5",
51 "110",171,"","2103e454da4491f4e32dd425a3341dc9c2a90848",
52 "011",490,"","b4b18049de405027528cd9e74b2ec540d4e6f06b",
53 "011",490,"0","34c63356b308742720ab966914eb0fc926e4294b",
54 "011",490,"01","75face1802b9f84f326368ab06e73e0502e9ea34",
55 "011",491,"","7c2c3d62f6aec28d94cdf93f02e739e7490698a1",
58 my $numtests = scalar(@vecs) / 4;
59 print "1..$numtests\n";
62 my $sha = $MODULE->new(1);
65 my $frag = shift @vecs;
66 my $reps = shift @vecs;
67 my $tail = shift @vecs;
68 my $bitstr = ($frag x $reps) . $tail;
69 print "not " unless $sha->add_bits($bitstr)->hexdigest
71 print "ok ", $testnum++, "\n";