r70328 - in /branches/upstream/libdigest-sha-perl/current: Changes MANIFEST META.yml Makefile.PL README SHA.xs lib/Digest/SHA.pm shasum src/hmac.c src/hmac.h src/sha.c src/sha.h src/sha64bit.c t/fips180-4.t

carnil at users.alioth.debian.org carnil at users.alioth.debian.org
Fri Mar 4 07:02:28 UTC 2011


Author: carnil
Date: Fri Mar  4 07:01:43 2011
New Revision: 70328

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=70328
Log:
[svn-upgrade] new version libdigest-sha-perl (5.60)

Added:
    branches/upstream/libdigest-sha-perl/current/t/fips180-4.t
Modified:
    branches/upstream/libdigest-sha-perl/current/Changes
    branches/upstream/libdigest-sha-perl/current/MANIFEST
    branches/upstream/libdigest-sha-perl/current/META.yml
    branches/upstream/libdigest-sha-perl/current/Makefile.PL
    branches/upstream/libdigest-sha-perl/current/README
    branches/upstream/libdigest-sha-perl/current/SHA.xs
    branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm
    branches/upstream/libdigest-sha-perl/current/shasum
    branches/upstream/libdigest-sha-perl/current/src/hmac.c
    branches/upstream/libdigest-sha-perl/current/src/hmac.h
    branches/upstream/libdigest-sha-perl/current/src/sha.c
    branches/upstream/libdigest-sha-perl/current/src/sha.h
    branches/upstream/libdigest-sha-perl/current/src/sha64bit.c

Modified: branches/upstream/libdigest-sha-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/Changes?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/Changes (original)
+++ branches/upstream/libdigest-sha-perl/current/Changes Fri Mar  4 07:01:43 2011
@@ -1,4 +1,11 @@
 Revision history for Perl extension Digest::SHA.
+
+5.60  Thu Mar  3 05:26:42 MST 2011
+	- added new SHA-512/224 and SHA-512/256 transforms
+		-- ref. NIST Draft FIPS 180-4 (February 2011)
+	- simplified shasum by removing duplicative text
+	- improved efficiency of Addfile
+		-- expensive -T test now occurs only in portable mode
 
 5.50  Tue Dec 14 06:20:08 MST 2010
 	- adopted convention that '-' always means STDIN

Modified: branches/upstream/libdigest-sha-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/MANIFEST?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/MANIFEST (original)
+++ branches/upstream/libdigest-sha-perl/current/MANIFEST Fri Mar  4 07:01:43 2011
@@ -19,6 +19,7 @@
 t/base64.t
 t/bitbuf.t
 t/dumpload.t
+t/fips180-4.t
 t/fips198.t
 t/gg.t
 t/gglong.t

Modified: branches/upstream/libdigest-sha-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/META.yml?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/META.yml (original)
+++ branches/upstream/libdigest-sha-perl/current/META.yml Fri Mar  4 07:01:43 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name: Digest-SHA
-version: 5.50
+version: 5.60
 abstract: Perl extension for SHA-1/224/256/384/512
 license: perl
 author:
@@ -10,7 +10,7 @@
 provides:
   Digest::SHA:
     file: lib/Digest/SHA.pm
-    version: 5.50
+    version: 5.60
 meta-spec:
   version: 1.3
   url: http://module-build.sourceforge.net/META-spec-v1.3.html

Modified: branches/upstream/libdigest-sha-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/Makefile.PL?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/Makefile.PL (original)
+++ branches/upstream/libdigest-sha-perl/current/Makefile.PL Fri Mar  4 07:01:43 2011
@@ -1,5 +1,6 @@
 require 5.003000;
 
+use strict;
 use ExtUtils::MakeMaker;
 use Getopt::Std;
 use Config;

Modified: branches/upstream/libdigest-sha-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/README?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/README (original)
+++ branches/upstream/libdigest-sha-perl/current/README Fri Mar  4 07:01:43 2011
@@ -1,4 +1,4 @@
-Digest::SHA version 5.50
+Digest::SHA version 5.60
 ========================
 
 Digest::SHA is a complete implementation of the NIST Secure Hash
