From: Steve Peters Date: Tue, 13 Jun 2006 01:15:21 +0000 (+0000) Subject: Upgrade to Digest-SHA-5.41 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84c0b84e93593c55108ebfb4f82522eee2fd61e1;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Digest-SHA-5.41 p4raw-id: //depot/perl@28390 --- diff --git a/ext/Digest/SHA/Changes b/ext/Digest/SHA/Changes index 5f01e1c..9b488b5 100644 --- a/ext/Digest/SHA/Changes +++ b/ext/Digest/SHA/Changes @@ -1,5 +1,18 @@ Revision history for Perl extension Digest::SHA. +5.41 Sat Jun 3 01:50:46 MST 2006 + - corrected addfile + -- process $file argument as a filehandle unless passed + as a SCALAR (which indicates a file name) + +5.40 Fri Jun 2 04:00:30 MST 2006 + - modified addfile to accept indirect filehandles + -- ref. rt.cpan.org #19627 and #19641 + +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 diff --git a/ext/Digest/SHA/README b/ext/Digest/SHA/README index 2f833d6..2121cbd 100644 --- a/ext/Digest/SHA/README +++ b/ext/Digest/SHA/README @@ -1,4 +1,4 @@ -Digest::SHA version 5.38 +Digest::SHA version 5.41 ======================== Digest::SHA is a complete implementation of the NIST Secure Hash diff --git a/ext/Digest/SHA/SHA.pm b/ext/Digest/SHA/SHA.pm index 0ba9347..dc7929a 100644 --- a/ext/Digest/SHA/SHA.pm +++ b/ext/Digest/SHA/SHA.pm @@ -6,7 +6,7 @@ use strict; use warnings; use integer; -our $VERSION = '5.38_01'; +our $VERSION = '5.41'; require Exporter; our @ISA = qw(Exporter); @@ -112,7 +112,7 @@ sub _addfile { # this is "addfile" from Digest::base 1.00 sub Addfile { my ($self, $file, $mode) = @_; - if (ref(\$file) eq 'GLOB') { return(_addfile($self, $file)) } + return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR'; $mode = defined($mode) ? $mode : ""; my ($binary, $portable) = map { $_ eq $mode } ("b", "p"); @@ -138,8 +138,8 @@ sub Addfile { 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?\015\012/\012/g; # DOS/Windows + $buf1 =~ s/\015/\012/g; # Apple/MacOS 9 $self->add($buf1); } _bail("Read failed") unless defined $n1; @@ -465,13 +465,9 @@ 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: -=over 4 - -=item B<"b"> read file in binary mode + "b" read file in binary mode -=item B<"p"> use portable mode - -=back + "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 diff --git a/ext/Digest/SHA/bin/shasum b/ext/Digest/SHA/bin/shasum index fdb615b..4899d63 100755 --- a/ext/Digest/SHA/bin/shasum +++ b/ext/Digest/SHA/bin/shasum @@ -1,11 +1,11 @@ #!perl -w - # shasum: filter for computing SHA digests (analogous to md5sum) + # shasum: filter for computing SHA digests (analogous to sha1sum) # # Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved # - # Version: 5.38 - # Thu May 25 02:02:02 MST 2006 + # Version: 5.41 + # Sat Jun 3 01:50:46 MST 2006 =head1 NAME @@ -52,7 +52,7 @@ L. use strict; use Getopt::Long; -my $VERSION = "5.38"; +my $VERSION = "5.41"; # Try to use Digest::SHA, since it's faster. If not installed, @@ -132,7 +132,7 @@ GetOptions( usage(0) if $help; -usage(1, "Ambiguous file mode\n") +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; @@ -144,7 +144,7 @@ usage(1, "shasum: --status option used only when verifying checksums\n") $alg = 1 unless $alg; grep { $_ == $alg } (1, 224, 256, 384, 512) - or usage(1, "Unrecognized algorithm\n"); + or usage(1, "shasum: Unrecognized algorithm\n"); # Display version information if requested @@ -176,24 +176,14 @@ my $modesym = $binary ? '*' : ($portable ? '?' : ' '); sub sumfile { my $file = shift; - unless (-e $file) { - warn "shasum: $file: No such file or directory\n"; + my $mode = $portable ? 'p' : ($binary ? 'b' : ''); + my $digest = eval { $module->new($alg)->addfile($file, $mode) }; + if ($@) { + warn "shasum: $file: $!\n"; return; } - unless (-r $file) { - warn "shasum: $file: FAILED open or read\n"; - return; - } - - my $digest = $module->new($alg); - unless ($digest) { - warn "shasum: $file: FAILED digest creation\n"; - return; - } - - my $readmode = $portable ? 'p' : ($binary ? 'b' : ''); - $digest->addfile($file, $readmode)->hexdigest; + $digest->hexdigest; } @@ -210,7 +200,7 @@ if ($check) { 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+$//; @@ -247,11 +237,8 @@ if ($check) { # Compute and display SHA checksums of requested files -for my $arg (@ARGV) { - if (-d $arg) { - warn "shasum: $arg: Is a directory\n"; - next; +for my $file (@ARGV) { + if (my $digest = sumfile($file)) { + print "$digest $modesym", "$file\n"; } - my $digest = sumfile($arg) or next; - print "$digest $modesym$arg\n"; } diff --git a/ext/Digest/SHA/src/hmac.c b/ext/Digest/SHA/src/hmac.c index be2fe64..a878cb5 100644 --- a/ext/Digest/SHA/src/hmac.c +++ b/ext/Digest/SHA/src/hmac.c @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.38 - * Thu May 25 02:02:02 MST 2006 + * Version: 5.41 + * Sat Jun 3 01:50:46 MST 2006 * */ diff --git a/ext/Digest/SHA/src/hmac.h b/ext/Digest/SHA/src/hmac.h index 221c09f..cf5ff76 100644 --- a/ext/Digest/SHA/src/hmac.h +++ b/ext/Digest/SHA/src/hmac.h @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.38 - * Thu May 25 02:02:02 MST 2006 + * Version: 5.41 + * Sat Jun 3 01:50:46 MST 2006 * */ diff --git a/ext/Digest/SHA/src/sha.c b/ext/Digest/SHA/src/sha.c index 7b4faa4..c057cb4 100644 --- a/ext/Digest/SHA/src/sha.c +++ b/ext/Digest/SHA/src/sha.c @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.38 - * Thu May 25 02:02:02 MST 2006 + * Version: 5.41 + * Sat Jun 3 01:50:46 MST 2006 * */ diff --git a/ext/Digest/SHA/src/sha.h b/ext/Digest/SHA/src/sha.h index bf850c4..e9f038e 100644 --- a/ext/Digest/SHA/src/sha.h +++ b/ext/Digest/SHA/src/sha.h @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.38 - * Thu May 25 02:02:02 MST 2006 + * Version: 5.41 + * Sat Jun 3 01:50:46 MST 2006 * */ diff --git a/ext/Digest/SHA/t/2-nist-sha-oo.t b/ext/Digest/SHA/t/2-nist-sha-oo.t index c1a6b3e..a653a99 100644 --- a/ext/Digest/SHA/t/2-nist-sha-oo.t +++ b/ext/Digest/SHA/t/2-nist-sha-oo.t @@ -20,7 +20,7 @@ BEGIN { "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" ); - plan tests => 5 + scalar(@vec); + plan tests => 6 + scalar(@vec); } # attempt to use an invalid algorithm, and check for failure @@ -49,6 +49,13 @@ binmode(FILE); ok($ctx->clone->addfile(*FILE)->hexdigest, $rsp); close(FILE); + # use indirect filehandle + +open(my $fh, "<$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);