diff options
author | Aaron Crane <arc@cpan.org> | 2014-03-18 18:50:38 +0000 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2014-03-18 18:53:02 +0000 |
commit | 626ec6d78ccfe68db9586606c40e6bad60f064cb (patch) | |
tree | 57217aad1640a1e16929b678c98946845d71c454 /cpan/Digest-SHA | |
parent | 47a9c2580a689eb6252f710c8ff39c9c9fb2c7cb (diff) | |
download | perl-626ec6d78ccfe68db9586606c40e6bad60f064cb.tar.gz |
Upgrade Digest-SHA from 5.87 to 5.88
[DELTA]
- added OUTPUT clause in SHA.xs to silence compiler warning
-- ref. shaclose()
- changed text file test (-T) to act on filehandles
-- ref. addfile portable mode
-- improves consistency when reading from STDIN
-- still acts on filenames for early Perls (< 5.6)
- added -M and -V options to shasum
-- undocumented: for development and testing use only
Diffstat (limited to 'cpan/Digest-SHA')
-rw-r--r-- | cpan/Digest-SHA/SHA.xs | 2 | ||||
-rw-r--r-- | cpan/Digest-SHA/lib/Digest/SHA.pm | 38 | ||||
-rw-r--r-- | cpan/Digest-SHA/shasum | 72 | ||||
-rw-r--r-- | cpan/Digest-SHA/src/sha.c | 8 | ||||
-rw-r--r-- | cpan/Digest-SHA/src/sha.h | 6 | ||||
-rw-r--r-- | cpan/Digest-SHA/src/sha64bit.c | 12 | ||||
-rw-r--r-- | cpan/Digest-SHA/src/sha64bit.h | 14 |
7 files changed, 99 insertions, 53 deletions
diff --git a/cpan/Digest-SHA/SHA.xs b/cpan/Digest-SHA/SHA.xs index 743337fdda..c38fcc4d9d 100644 --- a/cpan/Digest-SHA/SHA.xs +++ b/cpan/Digest-SHA/SHA.xs @@ -34,6 +34,8 @@ shaclose(s) CODE: RETVAL = shaclose(s); sv_setiv(SvRV(ST(0)), 0); +OUTPUT: + RETVAL SHA * shadup(s) diff --git a/cpan/Digest-SHA/lib/Digest/SHA.pm b/cpan/Digest-SHA/lib/Digest/SHA.pm index c13e30d578..57f0bd6ef6 100644 --- a/cpan/Digest-SHA/lib/Digest/SHA.pm +++ b/cpan/Digest-SHA/lib/Digest/SHA.pm @@ -7,7 +7,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Fcntl; use integer; -$VERSION = '5.87'; +$VERSION = '5.88'; require Exporter; require DynaLoader; @@ -108,6 +108,20 @@ sub _addfile { # this is "addfile" from Digest::base 1.00 $self; } +my $_can_T_filehandle; + +sub _istext { + local *FH = shift; + my $file = shift; + + if (! defined $_can_T_filehandle) { + local $^W = 0; + eval { -T FH }; + $_can_T_filehandle = $@ ? 0 : 1; + } + return $_can_T_filehandle ? -T FH : -T $file; +} + sub Addfile { my ($self, $file, $mode) = @_; @@ -135,27 +149,17 @@ sub Addfile { } binmode(FH) if $binary || $portable; - unless ($portable && -T $file) { + unless ($portable && _istext(*FH, $file)) { $self->_addfile(*FH); close(FH); return($self); } - my ($n1, $n2); - my ($buf1, $buf2) = ("", ""); - - while (($n1 = read(FH, $buf1, 4096))) { - while (substr($buf1, -1) eq "\015") { - $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; # early MacOS - $self->add($buf1); + while (<FH>) { + s/\015?\015\012/\012/g; # DOS/Windows + s/\015/\012/g; # early MacOS + $self->add($_); } - _bail("Read failed") unless defined $n1; close(FH); $self; @@ -257,7 +261,7 @@ sub load { my $file = shift; $file = "-" if (!defined($file) || $file eq ""); - + local *FH; open(FH, "< $file") or return; my $str = join('', <FH>); diff --git a/cpan/Digest-SHA/shasum b/cpan/Digest-SHA/shasum index 606393e477..32b71733bf 100644 --- a/cpan/Digest-SHA/shasum +++ b/cpan/Digest-SHA/shasum @@ -4,8 +4,8 @@ ## ## Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved ## - ## Version: 5.87 - ## Mon Feb 17 16:42:02 MST 2014 + ## Version: 5.88 + ## Mon Mar 17 08:46:10 MST 2014 ## shasum SYNOPSIS adapted from GNU Coreutils sha1sum. ## Add an "-a" option for algorithm selection, a "-p" @@ -47,10 +47,11 @@ shasum - Print or Check SHA Checksums 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, `^' for BITS), and name for each FILE. + The sums are computed as described in FIPS PUB 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, `^' for BITS), + and name for each FILE. Report shasum bugs to mshelor@cpan.org @@ -97,23 +98,7 @@ use strict; use Fcntl; use Getopt::Long; -my $VERSION = "5.87"; - - - ## 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"; - -my $module = $MOD_PREFER; -eval "require $module"; -if ($@) { - $module = $MOD_SECOND; - eval "require $module"; - die "Unable to find $MOD_PREFER or $MOD_SECOND\n" if $@; -} - +my $VERSION = "5.88"; sub usage { my($err, $msg) = @_; @@ -123,9 +108,11 @@ sub usage { warn($msg . "Type shasum -h for help\n"); exit($err); } - my($USAGE) = $POD =~ /SYNOPSIS\n\n(.+)\n=head1 DESCRIPTION\n/sm; + my($USAGE) = $POD =~ /SYNOPSIS(.+?)^=/sm; + $USAGE =~ s/^\s*//; + $USAGE =~ s/\s*$//; $USAGE =~ s/^ //gm; - print $USAGE; + print $USAGE, "\n"; exit($err); } @@ -139,7 +126,7 @@ select((select(STDERR), $| = 1)[0]); ## Collect options from command line my ($alg, $binary, $check, $text, $status, $warn, $help, $version); -my ($portable, $BITS); +my ($portable, $BITS, $modules, $versions); eval { Getopt::Long::Configure ("bundling") }; GetOptions( @@ -148,7 +135,9 @@ GetOptions( 's|status' => \$status, 'w|warn' => \$warn, 'h|help' => \$help, 'v|version' => \$version, 'p|portable' => \$portable, - '0|01' => \$BITS + '0|01' => \$BITS, + 'M|MODULES=s' => \$modules, + 'V|VERSIONS' => \$versions, ) or usage(1, ""); @@ -164,6 +153,28 @@ usage(1, "shasum: --status option used only when verifying checksums\n") if $status && !$check; + ## Try to use Digest::SHA. If not installed, use the slower + ## but functionally equivalent Digest::SHA::PurePerl instead. + + ## If option -M "Mod::Num1 Mod::Num2 ..." is invoked, try + ## those modules instead, in the order indicated. + +my @MODS = defined $modules + ? split(" ", $modules) + : qw(Digest::SHA Digest::SHA::PurePerl); + +my $module; +for (@MODS) { + my $mod = $_; + if (eval "require $mod") { + $module = $mod; + last; + } +} +die "shasum: Unable to find " . join(" or ", @MODS) . "\n" + unless defined $module; + + ## Default to SHA-1 unless overridden by command line option $alg = 1 unless defined $alg; @@ -178,6 +189,13 @@ if ($version) { exit(0); } +if ($versions) { + print "shasum $VERSION\n"; + print "$module ", eval "\$${module}::VERSION", "\n"; + print "perl ", defined $^V ? sprintf("%vd", $^V) : $], "\n"; + exit(0); +} + ## Try to figure out if the OS is DOS-like. If it is, ## default to binary mode when reading files, unless diff --git a/cpan/Digest-SHA/src/sha.c b/cpan/Digest-SHA/src/sha.c index a8480722c6..70ee233243 100644 --- a/cpan/Digest-SHA/src/sha.c +++ b/cpan/Digest-SHA/src/sha.c @@ -1,12 +1,12 @@ /* * sha.c: routines to compute SHA-1/224/256/384/512 digests * - * Ref: NIST FIPS PUB 180-2 Secure Hash Standard + * Ref: NIST FIPS PUB 180-4 Secure Hash Standard * * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved * - * Version: 5.87 - * Mon Feb 17 16:42:02 MST 2014 + * Version: 5.88 + * Mon Mar 17 08:46:10 MST 2014 * */ @@ -93,7 +93,7 @@ static void sha1(SHA *s, UCHR *block) /* SHA-1 transform */ SHA32_SCHED(W, block); /* - * Use SHA-1 alternate method from FIPS PUB 180-2 (ref. 6.1.3) + * Use SHA-1 alternate method from FIPS PUB 180-4 (ref. 6.1.3) * * To improve performance, unroll the loop and consolidate assignments * by changing the roles of variables "a" through "e" at each step. diff --git a/cpan/Digest-SHA/src/sha.h b/cpan/Digest-SHA/src/sha.h index f79deb0577..b9f1e70bb5 100644 --- a/cpan/Digest-SHA/src/sha.h +++ b/cpan/Digest-SHA/src/sha.h @@ -1,12 +1,12 @@ /* * sha.h: header file for SHA-1/224/256/384/512 routines * - * Ref: NIST FIPS PUB 180-2 Secure Hash Standard + * Ref: NIST FIPS PUB 180-4 Secure Hash Standard * * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved * - * Version: 5.87 - * Mon Feb 17 16:42:02 MST 2014 + * Version: 5.88 + * Mon Mar 17 08:46:10 MST 2014 * */ diff --git a/cpan/Digest-SHA/src/sha64bit.c b/cpan/Digest-SHA/src/sha64bit.c index 6c9096670f..71f99788e7 100644 --- a/cpan/Digest-SHA/src/sha64bit.c +++ b/cpan/Digest-SHA/src/sha64bit.c @@ -1,3 +1,15 @@ +/* + * sha64bit.c: routines to compute SHA-384/512 digests + * + * Ref: NIST FIPS PUB 180-4 Secure Hash Standard + * + * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved + * + * Version: 5.88 + * Mon Mar 17 08:46:10 MST 2014 + * + */ + #ifdef SHA_384_512 #undef sha_384_512 diff --git a/cpan/Digest-SHA/src/sha64bit.h b/cpan/Digest-SHA/src/sha64bit.h index c4fe7666bd..bdd7b1c870 100644 --- a/cpan/Digest-SHA/src/sha64bit.h +++ b/cpan/Digest-SHA/src/sha64bit.h @@ -1,10 +1,20 @@ /* + * sha64bit.h: placeholder values for 64-bit data and routines + * + * Ref: NIST FIPS PUB 180-4 Secure Hash Standard + * + * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved + * + * Version: 5.88 + * Mon Mar 17 08:46:10 MST 2014 + * * The following macros supply placeholder values that enable the - * `sha.c' module to successfully compile when 64-bit integer types + * sha.c module to successfully compile when 64-bit integer types * aren't present. * - * They are appropriately redefined in `sha64bit.c` if the compiler + * They are appropriately redefined in sha64bit.c if the compiler * provides a 64-bit type (i.e. when SHA_384_512 is defined). + * */ #define sha_384_512 0 |