@@ -34,7 +34,7 @@
 
 COPYRIGHT AND LICENSE
 
-Copyright (C) 2003-2010 Mark Shelor
+Copyright (C) 2003-2011 Mark Shelor
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.

Modified: branches/upstream/libdigest-sha-perl/current/SHA.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/SHA.xs?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/SHA.xs (original)
+++ branches/upstream/libdigest-sha-perl/current/SHA.xs Fri Mar  4 07:01:43 2011
@@ -6,7 +6,8 @@
 #include "src/hmac.c"
 
 static int ix2alg[] =
-	{1,1,1,224,224,224,256,256,256,384,384,384,512,512,512};
+	{1,1,1,224,224,224,256,256,256,384,384,384,512,512,512,
+	512224,512224,512224,512256,512256,512256};
 
 MODULE = Digest::SHA		PACKAGE = Digest::SHA
 
@@ -68,6 +69,12 @@
 	Digest::SHA::sha512 = 12
 	Digest::SHA::sha512_hex = 13
 	Digest::SHA::sha512_base64 = 14
+	Digest::SHA::sha512224 = 15
+	Digest::SHA::sha512224_hex = 16
+	Digest::SHA::sha512224_base64 = 17
+	Digest::SHA::sha512256 = 18
+	Digest::SHA::sha512256_hex = 19
+	Digest::SHA::sha512256_base64 = 20
 PREINIT:
 	int i;
 	unsigned char *data;
@@ -113,6 +120,12 @@
 	Digest::SHA::hmac_sha512 = 12
 	Digest::SHA::hmac_sha512_hex = 13
 	Digest::SHA::hmac_sha512_base64 = 14
+	Digest::SHA::hmac_sha512224 = 15
+	Digest::SHA::hmac_sha512224_hex = 16
+	Digest::SHA::hmac_sha512224_base64 = 17
+	Digest::SHA::hmac_sha512256 = 18
+	Digest::SHA::hmac_sha512256_hex = 19
+	Digest::SHA::hmac_sha512256_base64 = 20
 PREINIT:
 	int i;
 	unsigned char *key;

Modified: branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm (original)
+++ branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm Fri Mar  4 07:01:43 2011
@@ -7,7 +7,7 @@
 use Fcntl;
 use integer;
 
-$VERSION = '5.50';
+$VERSION = '5.60';
 
 require Exporter;
 require DynaLoader;
@@ -18,11 +18,15 @@
 	hmac_sha256	hmac_sha256_base64	hmac_sha256_hex
 	hmac_sha384	hmac_sha384_base64	hmac_sha384_hex
 	hmac_sha512	hmac_sha512_base64	hmac_sha512_hex
+	hmac_sha512224	hmac_sha512224_base64	hmac_sha512224_hex
+	hmac_sha512256	hmac_sha512256_base64	hmac_sha512256_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);
+	sha512		sha512_base64		sha512_hex
+	sha512224	sha512224_base64	sha512224_hex
+	sha512256	sha512256_base64	sha512256_hex);
 
 # If possible, inherit from Digest::base (which depends on MIME::Base64)
 
@@ -112,17 +116,16 @@
 
 	$mode = defined($mode) ? $mode : "";
 	my ($binary, $portable) = map { $_ eq $mode } ("b", "p");
-	my $text = -T $file;
 
 		## Always interpret "-" to mean STDIN; otherwise use
 		## sysopen to handle full range of POSIX file names
 	local *FH;
-	$file eq '-' and open(FH, '< -') 
+	$file eq '-' and open(FH, '< -')
 		or sysopen(FH, $file, O_RDONLY)
 			or _bail('Open failed');
 	binmode(FH) if $binary || $portable;
 
