'Digest::SHA' =>
{
'MAINTAINER' => 'mshelor',
- 'DISTRIBUTION' => 'MSHELOR/Digest-SHA-5.63.tar.gz',
- 'FILES' => q[cpan/Digest-SHA],
+ 'DISTRIBUTION' => 'MSHELOR/Digest-SHA-5.70.tar.gz',
+ 'FILES' => q[cpan/Digest-SHA],
'EXCLUDED' => [ qw{t/pod.t t/podcover.t examples/dups} ],
'UPSTREAM' => 'cpan',
},
Revision history for Perl extension Digest::SHA.
+5.70 Wed Dec 14 02:32:10 MST 2011
+ - added BITS mode to addfile method and shasum
+ -- partial-byte inputs now possible via files/STDIN
+ -- allows shasum to check all 8074 NIST Msg vectors
+ -- previously required special programming
+
5.63 Tue Nov 8 02:36:42 MST 2011
- added code to allow very large data inputs all at once
-- previously limited to several hundred MB at a time
-Digest::SHA version 5.63
+Digest::SHA version 5.70
========================
Digest::SHA is a complete implementation of the NIST Secure Hash
use Fcntl;
use integer;
-$VERSION = '5.63';
+$VERSION = '5.70';
require Exporter;
require DynaLoader;
$nbits = length($data);
$data = pack("B*", $data);
}
+ $nbits = length($data) * 8 if $nbits > length($data) * 8;
shawrite($data, $nbits, $$self);
return($self);
}
return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR';
$mode = defined($mode) ? $mode : "";
- my ($binary, $portable) = map { $_ eq $mode } ("b", "p");
+ my ($binary, $portable, $BITS) = map { $_ eq $mode } ("b", "p", "0");
## Always interpret "-" to mean STDIN; otherwise use
## sysopen to handle full range of POSIX file names
$file eq '-' and open(FH, '< -')
or sysopen(FH, $file, O_RDONLY)
or _bail('Open failed');
- binmode(FH) if $binary || $portable;
+ if ($BITS) {
+ my ($n, $buf) = (0, "");
+ while (($n = read(FH, $buf, 4096))) {
+ $buf =~ s/[^01]//g;
+ $self->add_bits($buf);
+ }
+ _bail("Read failed") unless defined $n;
+ close(FH);
+ return($self);
+ }
+
+ binmode(FH) if $binary || $portable;
unless ($portable && -T $file) {
$self->_addfile(*FH);
close(FH);
"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. Binary files
-are read in raw mode with no translation whatsoever.
+ "0" use BITS mode
+
+The "p" mode 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. 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.
+The BITS mode ("0") interprets the contents of I<$filename> as a logical
+stream of bits, where each ASCII '0' or '1' character represents a 0 or
+1 bit, respectively. All other characters are ignored. This provides
+a convenient way to calculate the digest values of partial-byte data by
+using files, rather than having to write programs using the I<add_bits>
+method.
=item B<dump($filename)>
##
## Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
##
- ## Version: 5.63
- ## Tue Nov 8 02:36:42 MST 2011
+ ## Version: 5.70
+ ## Wed Dec 14 02:32:10 MST 2011
## shasum SYNOPSIS adapted from GNU Coreutils sha1sum.
## Include an "-a" option for algorithm selection, and a
-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
+ -p, --portable read in portable mode
produces same digest on Windows/Unix/Mac
+ -0, --01 read in BITS mode
+ ASCII '0' interpreted as 0-bit,
+ ASCII '1' interpreted as 1-bit,
+ all other characters ignored
-t, --text read in text mode (default)
The following two options are useful only when verifying checksums:
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.
+ ` ' for text, `?' for portable, `^' for BITS), and name for each FILE.
Report shasum bugs to mshelor@cpan.org
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":
+The following command shows how to compute digests for typical inputs
+such as the NIST test vector "abc":
perl -e "print qq(abc)" | shasum
use Fcntl;
use Getopt::Long;
-my $VERSION = "5.63";
+my $VERSION = "5.70";
## Try to use Digest::SHA. If not installed, use the slower
## Collect options from command line
my ($alg, $binary, $check, $text, $status, $warn, $help, $version);
-my ($portable);
+my ($portable, $BITS);
eval { Getopt::Long::Configure ("bundling") };
GetOptions(
't|text' => \$text, 'a|algorithm=i' => \$alg,
's|status' => \$status, 'w|warn' => \$warn,
'h|help' => \$help, 'v|version' => \$version,
- 'p|portable' => \$portable
+ 'p|portable' => \$portable,
+ '0|01' => \$BITS
) or usage(1, "");
usage(0)
if $help;
usage(1, "shasum: Ambiguous file mode\n")
- if scalar(grep { defined $_ } ($binary, $portable, $text)) > 1;
+ if scalar(grep {defined $_} ($binary, $portable, $text, $BITS)) > 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")
my $isDOSish = ($^O =~ /^(MSWin\d\d|os2|dos|mint|cygwin)$/);
if ($isDOSish) { $binary = 1 unless $text || $portable }
-my $modesym = $binary ? '*' : ($portable ? '?' : ' ');
+my $modesym = $binary ? '*' : ($portable ? '?' : ($BITS ? '^' : ' '));
## Read from STDIN (-) if no files listed on command line
sub sumfile {
my $file = shift;
- my $mode = $portable ? 'p' : ($binary ? 'b' : '');
+ my $mode = $portable ? 'p' : ($binary ? 'b' : ($BITS ? '0' : ''));
my $digest = eval { $module->new($alg)->addfile($file, $mode) };
if ($@) { warn "shasum: $file: $!\n"; return }
$digest->hexdigest;
next if /^#/; s/\n$//; s/^[ \t]+//; $num_lines++;
$bslash = s/^\\//;
($sum, $modesym, $fname) =
- /^([\da-fA-F]+)[ \t]([ *?])([^\0]*)/;
+ /^([\da-fA-F]+)[ \t]([ *?^])([^\0]*)/;
$alg = defined $sum ? $len2alg{length($sum)} : undef;
$fname = unescape($fname) if defined $fname && $bslash;
if (grep { ! defined $_ } ($alg, $sum, $modesym, $fname)) {
}
$fname =~ s/\r$// unless -e $fname;
$rsp = "$fname: "; $num_files++;
- ($binary, $portable, $text) =
- map { $_ eq $modesym } ('*', '?', ' ');
+ ($binary, $portable, $text, $BITS) =
+ map { $_ eq $modesym } ('*', '?', ' ', '^');
unless ($digest = sumfile($fname)) {
$rsp .= "FAILED open or read\n";
$err = 1; $read_errs++;
*
* Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
*
- * Version: 5.63
- * Tue Nov 8 02:36:42 MST 2011
+ * Version: 5.70
+ * Wed Dec 14 02:32:10 MST 2011
*
*/
*
* Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
*
- * Version: 5.63
- * Tue Nov 8 02:36:42 MST 2011
+ * Version: 5.70
+ * Wed Dec 14 02:32:10 MST 2011
*
*/
*
* Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
*
- * Version: 5.63
- * Tue Nov 8 02:36:42 MST 2011
+ * Version: 5.70
+ * Wed Dec 14 02:32:10 MST 2011
*
*/
*
* Copyright (C) 2003-2011 Mark Shelor, All Rights Reserved
*
- * Version: 5.63
- * Tue Nov 8 02:36:42 MST 2011
+ * Version: 5.70
+ * Wed Dec 14 02:32:10 MST 2011
*
*/
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
);
-my $numtests = 6 + scalar @out;
+my $numtests = 8 + scalar @out;
print "1..$numtests\n";
# attempt to use an invalid algorithm, and check for failure
print "not " unless $sha->new(1)->addfile($tempfile, "p")->hexdigest eq
"d449e19c1b0b0c191294c8dc9fa2e4a6ff77fc51";
print "ok ", $testnum++, "\n";
+
+ # test addfile BITS mode
+
+$fh = FileHandle->new($tempfile, "w");
+print $fh "0100010"; # using NIST 7-bit test vector
+$fh->close;
+
+print "not " unless $sha->new(1)->addfile($tempfile, "0")->hexdigest eq
+ "04f31807151181ad0db278a1660526b0aeef64c2";
+print "ok ", $testnum++, "\n";
+
+$fh = FileHandle->new($tempfile, "w");
+binmode($fh);
+print $fh map(chr, (0..127)); # this is actually NIST 2-bit test
+$fh->close; # vector "01" (other chars ignored)
+
+print "not " unless $sha->new(1)->addfile($tempfile, "0")->hexdigest eq
+ "ec6b39952e1a3ec3ab3507185cf756181c84bbe2";
+print "ok ", $testnum++, "\n";
=item *
+L<Digest::SHA> has been upgraded from version 5.63 to version 5.70.
+
+Added BITS mode to addfile method and shasum which makes partial-byte inputs
+now possible via files/STDIN and allows shasum to check all 8074 NIST Msg vectors,
+where previously special programming was required to do this.
+
+=item *
+
L<ExtUtils::ParseXS> has been upgraded from version 3.05 to version 3.07.
=item *