r2830 - in /packages/libdigest-sha-perl/branches/upstream/current: ./ src/ t/ t/nist/

ntyni-guest at users.alioth.debian.org ntyni-guest at users.alioth.debian.org
Thu Jun 1 18:29:02 UTC 2006


Author: ntyni-guest
Date: Thu Jun  1 18:29:01 2006
New Revision: 2830

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2830
Log:
Load /tmp/tmp.wlpBVy3392/libdigest-sha-perl-5.39 into
packages/libdigest-sha-perl/branches/upstream/current.

Modified:
    packages/libdigest-sha-perl/branches/upstream/current/Changes
    packages/libdigest-sha-perl/branches/upstream/current/META.yml
    packages/libdigest-sha-perl/branches/upstream/current/Makefile.PL
    packages/libdigest-sha-perl/branches/upstream/current/README
    packages/libdigest-sha-perl/branches/upstream/current/SHA.pm
    packages/libdigest-sha-perl/branches/upstream/current/SIGNATURE
    packages/libdigest-sha-perl/branches/upstream/current/shasum
    packages/libdigest-sha-perl/branches/upstream/current/src/hmac.c
    packages/libdigest-sha-perl/branches/upstream/current/src/hmac.h
    packages/libdigest-sha-perl/branches/upstream/current/src/sha.c
    packages/libdigest-sha-perl/branches/upstream/current/src/sha.h
    packages/libdigest-sha-perl/branches/upstream/current/t/2-nist-sha-oo.t
    packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-hashes.sha1
    packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-messages.sha1
    packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-hashes.sha1
    packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-messages.sha1