-	unless ($portable && $text) {
+	unless ($portable && -T $file) {
 		$self->_addfile(*FH);
 		close(FH);
 		return($self);
@@ -235,11 +238,10 @@
 
 =head1 ABSTRACT
 
-Digest::SHA is a complete implementation of the NIST Secure Hash
-Standard.  It gives Perl programmers a convenient way to calculate
-SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 message digests.
-The module can handle all types of input, including partial-byte
-data.
+Digest::SHA is a complete implementation of the NIST Secure Hash Standard.
+It gives Perl programmers a convenient way to calculate SHA-1, SHA-224,
+SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256 message digests.
+The module can handle all types of input, including partial-byte data.
 
 =head1 DESCRIPTION
 
@@ -374,6 +376,10 @@
 
 =item B<sha512($data, ...)>
 
+=item B<sha512224($data, ...)>
+
+=item B<sha512256($data, ...)>
+
 Logically joins the arguments into a single string, and returns
 its SHA-1/224/256/384/512 digest encoded as a binary string.
 
@@ -387,6 +393,10 @@
 
 =item B<sha512_hex($data, ...)>
 
+=item B<sha512224_hex($data, ...)>
+
+=item B<sha512256_hex($data, ...)>
+
 Logically joins the arguments into a single string, and returns
 its SHA-1/224/256/384/512 digest encoded as a hexadecimal string.
 
@@ -399,6 +409,10 @@
 =item B<sha384_base64($data, ...)>
 
 =item B<sha512_base64($data, ...)>
+
+=item B<sha512224_base64($data, ...)>
+
+=item B<sha512256_base64($data, ...)>
 
 Logically joins the arguments into a single string, and returns
 its SHA-1/224/256/384/512 digest encoded as a Base64 string.
@@ -578,6 +592,10 @@
 
 =item B<hmac_sha512($data, $key)>
 
+=item B<hmac_sha512224($data, $key)>
+
+=item B<hmac_sha512256($data, $key)>
+
 Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
 with the result encoded as a binary string.  Multiple I<$data>
 arguments are allowed, provided that I<$key> is the last argument
@@ -593,6 +611,10 @@
 
 =item B<hmac_sha512_hex($data, $key)>
 
+=item B<hmac_sha512224_hex($data, $key)>
+
+=item B<hmac_sha512256_hex($data, $key)>
+
 Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
 with the result encoded as a hexadecimal string.  Multiple I<$data>
 arguments are allowed, provided that I<$key> is the last argument
@@ -608,6 +630,10 @@
 
 =item B<hmac_sha512_base64($data, $key)>
 
+=item B<hmac_sha512224_base64($data, $key)>
+
+=item B<hmac_sha512256_base64($data, $key)>
+
 Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
 with the result encoded as a Base64 string.  Multiple I<$data>
 arguments are allowed, provided that I<$key> is the last argument
@@ -624,9 +650,9 @@
 
 L<Digest>, L<Digest::SHA::PurePerl>
 
-The Secure Hash Standard (FIPS PUB 180-2) can be found at:
-
-L<http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf>
+The Secure Hash Standard (Draft FIPS PUB 180-4) can be found at:
+
+L<http://csrc.nist.gov/publications/drafts/fips180-4/Draft-FIPS180-4_Feb2011.pdf>
 
 The Keyed-Hash Message Authentication Code (HMAC):
 
@@ -658,11 +684,13 @@
 	Gunnar Wolf
 	Adam Woodbury
 
-for their valuable comments and suggestions.
+"who by trained skill rescued life from such great billows and such thick
+darkness and moored it in so perfect a calm and in so brilliant a light"
+- Lucretius
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2003-2010 Mark Shelor
+Copyright (C) 2003-2011 Mark Shelor
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.

Modified: branches/upstream/libdigest-sha-perl/current/shasum
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/shasum?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/shasum (original)
+++ branches/upstream/libdigest-sha-perl/current/shasum Fri Mar  4 07:01:43 2011
@@ -2,10 +2,16 @@
 
 	## shasum: filter for computing SHA digests (ref. sha1sum/md5sum)
 	##
-	## Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
+	## Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
 	##
-	## Version: 5.50
-	## Tue Dec 14 06:20:08 MST 2010
+	## Version: 5.60
+	## Thu Mar  3 05:26:42 MST 2011
+
+	## shasum SYNOPSIS adapted from GNU Coreutils sha1sum.
+	## Include an "-a" option for algorithm selection, and a
+	## "-p" option for portable digest computation.
+
+my $POD = <<'END_OF_POD';
 
 =head1 NAME
 
@@ -13,38 +19,41 @@
 
 =head1 SYNOPSIS
 
- Usage: shasum [OPTION] [FILE]...
-    or: shasum [OPTION] --check [FILE]
+ Usage: shasum [OPTION]... [FILE]...
  Print or check SHA checksums.
  With no FILE, or when FILE is -, read standard input.
 
-  -a, --algorithm    1 (default), 224, 256, 384, 512
-  -b, --binary       read files in binary mode (default on DOS/Windows)
-  -c, --check        check SHA sums against given list
-  -p, --portable     read files in portable mode
+   -a, --algorithm   1 (default), 224, 256, 384, 512, 512224, 512256
+   -b, --binary      read in binary mode
+   -c, --check       read SHA sums from the FILEs and check them
+   -p, --portable    read files in portable mode
                          produces same digest on Windows/Unix/Mac
-  -t, --text         read files in text mode (default)
+   -t, --text        read in text mode (default)
 
  The following two options are useful only when verifying checksums:
-
-  -s, --status       don't output anything, status code shows success
-  -w, --warn         warn about improperly formatted SHA checksum lines
-
-  -h, --help         display this help and exit
-  -v, --version      output version information and exit
-
- The sums are computed as described in FIPS PUB 180-2.  When checking,
- the input should be a former output of this program.  The default mode
- is to print a line with checksum, a character indicating type (`*'
- for binary, `?' for portable, ` ' for text), and name for each FILE.
+   -s, --status      don't output anything, status code shows success
+   -w, --warn        warn about improperly formatted checksum lines
+
+   -h, --help        display this help and exit
+   -v, --version     output version information and exit
+
+ When verifying SHA-512/224 or SHA-512/256 checksums, indicate the
+ algorithm explicitly using the -a option, e.g.
+
+   shasum -a 512224 -c checksumfile
+
+ The sums are computed as described in FIPS-180-4.  When checking, the
+ input should be a former output of this program.  The default mode is to
+ print a line with checksum, a character indicating type (`*' for binary,
+ ` ' for text, `?' for portable), and name for each FILE.
+
+ Report shasum bugs to mshelor at cpan.org
 
 =head1 DESCRIPTION
 
-The I<shasum> 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<shasum> through files, standard input, or both.
+Running I<shasum> is often the quickest way to compute SHA message
+digests.  The user simply feeds data to the script through files or
+standard input, and then collects the results from standard output.
 
 The following command shows how easy it is to compute digests for typical
 inputs such as the NIST test vector "abc":
@@ -55,30 +64,32 @@
 
 	perl -e "print qq(abc)" | shasum -a 256
 
-Since I<shasum> uses the same interface employed by the familiar
-I<sha1sum> program (and its somewhat outmoded anscestor I<md5sum>),
+Since I<shasum> mimics the behavior of the combined GNU I<sha1sum>,
+I<sha224sum>, I<sha256sum>, I<sha384sum>, and I<sha512sum> programs,
 you can install this script as a convenient drop-in replacement.
 
 =head1 AUTHOR
 
-Copyright (c) 2003-2010 Mark Shelor <mshelor at cpan.org>.
+Copyright (c) 2003-2011 Mark Shelor <mshelor at cpan.org>.
 
 =head1 SEE ALSO
 
-shasum is implemented using the Perl module L<Digest::SHA> or
+I<shasum> is implemented using the Perl module L<Digest::SHA> or
 L<Digest::SHA::PurePerl>.
 
 =cut
 
+END_OF_POD
+
 use strict;
-use FileHandle;
+use Fcntl;
 use Getopt::Long;
 
-my $VERSION = "5.50";
-
-
-	## Try to use Digest::SHA, since it's faster.  If not installed,
-	## use Digest::SHA::PurePerl instead.
+my $VERSION = "5.60";
+
+
+	## Try to use Digest::SHA.  If not installed, use the slower
+	## but functionally equivalent Digest::SHA::PurePerl instead.
 
 my $MOD_PREFER = "Digest::SHA";
 my $MOD_SECOND = "Digest::SHA::PurePerl";
@@ -92,10 +103,6 @@
 }
 
 
-	## Usage statement adapted from Ulrich Drepper's md5sum.
-	## Include an "-a" option for algorithm selection,
-	## and a "-p" option for portable digest computation.
-
 sub usage {
 	my($err, $msg) = @_;
 
@@ -104,41 +111,17 @@
 		warn($msg . "Type shasum -h for help\n");
 		exit($err);
 	}
-	print <<'END_OF_USAGE';
-Usage: shasum [OPTION] [FILE]...
-   or: shasum [OPTION] --check [FILE]
-Print or check SHA checksums.
-With no FILE, or when FILE is -, read standard input.
-
-  -a, --algorithm    1 (default), 224, 256, 384, 512
-  -b, --binary       read files in binary mode (default on DOS/Windows)
-  -c, --check        check SHA sums against given list
-  -p, --portable     read files in portable mode
-                         produces same digest on Windows/Unix/Mac
-  -t, --text         read files in text mode (default)
-
-The following two options are useful only when verifying checksums:
-  -s, --status       don't output anything, status code shows success
-  -w, --warn         warn about improperly formatted SHA checksum lines
-
-  -h, --help         display this help and exit
-  -v, --version      output version information and exit
-
-The sums are computed as described in FIPS PUB 180-2.  When checking, the
-input should be a former output of this program.  The default mode is to
-print a line with checksum, a character indicating type (`*' for binary,
-`?' for portable, ` ' for text), and name for each FILE.
-
-Report bugs to <mshelor at cpan.org>.
-END_OF_USAGE
+	my($USAGE) = $POD =~ /SYNOPSIS\n\n(.+)\n=head1 DESCRIPTION\n/sm;
+	$USAGE =~ s/^ //gm;
+	print $USAGE;
 	exit($err);
 }
 
 
 	## Sync stdout and stderr by forcing a flush after every write
 
