From: Rafael Garcia-Suarez Date: Tue, 10 Jul 2007 14:08:35 +0000 (+0000) Subject: Upgrade to Digest::SHA 5.45. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=747da336ec54bcc683913da95a63d1d823f064a8;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Digest::SHA 5.45. p4raw-id: //depot/perl@31578 --- diff --git a/MANIFEST b/MANIFEST index 4477a78..e7b7c0a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -384,41 +384,26 @@ ext/Digest/SHA/src/sha64bit.h Digest::SHA extension ext/Digest/SHA/src/sha.c Digest::SHA extension ext/Digest/SHA/src/sha.h Digest::SHA extension ext/Digest/SHA/src/shaxtra.c Digest::SHA extension -ext/Digest/SHA/t/1-exist.t See if Digest::SHA works -ext/Digest/SHA/t/1-hello-world.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-1.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-224.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-256.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-384.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-512.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-base64.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-sha-oo.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-vectors-bit.t See if Digest::SHA works -ext/Digest/SHA/t/2-nist-vectors-byte.t See if Digest::SHA works -ext/Digest/SHA/t/3-gillogly-easy.t See if Digest::SHA works -ext/Digest/SHA/t/3-gillogly-hard.t See if Digest::SHA works -ext/Digest/SHA/t/4-bitstr-increasing.t See if Digest::SHA works -ext/Digest/SHA/t/4-bitstr-large.t See if Digest::SHA works -ext/Digest/SHA/t/4-bitstr-random.t See if Digest::SHA works -ext/Digest/SHA/t/5-hmac-fips198.t See if Digest::SHA works -ext/Digest/SHA/t/5-hmac-rfc2202.t See if Digest::SHA works -ext/Digest/SHA/t/5-hmac-sha-256.t See if Digest::SHA works -ext/Digest/SHA/t/5-hmac-woodbury.t See if Digest::SHA works -ext/Digest/SHA/t/6-dump-load.t See if Digest::SHA works -ext/Digest/SHA/t/7-ireland.t See if Digest::SHA works -ext/Digest/SHA/t/gillogly/state.011 See if Digest::SHA works -ext/Digest/SHA/t/gillogly/state.110 See if Digest::SHA works -ext/Digest/SHA/t/nist/bit-hashes.sha1 See if Digest::SHA works -ext/Digest/SHA/t/nist/bit-messages.sha1 See if Digest::SHA works -ext/Digest/SHA/t/nist/byte-hashes.sha1 See if Digest::SHA works -ext/Digest/SHA/t/nist/byte-messages.sha1 See if Digest::SHA works -ext/Digest/SHA/t/nist/COPYRIGHT See if Digest::SHA works -ext/Digest/SHA/t/nist/Readme.txt See if Digest::SHA works -ext/Digest/SHA/t/state/state.1 See if Digest::SHA works -ext/Digest/SHA/t/state/state.256 See if Digest::SHA works -ext/Digest/SHA/t/state/state.384 See if Digest::SHA works -ext/Digest/SHA/t/state/state.512 See if Digest::SHA works -ext/Digest/SHA/typemap See if Digest::SHA works +ext/Digest/SHA/t/allfcns.t See if Digest::SHA works +ext/Digest/SHA/t/base64.t See if Digest::SHA works +ext/Digest/SHA/t/bitbuf.t See if Digest::SHA works +ext/Digest/SHA/t/dumpload.t See if Digest::SHA works +ext/Digest/SHA/t/fips198.t See if Digest::SHA works +ext/Digest/SHA/t/gg.t See if Digest::SHA works +ext/Digest/SHA/t/gglong.t See if Digest::SHA works +ext/Digest/SHA/t/hmacsha.t See if Digest::SHA works +ext/Digest/SHA/t/ireland.t See if Digest::SHA works +ext/Digest/SHA/t/methods.t See if Digest::SHA works +ext/Digest/SHA/t/nistbit.t See if Digest::SHA works +ext/Digest/SHA/t/nistbyte.t See if Digest::SHA works +ext/Digest/SHA/t/rfc2202.t See if Digest::SHA works +ext/Digest/SHA/t/sha1.t See if Digest::SHA works +ext/Digest/SHA/t/sha224.t See if Digest::SHA works +ext/Digest/SHA/t/sha256.t See if Digest::SHA works +ext/Digest/SHA/t/sha384.t See if Digest::SHA works +ext/Digest/SHA/t/sha512.t See if Digest::SHA works +ext/Digest/SHA/t/woodbury.t See if Digest::SHA works +ext/Digest/SHA/typemap Typemap for Digest::SHA ext/DynaLoader/dl_aix.xs AIX implementation ext/DynaLoader/dl_beos.xs BeOS implementation ext/DynaLoader/dl_dld.xs GNU dld style implementation diff --git a/ext/Digest/SHA/Changes b/ext/Digest/SHA/Changes index c630084..dff2302 100644 --- a/ext/Digest/SHA/Changes +++ b/ext/Digest/SHA/Changes @@ -1,5 +1,12 @@ Revision history for Perl extension Digest::SHA. +5.45 Tue Jun 26 02:36:00 MST 2007 + - extended portability to earlier Perls + -- works on Perl 5.003 and later + -- thanks to Jim Doble for testing on legacy platforms + - updated META.yml to conform to current META spec (1.3) + - minor documentation fixes + 5.44 Sat Oct 14 00:42:44 MST 2006 - removed SIGNATURE file from distribution -- spurious errors from CPANPLUS can break build diff --git a/ext/Digest/SHA/README b/ext/Digest/SHA/README index 050964b..862228b 100644 --- a/ext/Digest/SHA/README +++ b/ext/Digest/SHA/README @@ -1,4 +1,4 @@ -Digest::SHA version 5.44 +Digest::SHA version 5.45 ======================== Digest::SHA is a complete implementation of the NIST Secure Hash @@ -34,7 +34,7 @@ DEPENDENCIES COPYRIGHT AND LICENSE -Copyright (C) 2003-2006 Mark Shelor +Copyright (C) 2003-2007 Mark Shelor This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/ext/Digest/SHA/SHA.pm b/ext/Digest/SHA/SHA.pm index c2049b7..7df8b0b 100644 --- a/ext/Digest/SHA/SHA.pm +++ b/ext/Digest/SHA/SHA.pm @@ -1,17 +1,17 @@ package Digest::SHA; -require 5.006000; +require 5.003000; use strict; -use warnings; use integer; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -our $VERSION = '5.44'; +$VERSION = '5.45'; require Exporter; -our @ISA = qw(Exporter); - -our @EXPORT_OK = qw( +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +@EXPORT_OK = qw( hmac_sha1 hmac_sha1_base64 hmac_sha1_hex hmac_sha224 hmac_sha224_base64 hmac_sha224_hex hmac_sha256 hmac_sha256_base64 hmac_sha256_hex @@ -37,11 +37,6 @@ if ($@) { *b64digest = \&B64digest; } -require XSLoader; -XSLoader::load('Digest::SHA', $VERSION); - -# Preloaded methods go here. - # The following routines aren't time-critical, so they can be left in Perl sub new { @@ -118,32 +113,32 @@ sub Addfile { my ($binary, $portable) = map { $_ eq $mode } ("b", "p"); my $text = -T $file; - open(my $fh, "<$file") ## no critic - or _bail("Open failed"); - binmode($fh) if $binary || $portable; + local *FH; + open(FH, "<$file") or _bail("Open failed"); + binmode(FH) if $binary || $portable; unless ($portable && $text) { - $self->_addfile($fh); - close($fh); + $self->_addfile(*FH); + close(FH); return($self); } my ($n1, $n2); my ($buf1, $buf2) = ("", ""); - while (($n1 = read($fh, $buf1, 4096))) { + while (($n1 = read(FH, $buf1, 4096))) { while (substr($buf1, -1) eq "\015") { - $n2 = read($fh, $buf2, 4096); + $n2 = read(FH, $buf2, 4096); _bail("Read failed") unless defined $n2; last unless $n2; $buf1 .= $buf2; } $buf1 =~ s/\015?\015\012/\012/g; # DOS/Windows - $buf1 =~ s/\015/\012/g; # Apple/MacOS 9 + $buf1 =~ s/\015/\012/g; # early MacOS $self->add($buf1); } _bail("Read failed") unless defined $n1; - close($fh); + close(FH); $self; } @@ -170,6 +165,8 @@ sub load { return($self); } +Digest::SHA->bootstrap($VERSION); + 1; __END__ @@ -177,7 +174,7 @@ __END__ Digest::SHA - Perl extension for SHA-1/224/256/384/512 -=head1 SYNOPSIS (SHA) +=head1 SYNOPSIS In programs: @@ -404,7 +401,7 @@ its SHA-1/224/256/384/512 digest encoded as a Base64 string. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of -CPAN Digest modules. See L for details. +CPAN Digest modules. See L for details. =back @@ -558,7 +555,7 @@ system. Otherwise, a functionally equivalent substitute is used. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of -CPAN Digest modules. See L for details. +CPAN Digest modules. See L for details. =back @@ -614,7 +611,7 @@ in the list. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of -CPAN Digest modules. See L for details. +CPAN Digest modules. See L for details. =back @@ -640,6 +637,7 @@ The author is particularly grateful to Gisle Aas Chris Carey + Jim Doble Julius Duque Jeffrey Friedl Robert Gilmour @@ -657,7 +655,7 @@ for their valuable comments and suggestions. =head1 COPYRIGHT AND LICENSE -Copyright (C) 2003-2006 Mark Shelor +Copyright (C) 2003-2007 Mark Shelor This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/ext/Digest/SHA/SHA.xs b/ext/Digest/SHA/SHA.xs index c045da5..af0d666 100644 --- a/ext/Digest/SHA/SHA.xs +++ b/ext/Digest/SHA/SHA.xs @@ -15,6 +15,10 @@ PROTOTYPES: ENABLE #include #include +#ifndef INT2PTR +#define INT2PTR(p, i) (p) (i) +#endif + int shaclose(s) SHA * s diff --git a/ext/Digest/SHA/bin/shasum b/ext/Digest/SHA/bin/shasum index dc30a9e..f81b856 100755 --- a/ext/Digest/SHA/bin/shasum +++ b/ext/Digest/SHA/bin/shasum @@ -2,10 +2,10 @@ # shasum: filter for computing SHA digests (analogous to sha1sum) # - # Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved + # Copyright (C) 2003-2007 Mark Shelor, All Rights Reserved # - # Version: 5.44 - # Sat Oct 14 00:42:44 MST 2006 + # Version: 5.45 + # Tue Jun 26 02:36:00 MST 2007 =head1 NAME @@ -38,9 +38,30 @@ shasum - Print or Check SHA Checksums is to print a line with checksum, a character indicating type (`*' for binary, `?' for portable, ` ' for text), and name for each FILE. +=head1 DESCRIPTION + +The I script provides the easiest and most convenient way to +compute SHA message digests. Rather than writing a program, the user +simply feeds data to the script via the command line, and waits for +the results to be printed on standard output. Data can be fed to +I through files, standard input, or both. + +The following command shows how easy it is to compute digests for typical +inputs such as the NIST test vector "abc": + + perl -e "print qw(abc)" | shasum + +Or, if you want to use SHA-256 instead of the default SHA-1, simply say: + + perl -e "print qw(abc)" | shasum -a 256 + +Since I uses the same interface employed by the familiar +I program (and its somewhat outmoded anscestor I), +you can install this script as a convenient drop-in replacement. + =head1 AUTHOR -Copyright (c) 2003-2006 Mark Shelor . +Copyright (c) 2003-2007 Mark Shelor . =head1 SEE ALSO @@ -50,9 +71,10 @@ L. =cut use strict; +use FileHandle; use Getopt::Long; -my $VERSION = "5.44"; +my $VERSION = "5.45"; # Try to use Digest::SHA, since it's faster. If not installed, @@ -62,10 +84,10 @@ my $MOD_PREFER = "Digest::SHA"; my $MOD_SECOND = "Digest::SHA::PurePerl"; my $module = $MOD_PREFER; -eval "require $module"; ## no critic +eval "require $module"; if ($@) { $module = $MOD_SECOND; - eval "require $module"; ## no critic + eval "require $module"; die "Unable to find $MOD_PREFER or $MOD_SECOND\n" if $@; } @@ -118,7 +140,7 @@ END_OF_USAGE my ($alg, $binary, $check, $text, $status, $warn, $help, $version); my ($portable); -Getopt::Long::Configure ("bundling"); +eval { Getopt::Long::Configure ("bundling") }; GetOptions( 'b|binary' => \$binary, 'c|check' => \$check, 't|text' => \$text, 'a|algorithm=i' => \$alg, @@ -198,10 +220,10 @@ if ($check) { my $checkfile = shift(@ARGV); my ($err, $read_errs, $match_errs) = (0, 0, 0); my ($num_files, $num_checksums) = (0, 0); - my ($fh, $sum, $fname, $rsp); + my ($fh, $sum, $fname, $rsp, $digest); die "shasum: $checkfile: $!\n" - unless open($fh, "<$checkfile"); ## no critic + unless $fh = FileHandle->new($checkfile, "r"); while (<$fh>) { s/\s+$//; ($sum, $modesym, $fname) = /^(\S+) (.)(.*)$/; @@ -213,7 +235,7 @@ if ($check) { next; } $rsp = "$fname: "; $num_files++; - unless (my $digest = sumfile($fname)) { + unless ($digest = sumfile($fname)) { $rsp .= "FAILED open or read\n"; $err = 1; $read_errs++; } @@ -224,7 +246,7 @@ if ($check) { } print $rsp unless $status; } - close($fh); + $fh->close; unless ($status) { warn("shasum: WARNING: $read_errs of $num_files listed " . "files could not be read\n") if $read_errs; @@ -237,8 +259,10 @@ if ($check) { # Compute and display SHA checksums of requested files -for my $file (@ARGV) { - if (my $digest = sumfile($file)) { +my($file, $digest); + +for $file (@ARGV) { + if ($digest = sumfile($file)) { print "$digest $modesym", "$file\n"; } } diff --git a/ext/Digest/SHA/src/hmac.c b/ext/Digest/SHA/src/hmac.c index bb3bf24..9ecfc38 100644 --- a/ext/Digest/SHA/src/hmac.c +++ b/ext/Digest/SHA/src/hmac.c @@ -3,10 +3,10 @@ * * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code * - * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2007 Mark Shelor, All Rights Reserved * - * Version: 5.44 - * Sat Oct 14 00:42:44 MST 2006 + * Version: 5.45 + * Tue Jun 26 02:36:00 MST 2007 * */ @@ -95,7 +95,9 @@ char *hmacbase64(HMAC *h) int hmacclose(HMAC *h) { shaclose(h->osha); - memset(h, 0, sizeof(HMAC)); - SHA_free(h); + if (h != NULL) { + memset(h, 0, sizeof(HMAC)); + SHA_free(h); + } return(0); } diff --git a/ext/Digest/SHA/src/hmac.h b/ext/Digest/SHA/src/hmac.h index 1131358..88b2af0 100644 --- a/ext/Digest/SHA/src/hmac.h +++ b/ext/Digest/SHA/src/hmac.h @@ -3,10 +3,10 @@ * * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code * - * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2007 Mark Shelor, All Rights Reserved * - * Version: 5.44 - * Sat Oct 14 00:42:44 MST 2006 + * Version: 5.45 + * Tue Jun 26 02:36:00 MST 2007 * */ diff --git a/ext/Digest/SHA/src/hmacxtra.c b/ext/Digest/SHA/src/hmacxtra.c index 35a36ed..041a291 100644 --- a/ext/Digest/SHA/src/hmacxtra.c +++ b/ext/Digest/SHA/src/hmacxtra.c @@ -19,11 +19,11 @@ unsigned int keylen; hmacwrite(bitstr, bitcnt, h); hmacfinish(h); if (fmt == SHA_FMT_RAW) - memcpy(digest, hmacdigest(h), h->osha->digestlen); + memcpy(digest, hmacdigest(h), h->osha->digestlen); else if (fmt == SHA_FMT_HEX) - strcpy((char *) digest, hmachex(h)); + strcpy((char *) digest, hmachex(h)); else if (fmt == SHA_FMT_BASE64) - strcpy((char *) digest, hmacbase64(h)); + strcpy((char *) digest, hmacbase64(h)); else ret = NULL; hmacclose(h); diff --git a/ext/Digest/SHA/src/sha.c b/ext/Digest/SHA/src/sha.c index d6b5302..d996323 100644 --- a/ext/Digest/SHA/src/sha.c +++ b/ext/Digest/SHA/src/sha.c @@ -3,10 +3,10 @@ * * Ref: NIST FIPS PUB 180-2 Secure Hash Standard * - * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2007 Mark Shelor, All Rights Reserved * - * Version: 5.44 - * Sat Oct 14 00:42:44 MST 2006 + * Version: 5.45 + * Tue Jun 26 02:36:00 MST 2007 * */ @@ -425,7 +425,7 @@ char *shahex(SHA *s) } /* map: translation map for Base 64 encoding */ -static char map[] = +static char map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* encbase64: encodes input (0 to 3 bytes) into Base 64 */ diff --git a/ext/Digest/SHA/src/sha.h b/ext/Digest/SHA/src/sha.h index 1f5cca0..ca04350 100644 --- a/ext/Digest/SHA/src/sha.h +++ b/ext/Digest/SHA/src/sha.h @@ -3,10 +3,10 @@ * * Ref: NIST FIPS PUB 180-2 Secure Hash Standard * - * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2007 Mark Shelor, All Rights Reserved * - * Version: 5.44 - * Sat Oct 14 00:42:44 MST 2006 + * Version: 5.45 + * Tue Jun 26 02:36:00 MST 2007 * */ diff --git a/ext/Digest/SHA/t/1-exist.t b/ext/Digest/SHA/t/1-exist.t deleted file mode 100644 index 511fc69..0000000 --- a/ext/Digest/SHA/t/1-exist.t +++ /dev/null @@ -1,25 +0,0 @@ -use Test; -use strict; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -BEGIN { plan tests => 1 } - -use Digest::SHA qw( - hmac_sha1 hmac_sha1_base64 hmac_sha1_hex - hmac_sha224 hmac_sha224_base64 hmac_sha224_hex - hmac_sha256 hmac_sha256_base64 hmac_sha256_hex - hmac_sha384 hmac_sha384_base64 hmac_sha384_hex - hmac_sha512 hmac_sha512_base64 hmac_sha512_hex - sha1 sha1_base64 sha1_hex - sha224 sha224_base64 sha224_hex - sha256 sha256_base64 sha256_hex - sha384 sha384_base64 sha384_hex - sha512 sha512_base64 sha512_hex); - -ok(1); diff --git a/ext/Digest/SHA/t/1-hello-world.t b/ext/Digest/SHA/t/1-hello-world.t deleted file mode 100644 index 46aeaf0..0000000 --- a/ext/Digest/SHA/t/1-hello-world.t +++ /dev/null @@ -1,27 +0,0 @@ -use Test; -use Digest::SHA qw(sha1); -use strict; -use integer; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, @rsp); - -BEGIN { - - @vec = ( "hello world" ); - - @rsp = ( pack("H*", "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed") ); - - plan tests => scalar(@vec); - -} - -for (my $i = 0; $i < @vec; $i++) { - ok(sha1($vec[$i]), $rsp[$i]); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-1.t b/ext/Digest/SHA/t/2-nist-sha-1.t deleted file mode 100644 index 5a5c3c1..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-1.t +++ /dev/null @@ -1,33 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha1_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, @rsp); - -BEGIN { - @vec = ( -"abc", -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", -"a" x 1000000 - ); - - @rsp = ( -"a9993e364706816aba3e25717850c26c9cd0d89d", -"84983e441c3bd26ebaae4aa1f95129e5e54670f1", -"34aa973cd4c4daa4f61eeb2bdbad27316534016f" - ); - - plan tests => scalar(@vec); -} - -for (my $i = 0; $i < @vec; $i++) { - ok(sha1_hex($vec[$i]), $rsp[$i]); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-224.t b/ext/Digest/SHA/t/2-nist-sha-224.t deleted file mode 100644 index 8923a83..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-224.t +++ /dev/null @@ -1,33 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha224_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, @rsp); - -BEGIN { - @vec = ( -"abc", -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", -"a" x 1000000 - ); - - @rsp = ( -"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", -"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525", -"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" - ); - - plan tests => scalar(@vec); -} - -for (my $i = 0; $i < @vec; $i++) { - ok(sha224_hex($vec[$i]), $rsp[$i]); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-256.t b/ext/Digest/SHA/t/2-nist-sha-256.t deleted file mode 100644 index 67528ab..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-256.t +++ /dev/null @@ -1,33 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha256_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, @rsp); - -BEGIN { - @vec = ( -"abc", -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", -"a" x 1000000 - ); - - @rsp = ( -"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", -"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", -"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" - ); - - plan tests => scalar(@vec); -} - -for (my $i = 0; $i < @vec; $i++) { - ok(sha256_hex($vec[$i]), $rsp[$i]); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-384.t b/ext/Digest/SHA/t/2-nist-sha-384.t deleted file mode 100644 index 87e4c0b..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-384.t +++ /dev/null @@ -1,35 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha384_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, @rsp); - -BEGIN { - @vec = ( -"abc", -"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", -"a" x 1000000 - ); - - @rsp = ( -"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7", -"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039", -"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985" - ); - - plan tests => scalar(@vec); -} - -my $skip = sha384_hex("") ? 0 : 1; - -for (my $i = 0; $i < @vec; $i++) { - skip($skip, sha384_hex($vec[$i]), $rsp[$i]); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-base64.t b/ext/Digest/SHA/t/2-nist-sha-base64.t deleted file mode 100644 index 3d6dd5d..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-base64.t +++ /dev/null @@ -1,37 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha1_base64 sha224_base64 sha256_base64 sha384_base64 sha512_base64); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec, $data); - -BEGIN { - $data = "abc"; - @vec = ( -\&sha1_base64, "qZk+NkcGgWq6PiVxeFDCbJzQ2J0", -\&sha224_base64, "Iwl9IjQF2CKGQqR3vaJVsyqtvOS9oLP342ydpw", -\&sha256_base64, "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0", -\&sha384_base64, "ywB1P0WjXou1oD1pmsZQBycsMqsO3tFjGotgWkP/W+2AhgcroefMI1i67KE0yCWn", -\&sha512_base64, "3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw" - ); - - plan tests => scalar(@vec) / 2; -} - -my $fcn; -my $rsp; -my $skip; - -while (@vec) { - $fcn = shift(@vec); - $rsp = shift(@vec); - $skip = &$fcn("") ? 0 : 1; - skip($skip, &$fcn($data), $rsp); -} diff --git a/ext/Digest/SHA/t/2-nist-sha-oo.t b/ext/Digest/SHA/t/2-nist-sha-oo.t deleted file mode 100644 index 61c5e7c..0000000 --- a/ext/Digest/SHA/t/2-nist-sha-oo.t +++ /dev/null @@ -1,91 +0,0 @@ -use Test; -use strict; -use integer; -use File::Basename qw(dirname); -use File::Spec; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec); - -BEGIN { - @vec = ( -"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0", -"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" - ); - - plan tests => 6 + scalar(@vec); -} - - # attempt to use an invalid algorithm, and check for failure - -my $NSA = "SHA-42"; # No Such Algorithm -ok(Digest::SHA->new($NSA), undef); - - # test OO methods using first two SHA-256 vectors from NIST - -my $file = File::Spec->catfile(dirname($0), "oo.tmp"); -open(my $fh, q{>}, $file); -binmode($fh); -print $fh "bcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; -close($fh); - -my $ctx = Digest::SHA->new()->reset("SHA-256")->new(); -$ctx->add_bits("a", 5)->add_bits("001"); - -my $rsp = shift(@vec); -ok($ctx->clone->add("b", "c")->b64digest, $rsp); - -$rsp = shift(@vec); - - # test addfile with bareword filehandle - -open(FILE, "<$file"); ## no critic -binmode(FILE); ## no critic -ok($ctx->clone->addfile(*FILE)->hexdigest, $rsp); ## no critic -close(FILE); ## no critic - - # test addfile with indirect filehandle - -undef($fh); open($fh, q{<}, $file); -binmode($fh); -ok($ctx->clone->addfile($fh)->hexdigest, $rsp); -close($fh); - - # test addfile using file name instead of handle - -ok($ctx->addfile($file, "b")->hexdigest, $rsp); - - # test addfile portable mode - -undef($fh); open($fh, q{>}, $file); -binmode($fh); -print $fh "abc\012" x 2048; # using UNIX newline -close($fh); - -ok($ctx->new(1)->addfile($file, "p")->hexdigest, - "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"); - -undef($fh); open($fh, q{>}, $file); -binmode($fh); -print $fh "abc\015\012" x 2048; # using DOS/Windows newline -close($fh); - -ok($ctx->new(1)->addfile($file, "p")->hexdigest, - "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"); - -undef($fh); open($fh, q{>}, $file); -binmode($fh); -print $fh "abc\015" x 2048; # using Apple/Mac newline -close($fh); - -ok($ctx->new(1)->addfile($file, "p")->hexdigest, - "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"); - -unlink($file); diff --git a/ext/Digest/SHA/t/2-nist-vectors-bit.t b/ext/Digest/SHA/t/2-nist-vectors-bit.t deleted file mode 100644 index e870836..0000000 --- a/ext/Digest/SHA/t/2-nist-vectors-bit.t +++ /dev/null @@ -1,87 +0,0 @@ -# Test against SHA-1 Sample Vectors from NIST -# -# ref: http://csrc.nist.gov/cryptval/shs.html -# -# Uses files "nist/bit-messages.sha1" and "nist/bit-hashes.sha1" - -use Test; -use strict; -use integer; - -use File::Basename qw(dirname); -use File::Spec; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my @hashes; - -BEGIN { - my $file = File::Spec->catfile(dirname($0), "nist", "bit-hashes.sha1"); - open(my $fh, q{<}, $file); - while (<$fh>) { - next unless (/^[0-9A-F]/); - s/[\r\n]+$//; - if (/\^$/) { - s/\s*\^$//; - push(@hashes, $_); - } - } - close($fh); - plan tests => scalar(@hashes); -} - -sub doType3 { - my $hash; - my $str = pack("B*", shift); - my $ctx = Digest::SHA->new(1); - for (my $j = 0; $j <= 99; $j++) { - for (my $i = 1; $i <= 50000; $i++) { - $str .= chr(0x00) x (int($j/4)+3); - $str .= pack("N", $i); - $str = $ctx->add($str)->digest; - } - ok(uc(unpack("H*", $str)), $hash = shift(@hashes)); - } -} - -my @msgs; -my @cnts; -my $bitstr; -my $bitval; -my $line; -my $hash; -my $type3 = 0; -my $ctx = Digest::SHA->new(1); - -my $file = File::Spec->catfile(dirname($0), "nist", "bit-messages.sha1"); -open(my $fh, q{<}, $file); -while (<$fh>) { - $type3 = 1 if (/Type 3/); - $type3 = 0 if (/^add_bits($bitstr)->hexdigest), - $hash = shift(@hashes) - ) unless $type3; - doType3($bitstr) if ($type3); - $line = ""; - } -} -close($fh); diff --git a/ext/Digest/SHA/t/2-nist-vectors-byte.t b/ext/Digest/SHA/t/2-nist-vectors-byte.t deleted file mode 100644 index 3a0d0b4..0000000 --- a/ext/Digest/SHA/t/2-nist-vectors-byte.t +++ /dev/null @@ -1,87 +0,0 @@ -# Test against SHA-1 Sample Vectors from NIST -# -# ref: http://csrc.nist.gov/cryptval/shs.html -# -# Uses files "nist/byte-messages.sha1" and "nist/byte-hashes.sha1" - -use Test; -use strict; -use integer; - -use File::Basename qw(dirname); -use File::Spec; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my @hashes; - -BEGIN { - my $file = File::Spec->catfile(dirname($0), "nist", "byte-hashes.sha1"); - open(my $fh, q{<}, $file); - while (<$fh>) { - next unless (/^[0-9A-F]/); - s/[\r\n]+$//; - if (/\^$/) { - s/\s*\^$//; - push(@hashes, $_); - } - } - close($fh); - plan tests => scalar(@hashes); -} - -sub doType3 { - my $hash; - my $str = pack("B*", shift); - my $ctx = Digest::SHA->new(1); - for (my $j = 0; $j <= 99; $j++) { - for (my $i = 1; $i <= 50000; $i++) { - $str .= chr(0x00) x (int($j/4)+3); - $str .= pack("N", $i); - $str = $ctx->add($str)->digest; - } - ok(uc(unpack("H*", $str)), $hash = shift(@hashes)); - } -} - -my @msgs; -my @cnts; -my $bitstr; -my $bitval; -my $line; -my $hash; -my $type3 = 0; -my $ctx = Digest::SHA->new(1); - -my $file = File::Spec->catfile(dirname($0), "nist", "byte-messages.sha1"); -open(my $fh, q{<}, $file); -while (<$fh>) { - $type3 = 1 if (/Type 3/); - $type3 = 0 if (/^add(pack("B*", $bitstr))->hexdigest), - $hash = shift(@hashes) - ) unless $type3; - doType3($bitstr) if ($type3); - $line = ""; - } -} -close($fh); diff --git a/ext/Digest/SHA/t/3-gillogly-easy.t b/ext/Digest/SHA/t/3-gillogly-easy.t deleted file mode 100644 index 1be7ec5..0000000 --- a/ext/Digest/SHA/t/3-gillogly-easy.t +++ /dev/null @@ -1,68 +0,0 @@ -# Test against short bitwise vectors from Jim Gillogly and Francois Grieu -# -# http://www.chiark.greenend.org.uk/pipermail/ukcrypto/1999-February/003538.html - -use Test; -use strict; -use integer; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -# SHA-1 Test Vectors -# -# In the following we use the notation bitstring#n to mean a bitstring -# repeated n (in decimal) times, and we use | for concatenation. -# Therefore 110#3|1 is 1101101101. -# -# 110#148|11 : CE7387AE 577337BE 54EA94F8 2C842E8B E76BC3E1 -# 110#149 : DE244F06 3142CB2F 4C903B7F 7660577F 9E0D8791 -# 110#149|1 : A3D29824 27AE39C8 920CA5F4 99D6C2BD 71EBF03C -# 110#149|11 : 351AAB58 FF93CF12 AF7D5A58 4CFC8F7D 81023D10 -# -# 110#170 : 99638692 1E480D4E 2955E727 5DF3522C E8F5AB6E -# 110#170|1 : BB5F4AD4 8913F51B 157EB985 A5C2034B 8243B01B -# 110#170|11 : 9E92C554 2237B957 BA2244E8 141FDB66 DEC730A5 -# 110#171 : 2103E454 DA4491F4 E32DD425 A3341DC9 C2A90848 -# -# 011#490 : B4B18049 DE405027 528CD9E7 4B2EC540 D4E6F06B -# 011#490|0 : 34C63356 B3087427 20AB9669 14EB0FC9 26E4294B -# 011#490|01 : 75FACE18 02B9F84F 326368AB 06E73E05 02E9EA34 -# 011#491 : 7C2C3D62 F6AEC28D 94CDF93F 02E739E7 490698A1 -# - -my(@vec); - -BEGIN { - @vec = ( - "110",148,"11","ce7387ae577337be54ea94f82c842e8be76bc3e1", - "110",149,"","de244f063142cb2f4c903b7f7660577f9e0d8791", - "110",149,"1","a3d2982427ae39c8920ca5f499d6c2bd71ebf03c", - "110",149,"11","351aab58ff93cf12af7d5a584cfc8f7d81023d10", - "110",170,"","996386921e480d4e2955e7275df3522ce8f5ab6e", - "110",170,"1","bb5f4ad48913f51b157eb985a5c2034b8243b01b", - "110",170,"11","9e92c5542237b957ba2244e8141fdb66dec730a5", - "110",171,"","2103e454da4491f4e32dd425a3341dc9c2a90848", - "011",490,"","b4b18049de405027528cd9e74b2ec540d4e6f06b", - "011",490,"0","34c63356b308742720ab966914eb0fc926e4294b", - "011",490,"01","75face1802b9f84f326368ab06e73e0502e9ea34", - "011",491,"","7c2c3d62f6aec28d94cdf93f02e739e7490698a1", - ); - plan tests => scalar(@vec) / 4; -} - -my $bitstr; -my $bitcnt; -my $ctx = Digest::SHA->new(1); - -for (my $i = 0; $i < @vec/4; $i++) { - $bitstr = ($vec[4*$i] x $vec[4*$i+1]) . $vec[4*$i+2]; - $bitcnt = length($bitstr); - $bitstr = pack("B*", $bitstr); - ok($ctx->add_bits($bitstr, $bitcnt)->hexdigest, $vec[4*$i+3]); -} diff --git a/ext/Digest/SHA/t/4-bitstr-increasing.t b/ext/Digest/SHA/t/4-bitstr-increasing.t deleted file mode 100644 index 61e9a8e..0000000 --- a/ext/Digest/SHA/t/4-bitstr-increasing.t +++ /dev/null @@ -1,29 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -BEGIN { plan tests => 1 } - -my $i; -my $bitstr = pack("B*", "1" x 3999); -my $state = Digest::SHA->new("sHa1"); - -# Note that (1 + 2 + ... + 3999) + 2000 = 8000000 - -for ($i = 0; $i <= 3999; $i++) { - $state->add_bits($bitstr, $i); -} -$state->add_bits($bitstr, 2000); - -ok( - $state->hexdigest, - "559a512393dd212220ee080730d6f11644ba0222" -); diff --git a/ext/Digest/SHA/t/4-bitstr-large.t b/ext/Digest/SHA/t/4-bitstr-large.t deleted file mode 100644 index 3939405..0000000 --- a/ext/Digest/SHA/t/4-bitstr-large.t +++ /dev/null @@ -1,28 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -BEGIN { plan tests => 1 } - -my $i; -my $bitstr = pack("B*", "11111111" x 10000); -my $state = Digest::SHA->new("1"); - -$state->add_bits($bitstr, 1); # creates an alignment nuisance -for ($i = 0; $i < 99; $i++) { - $state->add_bits($bitstr, 80000); -} -$state->add_bits($bitstr, 79999); - -ok( - $state->hexdigest, - "559a512393dd212220ee080730d6f11644ba0222" -); diff --git a/ext/Digest/SHA/t/4-bitstr-random.t b/ext/Digest/SHA/t/4-bitstr-random.t deleted file mode 100644 index 137449a..0000000 --- a/ext/Digest/SHA/t/4-bitstr-random.t +++ /dev/null @@ -1,31 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -BEGIN { plan tests => 1 } - -my $reps = 8000000; -my $bitstr = pack("B*", "11111111" x 127); -my $maxbits = 8 * 127; -my $state = Digest::SHA->new(1); -my $num; - -while ($reps > $maxbits) { - $num = int(rand($maxbits)); - $state->add_bits($bitstr, $num); - $reps -= $num; -} -$state->add_bits($bitstr, $reps); - -ok( - $state->hexdigest, - "559a512393dd212220ee080730d6f11644ba0222" -); diff --git a/ext/Digest/SHA/t/5-hmac-fips198.t b/ext/Digest/SHA/t/5-hmac-fips198.t deleted file mode 100644 index 07c8c91..0000000 --- a/ext/Digest/SHA/t/5-hmac-fips198.t +++ /dev/null @@ -1,51 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(hmac_sha1_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@vec); - -BEGIN { - @vec = ( - "Sample #1", - "Sample #2", - "Sample #3", - "Sample #4" - ); - plan tests => scalar(@vec); -} - -my @keys = ("", "", "", ""); - -my $i = 0; -$keys[0] .= chr($i++) while (length($keys[0]) < 64); - -$i = 0x30; -$keys[1] .= chr($i++) while (length($keys[1]) < 20); - -$i = 0x50; -$keys[2] .= chr($i++) while (length($keys[2]) < 100); - -$i = 0x70; -$keys[3] .= chr($i++) while (length($keys[3]) < 49); - -my @hmac1rsp = ( - "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", - "0922d3405faa3d194f82a45830737d5cc6c75d24", - "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", - "9ea886efe268dbecce420c7524df32e0751a2a26" -); - -for ($i = 0; $i < @vec; $i++) { - ok( - hmac_sha1_hex($vec[$i], $keys[$i]), - $hmac1rsp[$i] - ); -} diff --git a/ext/Digest/SHA/t/5-hmac-woodbury.t b/ext/Digest/SHA/t/5-hmac-woodbury.t deleted file mode 100644 index 18782f7..0000000 --- a/ext/Digest/SHA/t/5-hmac-woodbury.t +++ /dev/null @@ -1,121 +0,0 @@ -# Test Vectors for HMAC-SHA-256/384/512 -# -# Vectors and script courtesy of Adam Woodbury, The MITRE Corporation - -use Test; -use strict; -use integer; -use Digest::SHA qw(hmac_sha256_hex hmac_sha384_hex hmac_sha512_hex); - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -BEGIN { plan tests => 21 } - -# Use RFC 2202 data/key values for 512-bit blocks - -my @vecs_bs512 = ( - "Hi There", - "what do ya want for nothing?", - chr(0xdd) x 50, - chr(0xcd) x 50, - "Test With Truncation", - "Test Using Larger Than Block-Size Key - Hash Key First", - "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" -); - -my @keys_bs512 = ( - chr(0x0b) x 20, - "Jefe", - chr(0xaa) x 20, - "", - chr(0x0c) x 20, - chr(0xaa) x 80, - chr(0xaa) x 80 -); - -# Lengthen final RFC 2202 data/key values for 1024-bit blocks - -my @vecs_bs1024 = ( - "Hi There", - "what do ya want for nothing?", - chr(0xdd) x 50, - chr(0xcd) x 50, - "Test With Truncation", - "Test Using Larger Than Block-Size Key - Hash Key First", - "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data. The Larger Block-Sizes Make For Much Longer Test Vectors" -); - -my @keys_bs1024 = ( - chr(0x0b) x 20, - "Jefe", - chr(0xaa) x 20, - "", - chr(0x0c) x 20, - chr(0xaa) x 200, - chr(0xaa) x 200 -); - -my @hmac256rsp = ( - "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7", - "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843", - "773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe", - "82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b", - "a3b6167473100ee06e0c796c2955552bfa6f7c0a6a8aef8b93f860aab0cd20c5", - "6953025ed96f0c09f80a96f78e6538dbe2e7b820e3dd970e7ddd39091b32352f", - "6355ac22e890d0a3c8481a5ca4825bc884d3e7a1ff98a2fc2ac7d8e064c3b2e6" -); - -my @hmac384rsp = ( -"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6", -"af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649", -"88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27", -"3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb", -"3abf34c3503b2a23a46efc619baef897f4c8e42c934ce55ccbae9740fcbc1af4ca62269e2a37cd88ba926341efe4aeea", -"ec629fe0dc1fab504fc1c89572d6573cf15c3a4b5b69d53f0c13849561a6c13e153af48d2538ce056a3fe10d69da16c3", -"07109d2c6c2fdcac39c3a8b5f36fc9a69e029d3d8647cc3e4ddb77888418c5c09d807942e5f96d17ee9fd46aed64b7f2" -); - -my @hmac512rsp = ( -"87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854", -"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737", -"fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb", -"b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd", -"415fad6271580a531d4179bc891d87a650188707922a4fbb36663a1eb16da008711c5b50ddd0fc235084eb9d3364a1454fb2ef67cd1d29fe6773068ea266e96b", -"9dc6330f4c966b62b735d565343cb77413deccdf42a92d9ef5e4e2ae33f6c924bbc8e34c47111bc069482d4dbcfee148419a6547f2d01500e8160b39cc2e4ae8", -"396ed3a17cef82cddbd987ea66a5dd1f38b68167df31f049463b85fa10b531d0e90d1052f8c9c7cda263468ec3f980a8fec06213c2944c92a0ac95a2d8ade76d" -); - -my $i = 0x01; -$keys_bs512[3] .= chr($i++) while (length($keys_bs512[3]) < 25); -$i = 0x01; -$keys_bs1024[3] .= chr($i++) while (length($keys_bs1024[3]) < 25); - -for ($i = 0; $i < @vecs_bs512; $i++) { - ok( - hmac_sha256_hex($vecs_bs512[$i], $keys_bs512[$i]), - $hmac256rsp[$i] - ); -} - -my $skip = hmac_sha384_hex("", "") ? 0 : 1; - -for ($i = 0; $i < @vecs_bs1024; $i++) { - skip( - $skip, - hmac_sha384_hex($vecs_bs1024[$i], $keys_bs1024[$i]), - $hmac384rsp[$i] - ); -} - -for ($i = 0; $i < @vecs_bs1024; $i++) { - skip( - $skip, - hmac_sha512_hex($vecs_bs1024[$i], $keys_bs1024[$i]), - $hmac512rsp[$i] - ); -} diff --git a/ext/Digest/SHA/t/6-dump-load.t b/ext/Digest/SHA/t/6-dump-load.t deleted file mode 100644 index 874812c..0000000 --- a/ext/Digest/SHA/t/6-dump-load.t +++ /dev/null @@ -1,57 +0,0 @@ -use Test; -use strict; -use integer; -use Digest::SHA qw(sha384_hex sha512_hex); -use File::Basename qw(dirname); -use File::Spec; - -BEGIN { - if ($ENV{PERL_CORE}) { - chdir 't' if -d 't'; - @INC = '../lib'; - } -} - -my(@sharsp); - -BEGIN { - @sharsp = ( -"34aa973cd4c4daa4f61eeb2bdbad27316534016f", -"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0", -"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985", -"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" - ); - plan tests => scalar(@sharsp); -} - -my @ext = (1, 256, 384, 512); -my $data = "a" x 990000; -my $skip; -my $tmpfile = File::Spec->catfile(dirname($0), "dumpload.tmp"); - -for (my $i = 0; $i < @sharsp; $i++) { - $skip = 0; - if ($ext[$i] == 384) { - $skip = sha384_hex("") ? 0 : 1; - } - if ($ext[$i] == 512) { - $skip = sha512_hex("") ? 0 : 1; - } - my $digest; - unless ($skip) { - my $state; - my $file = File::Spec->catfile(dirname($0), - "state", "state.$ext[$i]"); - unless ($state = Digest::SHA->load($file)) { - $state = Digest::SHA->new($ext[$i]); - $state->add($data); - $state->dump($file); - $state->load($file); - } - $state->add_bits($data, 79984)->dump($tmpfile); - $state->load($tmpfile)->add_bits($data, 16); - unlink($tmpfile); - $digest = $state->hexdigest; - } - skip($skip, $digest, $sharsp[$i]); -} diff --git a/ext/Digest/SHA/t/allfcns.t b/ext/Digest/SHA/t/allfcns.t new file mode 100644 index 0000000..309f730 --- /dev/null +++ b/ext/Digest/SHA/t/allfcns.t @@ -0,0 +1,30 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw( + hmac_sha1 hmac_sha1_base64 hmac_sha1_hex + hmac_sha224 hmac_sha224_base64 hmac_sha224_hex + hmac_sha256 hmac_sha256_base64 hmac_sha256_hex + hmac_sha384 hmac_sha384_base64 hmac_sha384_hex + hmac_sha512 hmac_sha512_base64 hmac_sha512_hex + sha1 sha1_base64 sha1_hex + sha224 sha224_base64 sha224_hex + sha256 sha256_base64 sha256_hex + sha384 sha384_base64 sha384_hex + sha512 sha512_base64 sha512_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +print "1..1\n"; + +print "ok 1\n"; diff --git a/ext/Digest/SHA/t/base64.t b/ext/Digest/SHA/t/base64.t new file mode 100644 index 0000000..52531df --- /dev/null +++ b/ext/Digest/SHA/t/base64.t @@ -0,0 +1,43 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha1_base64 sha224_base64 sha256_base64 + sha384_base64 sha512_base64)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my $in = "abc"; +my @out = map { eval } ; +my @fcn = (\&sha1_base64, \&sha224_base64, \&sha256_base64, + \&sha384_base64, \&sha512_base64); + +print "1..", scalar @out, "\n"; + +my $testnum = 1; +while (@out) { + my $fcn = shift @fcn; + my $rsp = shift @out; + my $skip = &$fcn("") ? 0 : 1; + unless ($skip) { + print "not " unless &$fcn($in) eq $rsp; + } + print "ok ", $testnum++, $skip ? " # skip: no 64 bit" : "", "\n"; +} + +__DATA__ +"qZk+NkcGgWq6PiVxeFDCbJzQ2J0" +"Iwl9IjQF2CKGQqR3vaJVsyqtvOS9oLP342ydpw" +"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0" +"ywB1P0WjXou1oD1pmsZQBycsMqsO3tFjGotgWkP/W+2AhgcroefMI1i67KE0yCWn" +"3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw" + diff --git a/ext/Digest/SHA/t/bitbuf.t b/ext/Digest/SHA/t/bitbuf.t new file mode 100644 index 0000000..d49380e --- /dev/null +++ b/ext/Digest/SHA/t/bitbuf.t @@ -0,0 +1,73 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my $numtests = 4; +print "1..$numtests\n"; + + # Here's the bitstring to test against, and its SHA-1 digest + +my $ONEBITS = pack("B*", "1" x 80000); +my $digest = "11003389959355c2773af6b0f36d842fe430ec49"; + +my $state = $MODULE->new("sHa1"); +my $testnum = 1; + +$state->add_bits($ONEBITS, 80000); +print "not " unless $state->hexdigest eq $digest; +print "ok ", $testnum++, "\n"; + + # buffer using a series of increasingly large bitstrings + +# Note that (1 + 2 + ... + 399) + 200 = 80000 + +for (1 .. 399) { + $state->add_bits($ONEBITS, $_); +} +$state->add_bits($ONEBITS, 200); + +print "not " unless $state->hexdigest eq $digest; +print "ok ", $testnum++, "\n"; + + # create a buffer-alignment nuisance + +$state = $MODULE->new("1"); + +$state->add_bits($ONEBITS, 1); +for (1 .. 99) { + $state->add_bits($ONEBITS, 800); +} +$state->add_bits($ONEBITS, 799); + +print "not " unless $state->hexdigest eq $digest; +print "ok ", $testnum++, "\n"; + + # buffer randomly-sized bitstrings + +my $reps = 80000; +my $maxbits = 8 * 127; + +$state = $MODULE->new(1); + +while ($reps > $maxbits) { + my $num = int(rand($maxbits)); + $state->add_bits($ONEBITS, $num); + $reps -= $num; +} +$state->add_bits($ONEBITS, $reps); + +print "not " unless $state->hexdigest eq $digest; +print "ok ", $testnum++, "\n"; diff --git a/ext/Digest/SHA/t/dumpload.t b/ext/Digest/SHA/t/dumpload.t new file mode 100644 index 0000000..27f7a7d --- /dev/null +++ b/ext/Digest/SHA/t/dumpload.t @@ -0,0 +1,102 @@ +use strict; +use FileHandle; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha384_hex sha512_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @sharsp = ( + "34aa973cd4c4daa4f61eeb2bdbad27316534016f", + "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0", + "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985", + "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" +); + +my $numtests = scalar @sharsp; +print "1..$numtests\n"; + +my @tempfiles; +END { 1 while unlink @tempfiles } + +my @statefiles = ("dl001.tmp", "dl256.tmp", "dl384.tmp", "dl512.tmp"); +for (@statefiles) { + push @tempfiles, $_; + my $fh = FileHandle->new($_, "w"); + for (1 .. 8) { my $line = ; print $fh $line } + $fh->close; +} +my $tmpfile = "dumpload.tmp"; +push @tempfiles, $tmpfile; + +my @alg = (1, 256, 384, 512); +my $data = "a" x 990000; + +my $testnum = 1; +while (@sharsp) { + my $skip = 0; + my $alg = shift @alg; + my $rsp = shift @sharsp; + my $file = shift @statefiles; push(@statefiles, $file); + if ($alg == 384) { $skip = sha384_hex("") ? 0 : 1 } + if ($alg == 512) { $skip = sha512_hex("") ? 0 : 1 } + if ($skip) { + print "ok ", $testnum++, " # skip: no 64 bit\n"; + next; + } + my $digest; + my $state; + unless ($state = $MODULE->load($file)) { + print "not ok ", $testnum++, "\n"; + next; + } + $state->add_bits($data, 79984)->dump($tmpfile); + $state->load($tmpfile)->add_bits($data, 16); + $digest = $state->hexdigest; + print "not " unless $digest eq $rsp; + print "ok ", $testnum++, "\n"; +} + +__DATA__ +alg:1 +H:9d6f7d2f:65e21307:c6f41af6:7c7fd3a9:8dec6058:00000000:00000000:00000000 +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 +blockcnt:384 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:7920000 +alg:256 +H:2d6c0def:4244ade7:fc8c121c:108f4493:ec3fbec2:91425a6e:b8d30d2a:9db24273 +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 +blockcnt:384 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:7920000 +alg:384 +H:598147f4583a61f7:8d194a4d7c9008cb:39725c96557d600f:d7f2079ce8251f19:bd735d446f9a3c7c:234de90b9060898d:a5b481b9d635d190:81c6e74ee4556125 +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 +blockcnt:384 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:7920000 +alg:512 +H:0442fe29a02b8c30:13553e6dbedc2aa0:8f891a0cb2ac3107:6fa1762b40ac04dd:dcbf420d729eea79:34703e9672dcf145:7bf9aaa14d400433:2aa65f044825466d +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 +blockcnt:384 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:7920000 diff --git a/ext/Digest/SHA/t/fips198.t b/ext/Digest/SHA/t/fips198.t new file mode 100644 index 0000000..7eda6e7 --- /dev/null +++ b/ext/Digest/SHA/t/fips198.t @@ -0,0 +1,42 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(hmac_sha1_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @data = map { "Sample #$_" } (1 .. 4); + +my @out = ( + "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", + "0922d3405faa3d194f82a45830737d5cc6c75d24", + "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", + "9ea886efe268dbecce420c7524df32e0751a2a26" +); + +my @keys = ("", "", "", ""); + +for (0x00 .. 0x00+63) { $keys[0] .= chr($_) } +for (0x30 .. 0x30+19) { $keys[1] .= chr($_) } +for (0x50 .. 0x50+99) { $keys[2] .= chr($_) } +for (0x70 .. 0x70+48) { $keys[3] .= chr($_) } + +my $numtests = scalar @data; +print "1..$numtests\n"; + +my $testnum = 1; +while (@data) { + print "not " unless hmac_sha1_hex(shift @data, shift @keys) + eq shift @out; + print "ok ", $testnum++, "\n"; +} diff --git a/ext/Digest/SHA/t/gg.t b/ext/Digest/SHA/t/gg.t new file mode 100644 index 0000000..c96156d --- /dev/null +++ b/ext/Digest/SHA/t/gg.t @@ -0,0 +1,72 @@ +# Test against short bitwise vectors from Jim Gillogly and Francois Grieu +# +# http://www.chiark.greenend.org.uk/pipermail/ukcrypto/1999-February/003538.html + +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +# SHA-1 Test Vectors +# +# In the following we use the notation bitstring#n to mean a bitstring +# repeated n (in decimal) times, and we use | for concatenation. +# Therefore 110#3|1 is 1101101101. +# +# 110#148|11 : CE7387AE 577337BE 54EA94F8 2C842E8B E76BC3E1 +# 110#149 : DE244F06 3142CB2F 4C903B7F 7660577F 9E0D8791 +# 110#149|1 : A3D29824 27AE39C8 920CA5F4 99D6C2BD 71EBF03C +# 110#149|11 : 351AAB58 FF93CF12 AF7D5A58 4CFC8F7D 81023D10 +# +# 110#170 : 99638692 1E480D4E 2955E727 5DF3522C E8F5AB6E +# 110#170|1 : BB5F4AD4 8913F51B 157EB985 A5C2034B 8243B01B +# 110#170|11 : 9E92C554 2237B957 BA2244E8 141FDB66 DEC730A5 +# 110#171 : 2103E454 DA4491F4 E32DD425 A3341DC9 C2A90848 +# +# 011#490 : B4B18049 DE405027 528CD9E7 4B2EC540 D4E6F06B +# 011#490|0 : 34C63356 B3087427 20AB9669 14EB0FC9 26E4294B +# 011#490|01 : 75FACE18 02B9F84F 326368AB 06E73E05 02E9EA34 +# 011#491 : 7C2C3D62 F6AEC28D 94CDF93F 02E739E7 490698A1 + +my @vecs = ( + "110",148,"11","ce7387ae577337be54ea94f82c842e8be76bc3e1", + "110",149,"","de244f063142cb2f4c903b7f7660577f9e0d8791", + "110",149,"1","a3d2982427ae39c8920ca5f499d6c2bd71ebf03c", + "110",149,"11","351aab58ff93cf12af7d5a584cfc8f7d81023d10", + "110",170,"","996386921e480d4e2955e7275df3522ce8f5ab6e", + "110",170,"1","bb5f4ad48913f51b157eb985a5c2034b8243b01b", + "110",170,"11","9e92c5542237b957ba2244e8141fdb66dec730a5", + "110",171,"","2103e454da4491f4e32dd425a3341dc9c2a90848", + "011",490,"","b4b18049de405027528cd9e74b2ec540d4e6f06b", + "011",490,"0","34c63356b308742720ab966914eb0fc926e4294b", + "011",490,"01","75face1802b9f84f326368ab06e73e0502e9ea34", + "011",491,"","7c2c3d62f6aec28d94cdf93f02e739e7490698a1", +); + +my $numtests = scalar(@vecs) / 4; +print "1..$numtests\n"; + +my $testnum = 1; +my $sha = $MODULE->new(1); + +while (@vecs) { + my $frag = shift @vecs; + my $reps = shift @vecs; + my $tail = shift @vecs; + my $bitstr = ($frag x $reps) . $tail; + print "not " unless $sha->add_bits($bitstr)->hexdigest + eq shift @vecs; + print "ok ", $testnum++, "\n"; +} diff --git a/ext/Digest/SHA/t/3-gillogly-hard.t b/ext/Digest/SHA/t/gglong.t similarity index 51% rename from ext/Digest/SHA/t/3-gillogly-hard.t rename to ext/Digest/SHA/t/gglong.t index 813d92a..f53464c 100644 --- a/ext/Digest/SHA/t/3-gillogly-hard.t +++ b/ext/Digest/SHA/t/gglong.t @@ -2,12 +2,16 @@ # # http://www.chiark.greenend.org.uk/pipermail/ukcrypto/1999-February/003538.html -use Test; use strict; -use integer; -use File::Basename qw(dirname); -use File::Spec; -use Digest::SHA; +use FileHandle; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} BEGIN { if ($ENV{PERL_CORE}) { @@ -35,37 +39,42 @@ BEGIN { # 011#1431655765|0 A3D7438C 589B0B93 2AA91CC2 446F06DF 9ABC73F0 # 011#1431655765|01 3EEE3E1E 28DEDE2C A444D68D A5675B2F AAAB3203 -my(@vec110, @vec011); +my @vec110 = ( # 110 rep 1431655764 + "11", "1eef5a18969255a3b1793a2a955c7ec28cd221a5", + "110", "7a1045b914672aface8d90e6d19b3a6ada3cb879", + "1101", "d5e09777a94f1ea9240874c48d9fecb6b634256b", + "11011", "eb2569043c3014e51b2862ae6eb5fb4e0b851d99" +); -BEGIN { - @vec110 = ( # 110 rep 1431655764 - "11", "1eef5a18969255a3b1793a2a955c7ec28cd221a5", - "110", "7a1045b914672aface8d90e6d19b3a6ada3cb879", - "1101", "d5e09777a94f1ea9240874c48d9fecb6b634256b", - "11011", "eb2569043c3014e51b2862ae6eb5fb4e0b851d99" - ); - - @vec011 = ( # 011 rep 1431655764 - "01", "4cb0c4ef69143d5bf34fc35f1d4b19f6eccae0f2", - "011", "47d92f911fc7bb74de00adfc4e981a8105556d52", - "0110", "a3d7438c589b0b932aa91cc2446f06df9abc73f0", - "01101", "3eee3e1e28dede2ca444d68da5675b2faaab3203" - ); - plan tests => scalar(@vec110) / 2 + scalar(@vec011) / 2; -} +my @vec011 = ( # 011 rep 1431655764 + "01", "4cb0c4ef69143d5bf34fc35f1d4b19f6eccae0f2", + "011", "47d92f911fc7bb74de00adfc4e981a8105556d52", + "0110", "a3d7438c589b0b932aa91cc2446f06df9abc73f0", + "01101", "3eee3e1e28dede2ca444d68da5675b2faaab3203" +); +print "1..", scalar(@vec110) / 2 + scalar(@vec011) / 2, "\n"; -my $STATE110 = File::Spec->catfile(dirname($0), "gillogly", "state.110"); -my $STATE011 = File::Spec->catfile(dirname($0), "gillogly", "state.011"); +my $STATE110 = "gglong0.tmp"; +my $STATE011 = "gglong1.tmp"; + +END { 1 while unlink $STATE110, $STATE011 } + +for ($STATE011, $STATE110) { + my $fh = FileHandle->new($_, "w"); + for (1 .. 8) { my $line = ; print $fh $line } + $fh->close; +} my $reps = 1 << 14; my $loops = int(1431655764 / $reps); my $rest = 3 * (1431655764 - $loops * $reps); sub state110 { + my $i; my $state; my $bitstr; - $state = Digest::SHA->new(1); + $state = $MODULE->new(1); if (-r $STATE110) { if ($state->load($STATE110)) { return($state); @@ -73,7 +82,7 @@ sub state110 { } $bitstr = pack("B*", "110" x $reps); $state->reset; - for (my $i = 0; $i < $loops; $i++) { + for ($i = 0; $i < $loops; $i++) { $state->add_bits($bitstr, 3 * $reps); } $state->add_bits($bitstr, $rest); @@ -82,10 +91,11 @@ sub state110 { } sub state011 { + my $i; my $state; my $bitstr; - $state = Digest::SHA->new(1); + $state = $MODULE->new(1); if (-r $STATE011) { if ($state->load($STATE011)) { return($state); @@ -93,7 +103,7 @@ sub state011 { } $bitstr = pack("B*", "011" x $reps); $state->reset; - for (my $i = 0; $i < $loops; $i++) { + for ($i = 0; $i < $loops; $i++) { $state->add_bits($bitstr, 3 * $reps); } $state->add_bits($bitstr, $rest); @@ -103,16 +113,38 @@ sub state011 { my $i; +my $testnum = 1; + my $state110 = state110(); for ($i = 0; $i < @vec110/2; $i++) { my $state = $state110->clone; $state->add_bits($vec110[2*$i]); - ok($state->hexdigest, $vec110[2*$i+1]); + print "not " unless $state->hexdigest eq $vec110[2*$i+1]; + print "ok ", $testnum++, "\n"; } my $state011 = state011(); for ($i = 0; $i < @vec011/2; $i++) { my $state = $state011->clone; $state->add_bits($vec011[2*$i]); - ok($state->hexdigest, $vec011[2*$i+1]); + print "not " unless $state->hexdigest eq $vec011[2*$i+1]; + print "ok ", $testnum++, "\n"; } + +__DATA__ +alg:1 +H:7950cbe2:86a45aa0:91ff7dff:29015b42:3912e764:00000000:00000000:00000000 +block:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6 +blockcnt:508 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:4294967292 +alg:1 +H:dfc51a14:87b4a4b7:ecf19acd:8cbbe40e:03a435f8:00000000:00000000:00000000 +block:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d +blockcnt:508 +lenhh:0 +lenhl:0 +lenlh:0 +lenll:4294967292 diff --git a/ext/Digest/SHA/t/gillogly/state.011 b/ext/Digest/SHA/t/gillogly/state.011 deleted file mode 100644 index 005c3c5..0000000 --- a/ext/Digest/SHA/t/gillogly/state.011 +++ /dev/null @@ -1,8 +0,0 @@ -alg:1 -H:7950cbe2:86a45aa0:91ff7dff:29015b42:3912e764:00000000:00000000:00000000 -block:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6 -blockcnt:508 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:4294967292 diff --git a/ext/Digest/SHA/t/gillogly/state.110 b/ext/Digest/SHA/t/gillogly/state.110 deleted file mode 100644 index 41b6215..0000000 --- a/ext/Digest/SHA/t/gillogly/state.110 +++ /dev/null @@ -1,8 +0,0 @@ -alg:1 -H:dfc51a14:87b4a4b7:ecf19acd:8cbbe40e:03a435f8:00000000:00000000:00000000 -block:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d:b6:db:6d -blockcnt:508 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:4294967292 diff --git a/ext/Digest/SHA/t/5-hmac-sha-256.t b/ext/Digest/SHA/t/hmacsha.t similarity index 54% rename from ext/Digest/SHA/t/5-hmac-sha-256.t rename to ext/Digest/SHA/t/hmacsha.t index 6a77835..d6ce6c0 100644 --- a/ext/Digest/SHA/t/5-hmac-sha-256.t +++ b/ext/Digest/SHA/t/hmacsha.t @@ -1,9 +1,14 @@ # HMAC-SHA-256 test vectors from draft-ietf-ipsec-ciph-sha-256-01.txt -use Test; use strict; -use integer; -use Digest::SHA qw(hmac_sha256_hex); + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(hmac_sha256_hex)); +} BEGIN { if ($ENV{PERL_CORE}) { @@ -12,28 +17,15 @@ BEGIN { } } -my(@data); +my @data = map { eval } ; -BEGIN { - @data = ( -"abc", -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", -"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", -"Hi There", -"what do ya want for nothing?", -chr(0xdd) x 50, -chr(0xcd) x 50, -"Test With Truncation", -"Test Using Larger Than Block-Size Key - Hash Key First", -"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" - ); - plan tests => scalar(@data); -} +my $numtests = scalar @data; +print "1..$numtests\n"; -my $k1 = pack("H*", "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"); -my $k2 = pack("H*", "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425"); +my $k1 = join( "", map { chr } (1 .. 32) ); +my $k2 = join( "", map { chr } (1 .. 37) ); -my @key = ( +my @keys = ( $k1, $k1, $k1, @@ -46,7 +38,7 @@ my @key = ( chr(0xaa) x 80 ); -my @hmac256rsp = ( +my @out = ( "a21b1f5d4cf4f73a4dd939750f7a066a7f98cc131cb16a6692759021cfab8181", "104fdc1257328f08184ba73131c53caee698e36119421149ea8c712456697d30", "470305fc7e40fe34d3eeb3e773d95aab73acf0fd060447a5eb4595bf33a9d1a3", @@ -59,13 +51,27 @@ my @hmac256rsp = ( "6355ac22e890d0a3c8481a5ca4825bc884d3e7a1ff98a2fc2ac7d8e064c3b2e6" ); - # do the first one by hand to test multi-argument data feed + # do the first one using multi-argument data feed -ok(hmac_sha256_hex("a", "b", "c", $k1), $hmac256rsp[0]); +my $testnum = 1; +my @args = split(//, shift @data); +print "not " unless hmac_sha256_hex(@args, shift @keys) eq shift @out; +print "ok ", $testnum++, "\n"; -for (my $i = 1; $i < @data; $i++) { - ok( - hmac_sha256_hex($data[$i], $key[$i]), - $hmac256rsp[$i] - ); +while (@data) { + print "not " unless hmac_sha256_hex(shift @data, shift @keys) + eq shift @out; + print "ok ", $testnum++, "\n"; } + +__DATA__ +"abc" +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +"Hi There" +"what do ya want for nothing?" +chr(0xdd) x 50 +chr(0xcd) x 50 +"Test With Truncation" +"Test Using Larger Than Block-Size Key - Hash Key First" +"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" diff --git a/ext/Digest/SHA/t/7-ireland.t b/ext/Digest/SHA/t/ireland.t similarity index 60% rename from ext/Digest/SHA/t/7-ireland.t rename to ext/Digest/SHA/t/ireland.t index 86e7d98..9063a6d 100644 --- a/ext/Digest/SHA/t/7-ireland.t +++ b/ext/Digest/SHA/t/ireland.t @@ -1,8 +1,13 @@ -use Test; use strict; -use File::Basename qw(dirname); -use File::Spec; -use Digest::SHA; +use FileHandle; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} BEGIN { if ($ENV{PERL_CORE}) { @@ -16,25 +21,23 @@ BEGIN { # Adapted from Julius Duque's original script (t/24-ireland.tmp) # - modified to use state cache via dump()/load() methods -BEGIN { plan tests => 1 } +print "1..1\n"; -my $file = File::Spec->catfile(dirname($0), "ireland.tmp"); -open(my $fh, q{>}, $file); while () { print $fh $_ } close($fh); +my $tempfile = "ireland.tmp"; +END { 1 while unlink $tempfile } -my $data = "a" x 1000000; -my $vec = "b9045a713caed5dff3d3b783e98d1ce5778d8bc331ee4119d707072312af06a7"; +my $fh = FileHandle->new($tempfile, "w"); +while () { print $fh $_ } close($fh); -my $ctx; -unless ($ctx = Digest::SHA->load($file)) { - $ctx = Digest::SHA->new(256); - for (1 .. 536) { $ctx->add($data) } - $ctx->add(substr($data, 0, 870910)); - $ctx->dump($file); -} -$ctx->add("aa"); -ok($ctx->hexdigest, $vec); +my $rsp = "b9045a713caed5dff3d3b783e98d1ce5778d8bc331ee4119d707072312af06a7"; -unlink($file); +my $sha; +if ($sha = $MODULE->load($tempfile)) { + $sha->add("aa"); + print "not " unless $sha->hexdigest eq $rsp; + print "ok 1\n"; +} +else { print "not ok 1\n" } __DATA__ alg:256 diff --git a/ext/Digest/SHA/t/methods.t b/ext/Digest/SHA/t/methods.t new file mode 100644 index 0000000..2d6f26d --- /dev/null +++ b/ext/Digest/SHA/t/methods.t @@ -0,0 +1,102 @@ +use strict; +use FileHandle; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @out = ( + "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0", + "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", +); + +my $numtests = 6 + scalar @out; +print "1..$numtests\n"; + + # attempt to use an invalid algorithm, and check for failure + +my $testnum = 1; +my $NSA = "SHA-42"; # No Such Algorithm +print "not " if $MODULE->new($NSA); +print "ok ", $testnum++, "\n"; + +my $tempfile = "methods.tmp"; +END { 1 while unlink $tempfile } + + # test OO methods using first two SHA-256 vectors from NIST + +my $fh = FileHandle->new($tempfile, "w"); +binmode($fh); +print $fh "bcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; +$fh->close; + +my $sha = $MODULE->new()->reset("SHA-256")->new(); +$sha->add_bits("a", 5)->add_bits("001"); + +my $rsp = shift(@out); +print "not " unless $sha->clone->add("b", "c")->b64digest eq $rsp; +print "ok ", $testnum++, "\n"; + +$rsp = shift(@out); + + # test addfile with bareword filehandle + +open(FILE, "<$tempfile"); +binmode(FILE); +print "not " unless + $sha->clone->addfile(*FILE)->hexdigest eq $rsp; +print "ok ", $testnum++, "\n"; +close(FILE); + + # test addfile with indirect filehandle + +$fh = FileHandle->new($tempfile, "r"); +binmode($fh); +print "not " unless $sha->clone->addfile($fh)->hexdigest eq $rsp; +print "ok ", $testnum++, "\n"; +$fh->close; + + # test addfile using file name instead of handle + +print "not " unless $sha->addfile($tempfile, "b")->hexdigest eq $rsp; +print "ok ", $testnum++, "\n"; + + # test addfile portable mode + +$fh = FileHandle->new($tempfile, "w"); +binmode($fh); +print $fh "abc\012" x 2048; # using UNIX newline +$fh->close; + +print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq + "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"; +print "ok ", $testnum++, "\n"; + +$fh = FileHandle->new($tempfile, "w"); +binmode($fh); +print $fh "abc\015\012" x 2048; # using DOS/Windows newline +$fh->close; + +print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq + "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"; +print "ok ", $testnum++, "\n"; + +$fh = FileHandle->new($tempfile, "w"); +binmode($fh); +print $fh "abc\015" x 2048; # using early-Mac newline +$fh->close; + +print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq + "d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51"; +print "ok ", $testnum++, "\n"; diff --git a/ext/Digest/SHA/t/nist/COPYRIGHT b/ext/Digest/SHA/t/nist/COPYRIGHT deleted file mode 100644 index 3671be9..0000000 --- a/ext/Digest/SHA/t/nist/COPYRIGHT +++ /dev/null @@ -1,17 +0,0 @@ -The files in this directory were extracted from the "sha1-vectors.zip" -archive, which is publicly available through the National Institute -of Standards and Technology (NIST) website at the following URL: - - http://csrc.nist.gov/cryptval/shs.html - -The files have been truncated to include only the first 10 test -cases for bit and byte messages. This was done solely to decrease -the size of the module distribution, thereby making downloads much -quicker for users. If a more extensive test run is desired, simply -replace these files by the originals from the above URL. - -NIST advises that the archive file describes "tests and vectors -that can be used to informally verify the correctness of an SHA-1 -implementation. However, use of these vectors does not take the -place of validation obtained through the Cryptographic Module -Validation Program." diff --git a/ext/Digest/SHA/t/nist/Readme.txt b/ext/Digest/SHA/t/nist/Readme.txt deleted file mode 100644 index 0c1fc32..0000000 --- a/ext/Digest/SHA/t/nist/Readme.txt +++ /dev/null @@ -1,82 +0,0 @@ - - Sample Vectors for SHA-1 Testing - - This file describes tests and vectors that can be used in verifying the correctness of -an SHA-1 implementation. However, use of these vectors does not take the place of validation -obtained through the Cryptographic Module Validation Program. - - There are three areas of the Secure Hash Standard for which test vectors are supplied: -short messages of varying length, selected long messages, and pseudorandomly generated messages. -Since it is possible for an implementation to correctly handle the hashing of byte-oriented -messages (and not messages of a non-byte length), the SHS tests each come in two flavors. For -both byte oriented and bit oriented messages, the message lengths are given in bits. - -Type I Test: Messages of Varying Length - - An implementation of the SHS must be able to correctly generate message digests for -messages of arbitrary length. This functionality can be tested by supplying the implementation -with 1025 pseudorandomly generated messages with lengths from 0 to 1024 bits (for an implementation -that only hashes byte-oriented data correctly, 129 messages of length 0, 8, 16, 24,...,1024 bits -will be supplied). - -Type II Test: Selected Long Messages - - Additional testing of an implementation can be performed by testing that the implementation -can correctly generate digests for longer messages. A list of 100 messages, each of length > 1024, -is supplied. These can be used to verify the hashing of longer message lengths. For bit oriented -testing the messages are from 1025 to 103425 bits long (length=1025+i*1024, where 0<=i<100). For -byte oriented testing the messages are from 1032 to 103432 (length=1032+i*1024, where 0<=i<100). - -Type III Test: Pseudorandomly Generated Messages - - This test determines whether the implementation can compute message digests for messages -that are generated using a given seed. A sequence of 100 message digests is generated using this -seed. The digests are generated according to the following pseudocode: - -procedure MonteCarlo(string SEED) -{ - integer i, j, a; - string M; - - M := SEED; - for j = 0 to 99 do { - for i = 1 to 50000 do { - for a = 1 to (j/4*8 + 24) do M := M || ’0’; /*‘0' is the binary zero bit. */ - M := M || i; /* Here, the value for ‘i’ is expressed as a 32-bit word - and concatenated with ‘M’. The first bit - concatenated with ‘M’ is the most significant bit of - this 32-bit word. */ - M := SHA(M); - } - print(M); - } - } - -NOTE: In the above procedure, || denotes concatenation. Also, M || i denotes appending the 32-bit -word representing the value ‘i’, as defined in section 2 of the SHS. Within the procedure, M is a string -of variable length. The initial length of 416 bits ensures that the length of M never exceeds 512 bits -during execution of the above procedure, and it ensures that messages will be of a byte length. Each -element printed should be 160 bits in length. - - -File formats: - -There are two files included for each test type (bit-oriented and byte-oriented). One file contains -the messages and the other file contains the hashes. - -The message files provided use "compact strings" to store the message values. Compact strings are -used to represented the messages in a compact form. A compact string has the form - z || b || n(1) || n(2) || ... || n(z) -where z>=0 that represents the number of n, b is either 0 or 1, and each n(i) is a decimal integer -representing a positive number. The length of the compact string is given by the summation of the n(i). - -The compact string is interpreted as the representation of the bit string consisting of b repeated n(1) times, -followed by 1-b repeated n(2) times, followed by b repeated n(3) times, and so on. - -Example: - M = 5 1 7 13 5 1 2 - where z = 5 and b = 1. Then the compact string M represents the bit string - 1111111000000000000011111011 - where 1 is repeated 7 times, 0 is repeated 13 times, 1 is repeated 5 times, - 0 is repeated 1 time, and 1 is repeated 2 times. - diff --git a/ext/Digest/SHA/t/nist/bit-hashes.sha1 b/ext/Digest/SHA/t/nist/bit-hashes.sha1 deleted file mode 100644 index b405ce1..0000000 --- a/ext/Digest/SHA/t/nist/bit-hashes.sha1 +++ /dev/null @@ -1,14 +0,0 @@ -# Configuration information for "SHA-1 Test" -# SHA tests are configured for BIT oriented implementations -H>SHS Type 1 Hashes -DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^ -59C4526AA2CC59F9A5F56B5579BA7108E7CCB61A ^ -6E42FB84067CFF056C43A49E484997AF23190879 ^ -C63FBB9A87171A176E6E054890E29A8C5F125F6C ^ -3109E33C1C4B9A0169D1599169D0E5A520A1E71C ^ -9195E1E73CC68D7170F44BD1D83CB624BC87FA0B ^ -64F7C374527278C0436DBC8DE5AABEC2BBF634BC ^ -154B622EA426FB151B1FF1BE1CE871752B9EDEB4 ^ -12BDD00FD4038756CBCF8ECDAD1B0CD862603CD8 ^ -6700F93E1691E83735279E167F67AF61FEE9813B ^ diff --git a/ext/Digest/SHA/t/nist/bit-messages.sha1 b/ext/Digest/SHA/t/nist/bit-messages.sha1 deleted file mode 100644 index 8e97b02..0000000 --- a/ext/Digest/SHA/t/nist/bit-messages.sha1 +++ /dev/null @@ -1,14 +0,0 @@ -# Configuration information for "SHA-1 Test" -# SHA tests are configured for BIT oriented implementations -H>SHS Type 1 Strings -0 1 ^ -1 1 1 ^ -2 1 1 1 ^ -3 0 1 1 1 ^ -2 0 2 2 ^ -4 1 1 1 2 1 ^ -3 0 2 2 2 ^ -4 1 1 2 2 2 ^ -5 1 2 2 1 1 2 ^ -5 0 2 2 1 1 3 ^ diff --git a/ext/Digest/SHA/t/nist/byte-hashes.sha1 b/ext/Digest/SHA/t/nist/byte-hashes.sha1 deleted file mode 100644 index 9aef69f..0000000 --- a/ext/Digest/SHA/t/nist/byte-hashes.sha1 +++ /dev/null @@ -1,14 +0,0 @@ -# Configuration information for "SHA-1 Test" -# SHA tests are configured for BYTE oriented implementations -H>SHS Type 1 Hashes -DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^ -3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5 ^ -19C1E2048FA7393CFBF2D310AD8209EC11D996E5 ^ -CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5 ^ -71AC973D0E4B50AE9E5043FF4D615381120A25A0 ^ -A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA ^ -D87A0EE74E4B9AD72E6847C87BDEEB3D07844380 ^ -1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD ^ -5A78F439B6DB845BB8A558E4CEB106CD7B7FF783 ^ -F871BCE62436C1E280357416695EE2EF9B83695C ^ diff --git a/ext/Digest/SHA/t/nist/byte-messages.sha1 b/ext/Digest/SHA/t/nist/byte-messages.sha1 deleted file mode 100644 index 6a3fc2f..0000000 --- a/ext/Digest/SHA/t/nist/byte-messages.sha1 +++ /dev/null @@ -1,14 +0,0 @@ -# Configuration information for "SHA-1 Test" -# SHA tests are configured for BYTE oriented implementations -H>SHS Type 1 Strings -0 1 ^ -5 0 2 1 2 1 2 ^ -5 0 1 3 4 4 4 ^ -7 0 4 3 4 4 1 4 4 ^ -10 0 4 1 5 3 4 4 3 1 3 4 ^ -10 0 3 1 6 5 5 1 3 6 6 4 ^ -13 1 3 2 5 3 3 3 4 6 6 1 4 6 2 ^ -16 1 3 5 5 1 2 1 3 3 6 3 5 2 3 5 7 2 ^ -15 1 8 1 5 3 2 7 4 5 6 7 3 3 1 6 3 ^ -15 1 4 6 8 2 1 4 2 5 1 6 8 8 6 4 7 ^ diff --git a/ext/Digest/SHA/t/nistbit.t b/ext/Digest/SHA/t/nistbit.t new file mode 100644 index 0000000..e64527d --- /dev/null +++ b/ext/Digest/SHA/t/nistbit.t @@ -0,0 +1,72 @@ +# Test against SHA-1 Sample Vectors from NIST +# +# ref: http://csrc.nist.gov/cryptval/shs.html + +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my $nist_hashes = <new(1); +for (@lines) { + next unless /^[\d ^]/; + $message .= $_; + next unless /\^\s*$/; + my @vals = $message =~ /\d+/g; $message = ""; + my $count = shift(@vals); + my $bit = shift(@vals); + my $bitstr = ""; + while (@vals) { + $bitstr .= $bit x shift(@vals); + $bit = 1 - $bit; + } + print "not " unless uc($sha->add_bits($bitstr)->hexdigest) + eq shift(@hashes); + print "ok ", $testnum++, "\n"; +} diff --git a/ext/Digest/SHA/t/nistbyte.t b/ext/Digest/SHA/t/nistbyte.t new file mode 100644 index 0000000..84ce722 --- /dev/null +++ b/ext/Digest/SHA/t/nistbyte.t @@ -0,0 +1,73 @@ +# Test against SHA-1 Sample Vectors from NIST +# +# ref: http://csrc.nist.gov/cryptval/shs.html + +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw()); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my $nist_hashes = <new(1); +for (@lines) { + next unless /^[\d ^]/; + $message .= $_; + next unless /\^\s*$/; + my @vals = $message =~ /\d+/g; $message = ""; + my $count = shift(@vals); + my $bit = shift(@vals); + my $bitstr = ""; + while (@vals) { + $bitstr .= $bit x shift(@vals); + $bit = 1 - $bit; + } + print "not " unless + uc($sha->add(pack("B*", $bitstr))->hexdigest) + eq shift(@hashes); + print "ok ", $testnum++, "\n"; +} diff --git a/ext/Digest/SHA/t/5-hmac-rfc2202.t b/ext/Digest/SHA/t/rfc2202.t similarity index 50% rename from ext/Digest/SHA/t/5-hmac-rfc2202.t rename to ext/Digest/SHA/t/rfc2202.t index f441b61..2837ab6 100644 --- a/ext/Digest/SHA/t/5-hmac-rfc2202.t +++ b/ext/Digest/SHA/t/rfc2202.t @@ -1,7 +1,12 @@ -use Test; use strict; -use integer; -use Digest::SHA qw(hmac_sha1_hex); + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(hmac_sha1_hex)); +} BEGIN { if ($ENV{PERL_CORE}) { @@ -10,32 +15,22 @@ BEGIN { } } -my(@vec); +my @data = map { eval } ; -BEGIN { - @vec = ( -"Hi There", -"what do ya want for nothing?", -chr(0xdd) x 50, -chr(0xcd) x 50, -"Test With Truncation", -"Test Using Larger Than Block-Size Key - Hash Key First", -"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" - ); - plan tests => scalar(@vec); -} +my $numtests = scalar @data; +print "1..$numtests\n"; my @keys = ( chr(0x0b) x 20, "Jefe", chr(0xaa) x 20, - "", + join("", map { chr } (1 .. 25)), chr(0x0c) x 20, chr(0xaa) x 80, chr(0xaa) x 80 ); -my @hmac1rsp = ( +my @out = ( "b617318655057264e28bc0b6fb378c8ef146be00", "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", "125d7342b9ac11cd91a39af48aa17b4f63f175d3", @@ -45,12 +40,18 @@ my @hmac1rsp = ( "e8e99d0f45237d786d6bbaa7965c7808bbff1a91" ); -my $i = 0x01; -$keys[3] .= chr($i++) while (length($keys[3]) < 25); - -for ($i = 0; $i < @vec; $i++) { - ok( - hmac_sha1_hex($vec[$i], $keys[$i]), - $hmac1rsp[$i] - ); +my $testnum = 1; +while (@data) { + print "not " unless hmac_sha1_hex(shift @data, shift @keys) + eq shift @out; + print "ok ", $testnum++, "\n"; } + +__DATA__ +"Hi There" +"what do ya want for nothing?" +chr(0xdd) x 50 +chr(0xcd) x 50 +"Test With Truncation" +"Test Using Larger Than Block-Size Key - Hash Key First" +"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" diff --git a/ext/Digest/SHA/t/sha1.t b/ext/Digest/SHA/t/sha1.t new file mode 100644 index 0000000..b3984b7 --- /dev/null +++ b/ext/Digest/SHA/t/sha1.t @@ -0,0 +1,37 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha1_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @vecs = map { eval } ; +$#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; + +my $numtests = scalar(@vecs) / 2; +print "1..$numtests\n"; + +for (1 .. $numtests) { + my $data = shift @vecs; + my $digest = shift @vecs; + print "not " unless sha1_hex($data) eq $digest; + print "ok ", $_, "\n"; +} + +__DATA__ +"abc" +"a9993e364706816aba3e25717850c26c9cd0d89d" +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +"84983e441c3bd26ebaae4aa1f95129e5e54670f1" +"a" x 1000000 +"34aa973cd4c4daa4f61eeb2bdbad27316534016f" diff --git a/ext/Digest/SHA/t/sha224.t b/ext/Digest/SHA/t/sha224.t new file mode 100644 index 0000000..1b6abe3 --- /dev/null +++ b/ext/Digest/SHA/t/sha224.t @@ -0,0 +1,37 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha224_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @vecs = map { eval } ; +$#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; + +my $numtests = scalar(@vecs) / 2; +print "1..$numtests\n"; + +for (1 .. $numtests) { + my $data = shift @vecs; + my $digest = shift @vecs; + print "not " unless sha224_hex($data) eq $digest; + print "ok ", $_, "\n"; +} + +__DATA__ +"abc" +"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" +"a" x 1000000 +"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" diff --git a/ext/Digest/SHA/t/sha256.t b/ext/Digest/SHA/t/sha256.t new file mode 100644 index 0000000..91f4457 --- /dev/null +++ b/ext/Digest/SHA/t/sha256.t @@ -0,0 +1,37 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha256_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @vecs = map { eval } ; +$#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; + +my $numtests = scalar(@vecs) / 2; +print "1..$numtests\n"; + +for (1 .. $numtests) { + my $data = shift @vecs; + my $digest = shift @vecs; + print "not " unless sha256_hex($data) eq $digest; + print "ok ", $_, "\n"; +} + +__DATA__ +"abc" +"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" +"a" x 1000000 +"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" diff --git a/ext/Digest/SHA/t/sha384.t b/ext/Digest/SHA/t/sha384.t new file mode 100644 index 0000000..4d1f6f3 --- /dev/null +++ b/ext/Digest/SHA/t/sha384.t @@ -0,0 +1,41 @@ +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha384_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @vecs = map { eval } ; +$#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; + +my $numtests = scalar(@vecs) / 2; +print "1..$numtests\n"; + +my $skip = sha384_hex("") ? 0 : 1; + +for (1 .. $numtests) { + my $data = shift @vecs; + my $digest = shift @vecs; + unless ($skip) { + print "not " unless sha384_hex($data) eq $digest; + } + print "ok ", $_, $skip ? " # skip: no 64 bit" : "", "\n"; +} + +__DATA__ +"abc" +"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" +"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" +"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039" +"a" x 1000000 +"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985" diff --git a/ext/Digest/SHA/t/2-nist-sha-512.t b/ext/Digest/SHA/t/sha512.t similarity index 51% rename from ext/Digest/SHA/t/2-nist-sha-512.t rename to ext/Digest/SHA/t/sha512.t index c24c5a9..f491703 100644 --- a/ext/Digest/SHA/t/2-nist-sha-512.t +++ b/ext/Digest/SHA/t/sha512.t @@ -1,7 +1,12 @@ -use Test; use strict; -use integer; -use Digest::SHA qw(sha512_hex); + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(sha512_hex)); +} BEGIN { if ($ENV{PERL_CORE}) { @@ -10,26 +15,27 @@ BEGIN { } } -my(@vec, @rsp); - -BEGIN { - @vec = ( -"abc", -"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", -"a" x 1000000 - ); - - @rsp = ( -"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", -"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909", -"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" - ); +my @vecs = map { eval } ; +$#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl"; - plan tests => scalar(@vec); -} +my $numtests = scalar(@vecs) / 2; +print "1..$numtests\n"; my $skip = sha512_hex("") ? 0 : 1; -for (my $i = 0; $i < @vec; $i++) { - skip($skip, sha512_hex($vec[$i]), $rsp[$i]); +for (1 .. $numtests) { + my $data = shift @vecs; + my $digest = shift @vecs; + unless ($skip) { + print "not " unless sha512_hex($data) eq $digest; + } + print "ok ", $_, $skip ? " # skip: no 64 bit" : "", "\n"; } + +__DATA__ +"abc" +"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" +"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" +"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" +"a" x 1000000 +"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" diff --git a/ext/Digest/SHA/t/state/state.1 b/ext/Digest/SHA/t/state/state.1 deleted file mode 100644 index 685db03..0000000 --- a/ext/Digest/SHA/t/state/state.1 +++ /dev/null @@ -1,8 +0,0 @@ -alg:1 -H:9d6f7d2f:65e21307:c6f41af6:7c7fd3a9:8dec6058:00000000:00000000:00000000 -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 -blockcnt:384 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:7920000 diff --git a/ext/Digest/SHA/t/state/state.256 b/ext/Digest/SHA/t/state/state.256 deleted file mode 100644 index 4fad8ed..0000000 --- a/ext/Digest/SHA/t/state/state.256 +++ /dev/null @@ -1,8 +0,0 @@ -alg:256 -H:2d6c0def:4244ade7:fc8c121c:108f4493:ec3fbec2:91425a6e:b8d30d2a:9db24273 -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 -blockcnt:384 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:7920000 diff --git a/ext/Digest/SHA/t/state/state.384 b/ext/Digest/SHA/t/state/state.384 deleted file mode 100644 index 8c1bb59..0000000 --- a/ext/Digest/SHA/t/state/state.384 +++ /dev/null @@ -1,8 +0,0 @@ -alg:384 -H:598147f4583a61f7:8d194a4d7c9008cb:39725c96557d600f:d7f2079ce8251f19:bd735d446f9a3c7c:234de90b9060898d:a5b481b9d635d190:81c6e74ee4556125 -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 -blockcnt:384 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:7920000 diff --git a/ext/Digest/SHA/t/state/state.512 b/ext/Digest/SHA/t/state/state.512 deleted file mode 100644 index 444b2ec..0000000 --- a/ext/Digest/SHA/t/state/state.512 +++ /dev/null @@ -1,8 +0,0 @@ -alg:512 -H:0442fe29a02b8c30:13553e6dbedc2aa0:8f891a0cb2ac3107:6fa1762b40ac04dd:dcbf420d729eea79:34703e9672dcf145:7bf9aaa14d400433:2aa65f044825466d -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 -blockcnt:384 -lenhh:0 -lenhl:0 -lenlh:0 -lenll:7920000 diff --git a/ext/Digest/SHA/t/woodbury.t b/ext/Digest/SHA/t/woodbury.t new file mode 100644 index 0000000..b8a9145 --- /dev/null +++ b/ext/Digest/SHA/t/woodbury.t @@ -0,0 +1,143 @@ +# Test Vectors for HMAC-SHA-256/384/512 +# +# Vectors and initial script courtesy of Adam Woodbury, The MITRE Corporation + +use strict; + +my $MODULE; + +BEGIN { + $MODULE = (-e "SHA.pm") ? "Digest::SHA" : "Digest::SHA::PurePerl"; + eval "require $MODULE" || die $@; + $MODULE->import(qw(hmac_sha256_hex hmac_sha384_hex hmac_sha512_hex)); +} + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = '../lib'; + } +} + +my @plex = map { eval } ; + +my $numtests = scalar(@plex) / 3; +print "1..$numtests\n"; + +# Use RFC 2202 data/key values for 512-bit blocks + +my @data_bs512 = splice(@plex, 0, 7); +my @keys_bs512 = splice(@plex, 0, 7); +my @hmac256rsp = splice(@plex, 0, 7); + +# Lengthen final RFC 2202 data/key values for 1024-bit blocks + +my @data_bs1024 = splice(@plex, 0, 7); +my @keys_bs1024 = splice(@plex, 0, 7); +my @hmac384rsp = splice(@plex, 0, 7); + +my @dat2_bs1024 = splice(@plex, 0, 7); +my @key2_bs1024 = splice(@plex, 0, 7); +my @hmac512rsp = splice(@plex, 0, 7); + +my $testnum = 1; + +while (@data_bs512) { + print "not " unless + hmac_sha256_hex(shift @data_bs512, shift @keys_bs512) + eq shift @hmac256rsp; + print "ok ", $testnum++, "\n"; +} + +my $skip = hmac_sha384_hex("", "") ? 0 : 1; + +while (@data_bs1024) { + if ($skip) { + print "ok ", $testnum++, + $skip ? " # skip: no 64 bit" : "", "\n"; + shift @data_bs1024; + next; + } + print "not " unless + hmac_sha384_hex(shift @data_bs1024, shift @keys_bs1024) + eq shift @hmac384rsp; + print "ok ", $testnum++, "\n"; +} + +while (@dat2_bs1024) { + if ($skip) { + print "ok ", $testnum++, + $skip ? " # skip: no 64 bit" : "", "\n"; + shift @dat2_bs1024; + next; + } + print "not " unless + hmac_sha512_hex(shift @dat2_bs1024, shift @key2_bs1024) + eq shift @hmac512rsp; + print "ok ", $testnum++, "\n"; +} + +__DATA__ +"Hi There" +"what do ya want for nothing?" +chr(0xdd) x 50 +chr(0xcd) x 50 +"Test With Truncation" +"Test Using Larger Than Block-Size Key - Hash Key First" +"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data" +chr(0x0b) x 20 +"Jefe" +chr(0xaa) x 20 +join("", map { chr } (1 .. 25)) +chr(0x0c) x 20 +chr(0xaa) x 80 +chr(0xaa) x 80 +"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7" +"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843" +"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe" +"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b" +"a3b6167473100ee06e0c796c2955552bfa6f7c0a6a8aef8b93f860aab0cd20c5" +"6953025ed96f0c09f80a96f78e6538dbe2e7b820e3dd970e7ddd39091b32352f" +"6355ac22e890d0a3c8481a5ca4825bc884d3e7a1ff98a2fc2ac7d8e064c3b2e6" +"Hi There" +"what do ya want for nothing?" +chr(0xdd) x 50 +chr(0xcd) x 50 +"Test With Truncation" +"Test Using Larger Than Block-Size Key - Hash Key First" +"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data. The Larger Block-Sizes Make For Much Longer Test Vectors" +chr(0x0b) x 20 +"Jefe" +chr(0xaa) x 20 +join("", map { chr } (1 .. 25)) +chr(0x0c) x 20 +chr(0xaa) x 200 +chr(0xaa) x 200 +"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6" +"af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649" +"88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27" +"3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb" +"3abf34c3503b2a23a46efc619baef897f4c8e42c934ce55ccbae9740fcbc1af4ca62269e2a37cd88ba926341efe4aeea" +"ec629fe0dc1fab504fc1c89572d6573cf15c3a4b5b69d53f0c13849561a6c13e153af48d2538ce056a3fe10d69da16c3" +"07109d2c6c2fdcac39c3a8b5f36fc9a69e029d3d8647cc3e4ddb77888418c5c09d807942e5f96d17ee9fd46aed64b7f2" +"Hi There" +"what do ya want for nothing?" +chr(0xdd) x 50 +chr(0xcd) x 50 +"Test With Truncation" +"Test Using Larger Than Block-Size Key - Hash Key First" +"Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data. The Larger Block-Sizes Make For Much Longer Test Vectors" +chr(0x0b) x 20 +"Jefe" +chr(0xaa) x 20 +join("", map { chr } (1 .. 25)) +chr(0x0c) x 20 +chr(0xaa) x 200 +chr(0xaa) x 200 +"87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854" +"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737" +"fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb" +"b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd" +"415fad6271580a531d4179bc891d87a650188707922a4fbb36663a1eb16da008711c5b50ddd0fc235084eb9d3364a1454fb2ef67cd1d29fe6773068ea266e96b" +"9dc6330f4c966b62b735d565343cb77413deccdf42a92d9ef5e4e2ae33f6c924bbc8e34c47111bc069482d4dbcfee148419a6547f2d01500e8160b39cc2e4ae8" +"396ed3a17cef82cddbd987ea66a5dd1f38b68167df31f049463b85fa10b531d0e90d1052f8c9c7cda263468ec3f980a8fec06213c2944c92a0ac95a2d8ade76d"