Modified: packages/libdigest-sha-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/Changes?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/Changes (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/Changes Thu Jun  1 18:29:01 2006
@@ -1,4 +1,46 @@
 Revision history for Perl extension Digest::SHA.
+
+5.39  Sun May 28 03:22:24 MST 2006
+	- modified shasum to warn rather than die for file errors
+		-- to follow conventions of GNU sha1sum/md5sum
+
+5.38  Thu May 25 02:02:02 MST 2006
+	- added new capabilities to the "addfile" method
+		-- now able to accept file names as well as handles
+		-- includes mode for portable digest calculation
+			-- thanks to Adam Kennedy for emails and ideas
+				ref. File::LocalizeNewlines
+	- used expanded addfile interface to simplify shasum (sumfile)
+		-- regex a tad less general than 5.37, but handles all
+			known newline variants in UNIX/Windows/MacOS
+	- enhanced WARNING messages from shasum checkfile processing
+		-- to mimic behavior of md5sum
+
+5.37  Mon May  8 04:30:09 MST 2006
+	- modified shasum to avoid file slurping (ref. sub sumfile)
+	- improved error handling of checksum files in shasum
+		-- to better mimic the behavior of md5sum
+	- refined line-break regex in shasum (ref. sub sumfile)
+		-- catches multiple CR's preceding LF
+			thanks to Gisle Aas for suggested patch
+	- changed loop vars to signed int's in shadump (ref. src/sha.c)
+		-- to prevent type mismatch warnings
+
+5.36  Mon May  8 01:38:36 MST 2006
+	- fixed the "portable" option in shasum
+		-- normalize line-breaks in text files only
+
+5.35  Thu May  4 16:54:42 MST 2006
+	- added "portable" option to shasum
+		-- to make digests match across Windows/Unix/MacOS
+	- enabled bundling of shasum command line options
+		-- to mimic behavior of md5sum
+	- removed \r's from text files in t/nist directory
+		-- resolves SIGNATURE clashes (rt.cpan.org #18983)
+	- changed suffix on SHA64_MAX (src/sha.h) to ULL
+		-- eliminates gcc warnings (rt.cpan.org #18988)
+	- specified minimum Perl version for module and Makefile.PL
+		-- closes rt.cpan.org #18984
 
 5.34  Thu Feb  2 18:55:40 MST 2006
 	- removed Unix-style pathnames in test scripts

Modified: packages/libdigest-sha-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/META.yml?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/META.yml (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/META.yml Thu Jun  1 18:29:01 2006
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name: Digest-SHA
-version: 5.34
+version: 5.39
 author:
   - Mark Shelor, mshelor at cpan.org
 abstract: Perl extension for SHA-1/224/256/384/512
@@ -12,5 +12,5 @@
 provides:
   Digest::SHA:
     file: SHA.pm
-    version: 5.34
+    version: 5.39
 generated_by: Module::Build version 0.22

Modified: packages/libdigest-sha-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/Makefile.PL?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/Makefile.PL (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/Makefile.PL Thu Jun  1 18:29:01 2006
@@ -1,3 +1,5 @@
+require 5.006000;
+
 use ExtUtils::MakeMaker;
 use Getopt::Std;
 use Config;

Modified: packages/libdigest-sha-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/README?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/README (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/README Thu Jun  1 18:29:01 2006
@@ -1,4 +1,4 @@
-Digest::SHA version 5.34
+Digest::SHA version 5.39
 ========================
 
 Digest::SHA is a complete implementation of the NIST Secure Hash

Modified: packages/libdigest-sha-perl/branches/upstream/current/SHA.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/SHA.pm?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/SHA.pm (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/SHA.pm Thu Jun  1 18:29:01 2006
@@ -1,10 +1,12 @@
 package Digest::SHA;
+
+require 5.006000;
 
 use strict;
 use warnings;
 use integer;
 
-our $VERSION = '5.34';
+our $VERSION = '5.39';
 
 require Exporter;
 our @ISA = qw(Exporter);
@@ -23,13 +25,14 @@
 
 # If possible, inherit from Digest::base (which depends on MIME::Base64)
 
+*addfile = \&Addfile;
+
 eval {
 	require MIME::Base64;
 	require Digest::base;
 	push(@ISA, 'Digest::base');
 };
 if ($@) {
-	*addfile = \&Addfile;
 	*hexdigest = \&Hexdigest;
 	*b64digest = \&B64digest;
 }
@@ -85,23 +88,64 @@
 	return($self);
 }
 
-# local copy of "addfile" in case Digest::base not installed
-
-sub Addfile {	# this is "addfile" from Digest::base 1.00
+sub _bail {
+	my $msg = shift;
+
+        require Carp;
+        Carp::croak("$msg: $!");
+}
+
+sub _addfile {  # this is "addfile" from Digest::base 1.00
     my ($self, $handle) = @_;
 
     my $n;
     my $buf = "";
 
     while (($n = read($handle, $buf, 4096))) {
-	$self->add($buf);
+        $self->add($buf);
     }
-    unless (defined $n) {
-	require Carp;
-	Carp::croak("Read failed: $!");
-    }
+    _bail("Read failed") unless defined $n;
 
     $self;
+}
+
+sub Addfile {
+	my ($self, $file, $mode) = @_;
+
+	if (ref(\$file) eq 'GLOB') { return(_addfile($self, $file)) }
+
+	$mode = defined($mode) ? $mode : "";
+	my ($binary, $portable) = map { $_ eq $mode } ("b", "p");
+	my $text = -T $file;
+
+	local *F;
+	_bail("Open failed") unless open(F, "<$file");
+	binmode(F) if $binary || $portable;
+
+	unless ($portable && $text) {
+		$self->_addfile(*F);
+		close(F);
+		return($self);
+	}
+
+	my ($n1, $n2);
+	my ($buf1, $buf2) = ("", "");
+
+	while (($n1 = read(F, $buf1, 4096))) {
+		while (substr($buf1, -1) eq "\015") {
+			$n2 = read(F, $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
+		$self->add($buf1);
+	}
+	_bail("Read failed") unless defined $n1;
+	close(F);
+
+	$self;
 }
 
 sub dump {
@@ -156,7 +200,10 @@
 	$sha = Digest::SHA->new($alg);
 
 	$sha->add($data);		# feed data into stream
+
 	$sha->addfile(*F);
+	$sha->addfile($filename);
+
 	$sha->add_bits($bits);
 	$sha->add_bits($data, $nbits);
 
@@ -409,8 +456,28 @@
 Reads from I<FILE> until EOF, and appends that data to the current
 state.  The return value is the updated object itself.
 
-This method is inherited if L<Digest::base> is installed on your
-system.  Otherwise, a functionally equivalent substitute is used.
+=item B<addfile($filename [, $mode])>
+
+Reads the contents of I<$filename>, and appends that data to the current
+state.  The return value is the updated object itself.
+
+By default, I<$filename> is simply opened and read; no special modes
+or I/O disciplines are used.  To change this, set the optional I<$mode>
+argument to one of the following values:
+
+	"b"	read file in binary mode
+
+	"p"	use portable mode
+
+The "p" mode is handy since it ensures that the digest value of
+I<$filename> will be the same when computed on different operating
+systems.  It accomplishes this by internally translating all newlines
+in text files to UNIX format before calculating the digest; on the other
+hand, binary files are read in raw mode with no translation whatsoever.
+
+For a fuller discussion of newline formats, refer to CPAN module
+L<File::LocalizeNewlines>.  Its "universal line separator" regex forms
+the basis of I<addfile>'s portable mode processing.
 
 =item B<dump($filename)>
 
@@ -539,6 +606,7 @@
 	Jeffrey Friedl
 	Robert Gilmour
 	Brian Gladman
+	Adam Kennedy
 	Andy Lester
 	Alex Muntada
 	Steve Peters

Modified: packages/libdigest-sha-perl/branches/upstream/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/SIGNATURE?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/SIGNATURE (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/SIGNATURE Thu Jun  1 18:29:01 2006
@@ -1,5 +1,5 @@
 This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.50.
+signed via the Module::Signature module, version 0.54.
 
 To verify the content in this distribution, first make sure you have
 Module::Signature installed, then type:
@@ -14,20 +14,20 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 4ec4dd0ac5a6e679b7ac77e0b5fb4be54e685e62 Changes
+SHA1 a73a1adca7a824df34190ceb459eb61046aa52e2 Changes
 SHA1 952a17b73eeb605287d1aa08d2e8bf4837106b43 MANIFEST
-SHA1 44c45b209faa50d5cea2cd3aa154543473224068 META.yml
-SHA1 9903634fd8ce5d1ed2fbece7be5ed0cd5d98f158 Makefile.PL
-SHA1 8525f94799ac062aa636851ec618242b39b7c40f README
-SHA1 1b4d9e922933406df2c062878be9c5340dd40031 SHA.pm
+SHA1 40a4eefdf66e75517fffb829964a414cb370be4a META.yml
+SHA1 def31e4ea732857338ca9858b091a7b9b4c35fd7 Makefile.PL
+SHA1 3d858a1fb34300001599f240a4fdba54c81ea31f README
+SHA1 fa71c875541414bfe5307756c4cc435a760750a9 SHA.pm
 SHA1 51d3d1db41241cdf960bb3d5c81efa9eac13b197 SHA.xs
 SHA1 48517b1bf0ddf48ae4bc24910d3b9af625bc2325 ppport.h
-SHA1 3feeaa9113148ee3bff0073c7d0aa7977652581d shasum
-SHA1 8b7099c5959550c621ff6ba6e9ac0a856b5b25db src/hmac.c
-SHA1 5b081137aae691475eac941783b7842c81767485 src/hmac.h
+SHA1 7f01b2c6c83dc682b1704901d3001b40b83cc9c6 shasum
+SHA1 71366f8b4cb41657ad43d6a8f3c533ba5126f98e src/hmac.c
+SHA1 caa7528bf0d5a6e73abedb54ddd8fd0366c275d7 src/hmac.h
 SHA1 7589c6ce33e74a58ded932d69756659e91723fdb src/hmacxtra.c
-SHA1 c31a02bd6128a416e85eb979258bf392e639d37e src/sha.c
-SHA1 fe5481cafe6d17424100d0c3119023d033acf783 src/sha.h
+SHA1 7211043454d63e444252bd03c1f3aef2f8754e63 src/sha.c
+SHA1 e92ff7c10662e1e9a2393cc49ced373c17c83d7f src/sha.h
 SHA1 c1bba35de65c8d81362472b76075dba8cf1e542b src/sha64bit.c
 SHA1 48d806b05a15dfd8211d5f7158b3294d86fa24d2 src/sha64bit.h
 SHA1 329ac17325437c725331fbf84ae0c9484f50041a src/shaxtra.c
@@ -41,7 +41,7 @@
 SHA1 5ff47d34427af615dd5222486a3460e2a75535aa t/2-nist-sha-384.t
 SHA1 4d5dfce16efb801b27dcd5cfcd904d91175e97f1 t/2-nist-sha-512.t
 SHA1 902f263f29354655886cc5e5361bf8ff6fc6dc68 t/2-nist-sha-base64.t
-SHA1 a0c79db3485aac71beaa52f2e492445b19bdbf3f t/2-nist-sha-oo.t
+SHA1 cbfd1bd7c5f3b708b0a1b581dcf6af65490c446f t/2-nist-sha-oo.t
 SHA1 62b21ae81d5e57c0b064f7ba0c6bc81952ea2808 t/2-nist-vectors-bit.t
 SHA1 f8f550ff0161091803e163f56ecc043a9ae2387c t/2-nist-vectors-byte.t
 SHA1 3e9a29e58dfc4a6c40b5f92982d7ba26f175cf9c t/3-gillogly-easy.t
@@ -58,20 +58,20 @@
 SHA1 636d5e987243f6634fdc1dff1fe1d11d07778347 t/gillogly/state.011
 SHA1 b1e86af6b46e066555bbcd749982ccba816cf744 t/gillogly/state.110
 SHA1 427874bceb58bc3a36b5808a204023334614930b t/nist/COPYRIGHT
-SHA1 573d7d4bba50c5cecb4a86f1ffff14d764a31ecb t/nist/Readme.txt
-SHA1 7996bb1a434fb3f6fd38f64800ab3b2fe5d23c6b t/nist/bit-hashes.sha1
-SHA1 d21096373dfbf3330d89bcb2e704b543a27b6065 t/nist/bit-messages.sha1
-SHA1 dd66fe858830fb1b23d35affa402b52a77a15b1f t/nist/byte-hashes.sha1
-SHA1 936304c2db3a3ee49ecb1247f8466814cab080a0 t/nist/byte-messages.sha1
+SHA1 fb62fba7cf3abd4a3f102e3c5d1364885f3fca0c t/nist/Readme.txt
+SHA1 1c5e5609f4a68cbaac298d0bbcbc7f56866ac296 t/nist/bit-hashes.sha1
+SHA1 f5d19f0842895dc74ec3f9b1b2bc684088552d8e t/nist/bit-messages.sha1
+SHA1 81cc5e5a0c57de956de3f44977e486afa871068f t/nist/byte-hashes.sha1
+SHA1 505c66bd2326114b05fa96474ff1973e52761137 t/nist/byte-messages.sha1
 SHA1 3b51b03c790b1cf112d4804573f5fd4814b384c2 t/state/state.1
 SHA1 cc3d0feffc019e4651fb085e7bc51e190e58fa53 t/state/state.256
 SHA1 2130ee8086bc7bf41fc329e9d87a81e2d98b68c8 t/state/state.384
 SHA1 69cd49d84cb11c83ef8e6eb36f6a472edb37079d t/state/state.512
 SHA1 e93dd71c67ba56e170516c16eeeb7659a41f91fd typemap
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.0 (Darwin)
+Version: GnuPG v1.4.1 (GNU/Linux)
 
-iD8DBQFD4rkjBwNg/wr1Y/4RAonyAJ4x4Z4AcLWE19ia1AaD2qc4uk+0BQCgitCp
-cRrFVjJh69RZtmw12owCn8U=
-=2SJ3
+iD8DBQFEeXyTBwNg/wr1Y/4RAk8iAJ0S8L/kq7tn3ucmsSOUQyP4dSV1yACgj8K6
++6ZCFz3GP+PHDsSyTb06TME=
+=XeHm
 -----END PGP SIGNATURE-----

Modified: packages/libdigest-sha-perl/branches/upstream/current/shasum
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/shasum?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/shasum (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/shasum Thu Jun  1 18:29:01 2006
@@ -4,8 +4,8 @@
 	#
 	# Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved
 	#
-	# Version: 5.34
-	# Thu Feb  2 18:55:40 MST 2006
+	# Version: 5.39
+	# Sun May 28 03:22:24 MST 2006
 
 =head1 NAME
 
@@ -21,20 +21,22 @@
   -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/MacOS 9
   -t, --text         read files in text mode (default)
 
  The following two options are useful only when verifying checksums:
 
-      --status       don't output anything, status code shows success
+  -s, --status       don't output anything, status code shows success
   -w, --warn         warn about improperly formatted SHA checksum lines
 
-      --help         display this help and exit
-      --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 text), and name for each FILE.
+  -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.
 
 =head1 AUTHOR
 
@@ -42,7 +44,7 @@
 
 =head1 SEE ALSO
 
-Shasum is implemented using the Perl module L<Digest::SHA> or
+shasum is implemented using the Perl module L<Digest::SHA> or
 L<Digest::SHA::PurePerl>.
 
 =cut
@@ -50,7 +52,7 @@
 use strict;
 use Getopt::Long;
 
-my $VERSION = "5.34";
+my $VERSION = "5.39";
 
 
 	# Try to use Digest::SHA, since it's faster.  If not installed,
@@ -69,13 +71,18 @@
 
 
 	# Usage statement adapted from Ulrich Drepper's md5sum.
-	# Include an "-a" option for algorithm selection.
+	# Include an "-a" option for algorithm selection,
+	# and a "-p" option for portable digest computation.
 
 sub usage {
-	my($err) = @_;
-
-	my $stream = $err ? *STDERR : *STDOUT;
-	print $stream <<'END_OF_USAGE';
+	my($err, $msg) = @_;
+
+	$msg = "" unless defined $msg;
+	if ($err) {
+		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.
@@ -84,19 +91,21 @@
   -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/MacOS 9
   -t, --text         read files in text mode (default)
 
 The following two options are useful only when verifying checksums:
-      --status       don't output anything, status code shows success
+  -s, --status       don't output anything, status code shows success
   -w, --warn         warn about improperly formatted SHA checksum lines
 
-      --help         display this help and exit
-      --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 text), and name for each FILE.
+  -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
@@ -107,27 +116,35 @@
 	# Collect options from command line
 
 my ($alg, $binary, $check, $text, $status, $warn, $help, $version);
-
+my ($portable);
+
+Getopt::Long::Configure ("bundling");
 GetOptions(
-	'binary' => \$binary, 'check' => \$check,
-	'text' => \$text, 'algorithm=i' => \$alg,
-	'status' => \$status, 'warn' => \$warn,
-	'help' => \$help, 'version' => \$version
-) or usage(1);
+	'b|binary' => \$binary, 'c|check' => \$check,
+	't|text' => \$text, 'a|algorithm=i' => \$alg,
+	's|status' => \$status, 'w|warn' => \$warn,
+	'h|help' => \$help, 'v|version' => \$version,
+	'p|portable' => \$portable
+) or usage(1, "");
 
 
 	# Deal with help requests and incorrect uses
 
-usage(0) if $help;
-usage(1) if $binary and $text;
-usage(1) if $warn and not $check;
-usage(1) if $status and not $check;
+usage(0)
+	if $help;
+usage(1, "shasum: Ambiguous file mode\n")
+	if scalar(grep { defined $_ } ($binary, $portable, $text)) > 1;
+usage(1, "shasum: --warn option used only when verifying checksums\n")
+	if $warn && !$check;
+usage(1, "shasum: --status option used only when verifying checksums\n")
+	if $status && !$check;
 
 
 	# Default to SHA-1 unless overriden by command line option
 
 $alg = 1 unless $alg;
-grep { $_ == $alg } (1, 224, 256, 384, 512) or usage(1);
+grep { $_ == $alg } (1, 224, 256, 384, 512)
+	or usage(1, "shasum: Unrecognized algorithm\n");
 
 
 	# Display version information if requested
@@ -140,10 +157,13 @@
 
 	# Try to figure out if the OS is DOS-like.  If it is,
 	# default to binary mode when reading files, unless
-	# explicitly overriden by command line "text" option.
+	# explicitly overriden by command line "--text" or
+	# "--portable" options.
 
 my $isDOSish = ($^O =~ /^(MSWin\d\d|os2|dos|mint|cygwin)$/);
-if ($isDOSish) { $binary = 1 unless $text }
+if ($isDOSish) { $binary = 1 unless $text || $portable }
+
+my $modesym = $binary ? '*' : ($portable ? '?' : ' ');
 
 
 	# Read from STDIN (-) if no files listed on command line
@@ -154,17 +174,16 @@
 	# sumfile($file): computes SHA digest of $file
 
 sub sumfile {
-	my($file) = @_;
-	my($fh, $digest);
-
-	unless (open($fh, "<$file")) {
-		print STDERR "shasum: $file: No such file or directory\n";
+	my $file = shift;
+
+	my $mode = $portable ? 'p' : ($binary ? 'b' : '');
+	my $digest = eval { $module->new($alg)->addfile($file, $mode) };
+	if ($@) {
+		warn "shasum: $file: $!\n";
 		return;
 	}
-	binmode($fh) if $binary;
-	$digest = $module->new($alg)->addfile($fh)->hexdigest;
-	close($fh);
-	return($digest);
+
+	$digest->hexdigest;
 }
 
 
@@ -177,36 +196,49 @@
 
 if ($check) {
 	my $checkfile = shift(@ARGV);
-	my $err = 0;
+	my ($err, $read_errs, $match_errs) = (0, 0, 0);
+	my ($num_files, $num_checksums) = (0, 0);
 	my ($fh, $sum, $fname, $rsp);
 
-	die "shasum: $checkfile: No such file or directory\n"
+	die "shasum: $checkfile: $!\n"
 		unless open($fh, "<$checkfile");
 	while (<$fh>) {
 		s/\s+$//;
-		($sum, $binary, $fname) = /^(\S+)\s+(\*?)(.*)$/;
+		($sum, $modesym, $fname) = /^(\S+) (.)(.*)$/;
+		($binary, $portable, $text) =
+			map { $_ eq $modesym } ('*', '?', ' ');
 		unless ($alg = $len2alg{length($sum)}) {
-			print STDERR "shasum: $checkfile: $.: improperly ",
-				"formatted SHA checksum line\n" if $warn;
+			warn("shasum: $checkfile: $.: improperly " .
+				"formatted SHA checksum line\n") if $warn;
 			next;
 		}
-		$rsp = "$fname: ";
-		if (lc($sum) eq sumfile($fname)) { $rsp .= "OK\n" }
-		else { $rsp .= "FAILED\n"; $err = 1 }
+		$rsp = "$fname: "; $num_files++;
+		unless (my $digest = sumfile($fname)) {
+			$rsp .= "FAILED open or read\n";
+			$err = 1; $read_errs++;
+		}
+		else {
+			$num_checksums++;
+			if (lc($sum) eq $digest) { $rsp .= "OK\n" }
+			else { $rsp .= "FAILED\n"; $err = 1; $match_errs++ }
+		}
 		print $rsp unless $status;
 	}
 	close($fh);
+	unless ($status) {
+		warn("shasum: WARNING: $read_errs of $num_files listed " .
+			"files could not be read\n") if $read_errs;
+		warn("shasum: WARNING: $match_errs of $num_checksums " .
+			"computed checksums did NOT match\n") if $match_errs;
+	}
 	exit($err);
 }
 
 
 	# Compute and display SHA checksums of requested files
 
-for (@ARGV) {
-	if (-d $_) {
-		print STDERR "shasum: $_: Is a directory\n";
-		next;
-	}
-	next unless my $digest = sumfile($_);
-	print "$digest ", $binary ? "\*" : " ", "$_\n";
-}
+for my $arg (@ARGV) {
+	if (my $digest = sumfile($arg)) {
+		print "$digest $modesym", "$arg\n";
+	}
+}

Modified: packages/libdigest-sha-perl/branches/upstream/current/src/hmac.c
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/src/hmac.c?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/src/hmac.c (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/src/hmac.c Thu Jun  1 18:29:01 2006
@@ -5,8 +5,8 @@
  *
  * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved
  *
- * Version: 5.34
- * Thu Feb  2 18:55:40 MST 2006
+ * Version: 5.39
+ * Sun May 28 03:22:24 MST 2006
  *
  */
 

Modified: packages/libdigest-sha-perl/branches/upstream/current/src/hmac.h
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/src/hmac.h?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/src/hmac.h (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/src/hmac.h Thu Jun  1 18:29:01 2006
@@ -5,8 +5,8 @@
  *
  * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved
  *
- * Version: 5.34
- * Thu Feb  2 18:55:40 MST 2006
+ * Version: 5.39
+ * Sun May 28 03:22:24 MST 2006
  *
  */
 

Modified: packages/libdigest-sha-perl/branches/upstream/current/src/sha.c
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/src/sha.c?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/src/sha.c (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/src/sha.c Thu Jun  1 18:29:01 2006
@@ -5,8 +5,8 @@
  *
  * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved
  *
- * Version: 5.34
- * Thu Feb  2 18:55:40 MST 2006
+ * Version: 5.39
+ * Sun May 28 03:22:24 MST 2006
  *
  */
 
@@ -517,7 +517,7 @@
 char *file;
 SHA *s;
 {
-	unsigned int i, j;
+	int i, j;
 	SHA_FILE *f;
 	UCHR *p = shadigest(s);
 
@@ -530,7 +530,7 @@
 		for (j = 0; j < (s->alg <= 256 ? 4 : 8); j++)
 			SHA_fprintf(f, "%s%02x", j==0 ? ":" : "", *p++);
 	SHA_fprintf(f, "\nblock");
-	for (i = 0; i < s->blocksize>>3; i++)
+	for (i = 0; i < (int) (s->blocksize >> 3); i++)
 		SHA_fprintf(f, ":%02x", s->block[i]);
 	SHA_fprintf(f, "\nblockcnt:%u\n", s->blockcnt);
 	SHA_fprintf(f, "lenhh:%lu\nlenhl:%lu\nlenlh:%lu\nlenll:%lu\n",

Modified: packages/libdigest-sha-perl/branches/upstream/current/src/sha.h
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/src/sha.h?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/src/sha.h (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/src/sha.h Thu Jun  1 18:29:01 2006
@@ -5,8 +5,8 @@
  *
  * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved
  *
- * Version: 5.34
- * Thu Feb  2 18:55:40 MST 2006
+ * Version: 5.39
+ * Sun May 28 03:22:24 MST 2006
  *
  */
 
@@ -16,7 +16,6 @@
 #include <limits.h>
 
 #define SHA32_MAX	4294967295U
-#define SHA64_MAX	18446744073709551615U
 
 #define SHA32_SHR(x, n)	((x) >> (n))
 #define SHA32_SHL(x, n)	((x) << (n))
@@ -61,6 +60,7 @@
 #elif defined(SHA_ULL_EXISTS)
 	#undef  SHA64_ALIGNED
 	#undef  SHA64_SHR
+	#define SHA64_MAX	18446744073709551615ULL
 	#define SHA64_SHR(x, n)	(((x) & SHA64_MAX) >> (n))
 	#define SHA64	unsigned long long
 	#define SHA64_CONST(c)	c ## ULL

Modified: packages/libdigest-sha-perl/branches/upstream/current/t/2-nist-sha-oo.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/t/2-nist-sha-oo.t?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/t/2-nist-sha-oo.t (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/t/2-nist-sha-oo.t Thu Jun  1 18:29:01 2006
@@ -20,7 +20,7 @@
 "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
 	);
 
-	plan tests => 1 + scalar(@vec);
+	plan tests => 5 + scalar(@vec);
 }
 
 	# attempt to use an invalid algorithm, and check for failure
@@ -46,6 +46,37 @@
 $rsp = shift(@vec);
 open(FILE, "<$file");
 binmode(FILE);
-ok($ctx->addfile(*FILE)->hexdigest, $rsp);
+ok($ctx->clone->addfile(*FILE)->hexdigest, $rsp);
 close(FILE);
+
+	# test addfile using file name instead of handle
+
+ok($ctx->addfile($file, "b")->hexdigest, $rsp);
+
+	# test addfile portable mode
+
+open(FILE, ">$file");
+binmode(FILE);
+print FILE "abc\012" x 2048;		# using UNIX newline
+close(FILE);
+
+ok($ctx->new(1)->addfile($file, "p")->hexdigest,
+	"d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51");
+
+open(FILE, ">$file");
+binmode(FILE);
+print FILE "abc\015\012" x 2048;	# using DOS/Windows newline
+close(FILE);
+
+ok($ctx->new(1)->addfile($file, "p")->hexdigest,
+	"d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51");
+
+open(FILE, ">$file");
+binmode(FILE);
+print FILE "abc\015" x 2048;		# using Apple/Mac newline
+close(FILE);
+
+ok($ctx->new(1)->addfile($file, "p")->hexdigest,
+	"d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51");
+
 unlink($file);

Modified: packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-hashes.sha1
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-hashes.sha1?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-hashes.sha1 (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-hashes.sha1 Thu Jun  1 18:29:01 2006
@@ -1,14 +1,14 @@
-#  Configuration information for "SHA-1 Test"
-#  SHA tests are configured for BIT oriented implementations
-H>SHS Type 1 Hashes<H
-D>
-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^
-59C4526AA2CC59F9A5F56B5579BA7108E7CCB61A ^
-6E42FB84067CFF056C43A49E484997AF23190879 ^
-C63FBB9A87171A176E6E054890E29A8C5F125F6C ^
-3109E33C1C4B9A0169D1599169D0E5A520A1E71C ^
-9195E1E73CC68D7170F44BD1D83CB624BC87FA0B ^
-64F7C374527278C0436DBC8DE5AABEC2BBF634BC ^
-154B622EA426FB151B1FF1BE1CE871752B9EDEB4 ^
-12BDD00FD4038756CBCF8ECDAD1B0CD862603CD8 ^
-6700F93E1691E83735279E167F67AF61FEE9813B ^
+#  Configuration information for "SHA-1 Test"
+#  SHA tests are configured for BIT oriented implementations
+H>SHS Type 1 Hashes<H
+D>
+DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^
+59C4526AA2CC59F9A5F56B5579BA7108E7CCB61A ^
+6E42FB84067CFF056C43A49E484997AF23190879 ^
+C63FBB9A87171A176E6E054890E29A8C5F125F6C ^
+3109E33C1C4B9A0169D1599169D0E5A520A1E71C ^
+9195E1E73CC68D7170F44BD1D83CB624BC87FA0B ^
+64F7C374527278C0436DBC8DE5AABEC2BBF634BC ^
+154B622EA426FB151B1FF1BE1CE871752B9EDEB4 ^
+12BDD00FD4038756CBCF8ECDAD1B0CD862603CD8 ^
+6700F93E1691E83735279E167F67AF61FEE9813B ^

Modified: packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-messages.sha1
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-messages.sha1?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-messages.sha1 (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/t/nist/bit-messages.sha1 Thu Jun  1 18:29:01 2006
@@ -1,14 +1,14 @@
-#  Configuration information for "SHA-1 Test"
-#  SHA tests are configured for BIT oriented implementations
-H>SHS Type 1 Strings<H
-D>
-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 ^
+#  Configuration information for "SHA-1 Test"
+#  SHA tests are configured for BIT oriented implementations
+H>SHS Type 1 Strings<H
+D>
+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 ^

Modified: packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-hashes.sha1
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-hashes.sha1?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-hashes.sha1 (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-hashes.sha1 Thu Jun  1 18:29:01 2006
@@ -1,14 +1,14 @@
-#  Configuration information for "SHA-1 Test"
-#  SHA tests are configured for BYTE oriented implementations
-H>SHS Type 1 Hashes<H
-D>
-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^
-3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5 ^
-19C1E2048FA7393CFBF2D310AD8209EC11D996E5 ^
-CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5 ^
-71AC973D0E4B50AE9E5043FF4D615381120A25A0 ^
-A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA ^
-D87A0EE74E4B9AD72E6847C87BDEEB3D07844380 ^
-1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD ^
-5A78F439B6DB845BB8A558E4CEB106CD7B7FF783 ^
-F871BCE62436C1E280357416695EE2EF9B83695C ^
+#  Configuration information for "SHA-1 Test"
+#  SHA tests are configured for BYTE oriented implementations
+H>SHS Type 1 Hashes<H
+D>
+DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 ^
+3CDF2936DA2FC556BFA533AB1EB59CE710AC80E5 ^
+19C1E2048FA7393CFBF2D310AD8209EC11D996E5 ^
+CA775D8C80FAA6F87FA62BECA6CA6089D63B56E5 ^
+71AC973D0E4B50AE9E5043FF4D615381120A25A0 ^
+A6B5B9F854CFB76701C3BDDBF374B3094EA49CBA ^
+D87A0EE74E4B9AD72E6847C87BDEEB3D07844380 ^
+1976B8DD509FE66BF09C9A8D33534D4EF4F63BFD ^
+5A78F439B6DB845BB8A558E4CEB106CD7B7FF783 ^
+F871BCE62436C1E280357416695EE2EF9B83695C ^

Modified: packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-messages.sha1
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-messages.sha1?rev=2830&op=diff
==============================================================================
--- packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-messages.sha1 (original)
+++ packages/libdigest-sha-perl/branches/upstream/current/t/nist/byte-messages.sha1 Thu Jun  1 18:29:01 2006
@@ -1,14 +1,14 @@
-#  Configuration information for "SHA-1 Test"
-#  SHA tests are configured for BYTE oriented implementations
-H>SHS Type 1 Strings<H
-D>
-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 ^
+#  Configuration information for "SHA-1 Test"
+#  SHA tests are configured for BYTE oriented implementations
+H>SHS Type 1 Strings<H
+D>
+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 ^




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