-autoflush STDOUT 1;
-autoflush STDERR 1;
+select((select(STDOUT), $| = 1)[0]);
+select((select(STDERR), $| = 1)[0]);
 
 
 	## Collect options from command line
@@ -171,7 +154,7 @@
 	## Default to SHA-1 unless overriden by command line option
 
 $alg = 1 unless defined $alg;
-grep { $_ == $alg } (1, 224, 256, 384, 512)
+grep { $_ == $alg } (1, 224, 256, 384, 512, 512224, 512256)
 	or usage(1, "shasum: Unrecognized algorithm\n");
 
 
@@ -214,6 +197,8 @@
 	## %len2alg: maps hex digest length to SHA algorithm
 
 my %len2alg = (40 => 1, 56 => 224, 64 => 256, 96 => 384, 128 => 512);
+$len2alg{56} = 512224 if $alg == 512224;
+$len2alg{64} = 512256 if $alg == 512256;
 
 
 	## unescape: convert backslashed filename to plain filename
@@ -233,11 +218,11 @@
 sub verify {
 	my $checkfile = shift;
 	my ($err, $fmt_errs, $read_errs, $match_errs) = (0, 0, 0, 0);
-	my ($num_lines, $num_files, $num_checksums) = (0, 0, 0);
+	my ($num_lines, $num_files) = (0, 0);
 	my ($bslash, $sum, $fname, $rsp, $digest);
 
 	local *FH;
-	$checkfile eq '-' and open(FH, '< -') 
+	$checkfile eq '-' and open(FH, '< -')
 		and $checkfile = 'standard input'
 	or sysopen(FH, $checkfile, O_RDONLY)
 		or die "shasum: $checkfile: $!\n";
@@ -264,7 +249,6 @@
 			$err = 1; $read_errs++;
 		}
 		else {
-			$num_checksums++;
 			if (lc($sum) eq $digest) { $rsp .= "OK\n" }
 			else { $rsp .= "FAILED\n"; $err = 1; $match_errs++ }
 		}

Modified: branches/upstream/libdigest-sha-perl/current/src/hmac.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/hmac.c?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/hmac.c (original)
+++ branches/upstream/libdigest-sha-perl/current/src/hmac.c Fri Mar  4 07:01:43 2011
@@ -3,10 +3,10 @@
  *
  * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code
  *
- * Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
+ * Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
  *
- * Version: 5.50
- * Tue Dec 14 06:20:08 MST 2010
+ * Version: 5.60
+ * Thu Mar  3 05:26:42 MST 2011
  *
  */
 

Modified: branches/upstream/libdigest-sha-perl/current/src/hmac.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/hmac.h?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/hmac.h (original)
+++ branches/upstream/libdigest-sha-perl/current/src/hmac.h Fri Mar  4 07:01:43 2011
@@ -3,10 +3,10 @@
  *
  * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code
  *
- * Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
+ * Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
  *
- * Version: 5.50
- * Tue Dec 14 06:20:08 MST 2010
+ * Version: 5.60
+ * Thu Mar  3 05:26:42 MST 2011
  *
  */
 
@@ -37,21 +37,27 @@
 
 #ifndef SHA_PERL_MODULE
 
-unsigned char	*hmac1digest	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac1hex	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac1base64	(_HMAC_DATA, _HMAC_KEY);
-unsigned char	*hmac224digest	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac224hex	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac224base64	(_HMAC_DATA, _HMAC_KEY);
-unsigned char	*hmac256digest	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac256hex	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac256base64	(_HMAC_DATA, _HMAC_KEY);
-unsigned char	*hmac384digest	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac384hex	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac384base64	(_HMAC_DATA, _HMAC_KEY);
-unsigned char	*hmac512digest	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac512hex	(_HMAC_DATA, _HMAC_KEY);
-char		*hmac512base64	(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac1digest		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac1hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac1base64		(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac224digest		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac224hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac224base64		(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac256digest		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac256hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac256base64		(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac384digest		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac384hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac384base64		(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac512digest		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512base64		(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac512224digest	(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512224hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512224base64	(_HMAC_DATA, _HMAC_KEY);
+unsigned char	*hmac512256digest	(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512256hex		(_HMAC_DATA, _HMAC_KEY);
+char		*hmac512256base64	(_HMAC_DATA, _HMAC_KEY);
 
 #endif
 

Modified: branches/upstream/libdigest-sha-perl/current/src/sha.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/sha.c?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/sha.c (original)
+++ branches/upstream/libdigest-sha-perl/current/src/sha.c Fri Mar  4 07:01:43 2011
@@ -3,10 +3,10 @@
  *
  * Ref: NIST FIPS PUB 180-2 Secure Hash Standard
  *
- * Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
+ * Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
  *
- * Version: 5.50
- * Tue Dec 14 06:20:08 MST 2010
+ * Version: 5.60
+ * Thu Mar  3 05:26:42 MST 2011
  *
  */
 
@@ -265,6 +265,8 @@
 	else if (s->alg == SHA256) SHA_INIT(256, 256);
 	else if (s->alg == SHA384) SHA_INIT(384, 512);
 	else if (s->alg == SHA512) SHA_INIT(512, 512);
+	else if (s->alg == SHA512224) SHA_INIT(512224, 512);
+	else if (s->alg == SHA512256) SHA_INIT(512256, 512);
 }
 
 /* shaopen: creates a new digest object */
@@ -273,7 +275,8 @@
 	SHA *s;
 
 	if (alg != SHA1 && alg != SHA224 && alg != SHA256 &&
-		alg != SHA384 && alg != SHA512)
+		alg != SHA384    && alg != SHA512 &&
+		alg != SHA512224 && alg != SHA512256)
 		return(NULL);
 	if (alg >= SHA384 && !sha_384_512)
 		return(NULL);

Modified: branches/upstream/libdigest-sha-perl/current/src/sha.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/sha.h?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/sha.h (original)
+++ branches/upstream/libdigest-sha-perl/current/src/sha.h Fri Mar  4 07:01:43 2011
@@ -3,10 +3,10 @@
  *
  * Ref: NIST FIPS PUB 180-2 Secure Hash Standard
  *
- * Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
- *
- * Version: 5.50
- * Tue Dec 14 06:20:08 MST 2010
+ * Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
+ *
+ * Version: 5.60
+ * Thu Mar  3 05:26:42 MST 2011
  *
  */
 
@@ -145,23 +145,29 @@
 	#define SHA_getc		fgetc
 #endif
 
-#define SHA1	1
-#define SHA224	224
-#define SHA256	256
-#define SHA384	384
-#define SHA512	512
+#define SHA1		1
+#define SHA224		224
+#define SHA256		256
+#define SHA384		384
+#define SHA512		512
+#define SHA512224	512224
+#define SHA512256	512256
 
 #define SHA1_BLOCK_BITS		512
 #define SHA224_BLOCK_BITS	SHA1_BLOCK_BITS
 #define SHA256_BLOCK_BITS	SHA1_BLOCK_BITS
 #define SHA384_BLOCK_BITS	1024
 #define SHA512_BLOCK_BITS	SHA384_BLOCK_BITS
+#define SHA512224_BLOCK_BITS	SHA512_BLOCK_BITS
+#define SHA512256_BLOCK_BITS	SHA512_BLOCK_BITS
 
 #define SHA1_DIGEST_BITS	160
 #define SHA224_DIGEST_BITS	224
 #define SHA256_DIGEST_BITS	256
 #define SHA384_DIGEST_BITS	384
 #define SHA512_DIGEST_BITS	512
+#define SHA512224_DIGEST_BITS	224
+#define SHA512256_DIGEST_BITS	256
 
 #define SHA_MAX_BLOCK_BITS	SHA512_BLOCK_BITS
 #define SHA_MAX_DIGEST_BITS	SHA512_DIGEST_BITS
@@ -212,21 +218,27 @@
 
 #ifndef SHA_PERL_MODULE
 
-unsigned char	*sha1digest	(_SHA_DATA);
-char		*sha1hex	(_SHA_DATA);
-char		*sha1base64	(_SHA_DATA);
-unsigned char	*sha224digest	(_SHA_DATA);
-char		*sha224hex	(_SHA_DATA);
-char		*sha224base64	(_SHA_DATA);
-unsigned char	*sha256digest	(_SHA_DATA);
-char		*sha256hex	(_SHA_DATA);
-char		*sha256base64	(_SHA_DATA);
-unsigned char	*sha384digest	(_SHA_DATA);
-char		*sha384hex	(_SHA_DATA);
-char		*sha384base64	(_SHA_DATA);
-unsigned char	*sha512digest	(_SHA_DATA);
-char		*sha512hex	(_SHA_DATA);
-char		*sha512base64	(_SHA_DATA);
+unsigned char	*sha1digest		(_SHA_DATA);
+char		*sha1hex		(_SHA_DATA);
+char		*sha1base64		(_SHA_DATA);
+unsigned char	*sha224digest		(_SHA_DATA);
+char		*sha224hex		(_SHA_DATA);
+char		*sha224base64		(_SHA_DATA);
+unsigned char	*sha256digest		(_SHA_DATA);
+char		*sha256hex		(_SHA_DATA);
+char		*sha256base64		(_SHA_DATA);
+unsigned char	*sha384digest		(_SHA_DATA);
+char		*sha384hex		(_SHA_DATA);
+char		*sha384base64		(_SHA_DATA);
+unsigned char	*sha512digest		(_SHA_DATA);
+char		*sha512hex		(_SHA_DATA);
+char		*sha512base64		(_SHA_DATA);
+unsigned char	*sha512224digest	(_SHA_DATA);
+char		*sha512224hex		(_SHA_DATA);
+char		*sha512224base64	(_SHA_DATA);
+unsigned char	*sha512256digest	(_SHA_DATA);
+char		*sha512256hex		(_SHA_DATA);
+char		*sha512256base64	(_SHA_DATA);
 
 #endif
 

Modified: branches/upstream/libdigest-sha-perl/current/src/sha64bit.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/sha64bit.c?rev=70328&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/sha64bit.c (original)
+++ branches/upstream/libdigest-sha-perl/current/src/sha64bit.c Fri Mar  4 07:01:43 2011
@@ -65,6 +65,20 @@
 C64(0x1f83d9abfb41bd6b), C64(0x5be0cd19137e2179)
 };
 
+static W64 H0512224[8] =	/* SHA-512/224 initial hash value */
+{
+C64(0x8c3d37c819544da2), C64(0x73e1996689dcd4d6), C64(0x1dfab7ae32ff9c82),
+C64(0x679dd514582f9fcf), C64(0x0f6d2b697bd44da8), C64(0x77e36f7304c48942),
+C64(0x3f9d85a86a1d36c8), C64(0x1112e6ad91d692a1)
+
+};
+static W64 H0512256[8] =	/* SHA-512/256 initial hash value */
+{
+C64(0x22312194fc2bf72c), C64(0x9f555fa3c84c64c2), C64(0x2393b86b6f53b151),
+C64(0x963877195940eabd), C64(0x96283ee2a88effe3), C64(0xbe5e1e2553863992),
+C64(0x2b0199fc2c85b8aa), C64(0x0eb72ddc81c52ca2)
+};
+
 /* strto64: converts hex string to a 64-bit word */
 static W64 strto64(char *s)
 {

Added: branches/upstream/libdigest-sha-perl/current/t/fips180-4.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/t/fips180-4.t?rev=70328&op=file
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/t/fips180-4.t (added)
+++ branches/upstream/libdigest-sha-perl/current/t/fips180-4.t Fri Mar  4 07:01:43 2011
@@ -1,0 +1,45 @@
+use strict;
+
+my $MODULE;
+
+BEGIN {
+	$MODULE = (-d "src") ? "Digest::SHA" : "Digest::SHA::PurePerl";
+	eval "require $MODULE" || die $@;
+	$MODULE->import(qw(sha512_hex sha512224_hex sha512256_hex));
+}
+
+BEGIN {
+	if ($ENV{PERL_CORE}) {
+		chdir 't' if -d 't';
+		@INC = '../lib';
+	}
+}
+
+my @vecs = map { eval } <DATA>;
+# $#vecs -= 2 if $MODULE eq "Digest::SHA::PurePerl";
+
+my $numtests = scalar(@vecs) / 2;
+print "1..$numtests\n";
+
+my $skip = sha512_hex("") ? 0 : 1;
+
+for (1 .. $numtests) {
+	my $data = shift @vecs;
+	my $digest = shift @vecs;
+	unless ($skip) {
+		my $rsp = ($_ <= $numtests/2) ?
+			sha512224_hex($data) : sha512256_hex($data);
+		print "not " unless $rsp eq $digest;
+	}
+	print "ok ", $_, $skip ? " # skip: no 64 bit" : "", "\n";
+}
+
+__DATA__
+"abc"
+"4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa"
+"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+"23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9"
+"abc"
+"53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23"
+"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+"3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a"




More information about the Pkg-perl-cvs-commits mailing list