From e80e3195a56ee8ba20dc0e0f5d5381af5ec5ac33 Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Thu, 30 Jan 2014 15:43:37 +0000 Subject: [PATCH] Update Digest-SHA to CPAN version 5.86 [DELTA] 5.86 Thu Jan 30 08:24:28 MST 2014 - improved the performance of hexadecimal output functions -- ref. 'shahex' in src/sha.c -- thanks to Thomas Drugeon for ideas and test script --- Porting/Maintainers.pl | 2 +- cpan/Digest-SHA/lib/Digest/SHA.pm | 4 ++-- cpan/Digest-SHA/shasum | 10 +++++----- cpan/Digest-SHA/src/sha.c | 31 ++++++++++++++++++++----------- cpan/Digest-SHA/src/sha.h | 6 +++--- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index c3856fb..f88ab04 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -384,7 +384,7 @@ use File::Glob qw(:case); }, 'Digest::SHA' => { - 'DISTRIBUTION' => 'MSHELOR/Digest-SHA-5.85.tar.gz', + 'DISTRIBUTION' => 'MSHELOR/Digest-SHA-5.86.tar.gz', 'FILES' => q[cpan/Digest-SHA], 'EXCLUDED' => [ qw( t/pod.t diff --git a/cpan/Digest-SHA/lib/Digest/SHA.pm b/cpan/Digest-SHA/lib/Digest/SHA.pm index 9f94136..d8c9aec 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.85'; +$VERSION = '5.86'; require Exporter; require DynaLoader; @@ -733,7 +733,7 @@ darkness and moored it in so perfect a calm and in so brilliant a light" =head1 COPYRIGHT AND LICENSE -Copyright (C) 2003-2013 Mark Shelor +Copyright (C) 2003-2014 Mark Shelor This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/cpan/Digest-SHA/shasum b/cpan/Digest-SHA/shasum index 381a980..0026a25 100644 --- a/cpan/Digest-SHA/shasum +++ b/cpan/Digest-SHA/shasum @@ -2,10 +2,10 @@ ## shasum: filter for computing SHA digests (ref. sha1sum/md5sum) ## - ## Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved + ## Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved ## - ## Version: 5.85 - ## Wed Jun 26 04:05:26 MST 2013 + ## Version: 5.86 + ## Thu Jan 30 08:24:28 MST 2014 ## shasum SYNOPSIS adapted from GNU Coreutils sha1sum. ## Add an "-a" option for algorithm selection, a "-p" @@ -82,7 +82,7 @@ the 7-bit message I<0001100>: =head1 AUTHOR -Copyright (c) 2003-2013 Mark Shelor . +Copyright (c) 2003-2014 Mark Shelor . =head1 SEE ALSO @@ -97,7 +97,7 @@ use strict; use Fcntl; use Getopt::Long; -my $VERSION = "5.85"; +my $VERSION = "5.86"; ## Try to use Digest::SHA. If not installed, use the slower diff --git a/cpan/Digest-SHA/src/sha.c b/cpan/Digest-SHA/src/sha.c index d989d6c..9554c25 100644 --- a/cpan/Digest-SHA/src/sha.c +++ b/cpan/Digest-SHA/src/sha.c @@ -3,10 +3,10 @@ * * Ref: NIST FIPS PUB 180-2 Secure Hash Standard * - * Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved * - * Version: 5.85 - * Wed Jun 26 04:05:26 MST 2013 + * Version: 5.86 + * Thu Jan 30 08:24:28 MST 2014 * */ @@ -423,22 +423,31 @@ static UCHR *shadigest(SHA *s) return(s->digest); } +/* xmap: translation map for hexadecimal encoding */ +static char xmap[] = + "0123456789abcdef"; + /* shahex: returns pointer to current digest (hexadecimal) */ static char *shahex(SHA *s) { int i; + char *h; + UCHR *d; digcpy(s); s->hex[0] = '\0'; if (HEXLEN((size_t) s->digestlen) >= sizeof(s->hex)) return(s->hex); - for (i = 0; i < s->digestlen; i++) - sprintf(s->hex+i*2, "%02x", s->digest[i]); + for (i = 0, h = s->hex, d = s->digest; i < s->digestlen; i++) { + *h++ = xmap[(*d >> 4) & 0x0f]; + *h++ = xmap[(*d++ ) & 0x0f]; + } + *h = '\0'; return(s->hex); } -/* map: translation map for Base 64 encoding */ -static char map[] = +/* bmap: translation map for Base 64 encoding */ +static char bmap[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* encbase64: encodes input (0 to 3 bytes) into Base 64 */ @@ -450,10 +459,10 @@ static void encbase64(UCHR *in, int n, char *out) if (n < 1 || n > 3) return; memcpy(byte, in, n); - out[0] = map[byte[0] >> 2]; - out[1] = map[((byte[0] & 0x03) << 4) | (byte[1] >> 4)]; - out[2] = map[((byte[1] & 0x0f) << 2) | (byte[2] >> 6)]; - out[3] = map[byte[2] & 0x3f]; + out[0] = bmap[byte[0] >> 2]; + out[1] = bmap[((byte[0] & 0x03) << 4) | (byte[1] >> 4)]; + out[2] = bmap[((byte[1] & 0x0f) << 2) | (byte[2] >> 6)]; + out[3] = bmap[byte[2] & 0x3f]; out[n+1] = '\0'; } diff --git a/cpan/Digest-SHA/src/sha.h b/cpan/Digest-SHA/src/sha.h index b38b1fd..a50b25e 100644 --- a/cpan/Digest-SHA/src/sha.h +++ b/cpan/Digest-SHA/src/sha.h @@ -3,10 +3,10 @@ * * Ref: NIST FIPS PUB 180-2 Secure Hash Standard * - * Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved + * Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved * - * Version: 5.85 - * Wed Jun 26 04:05:26 MST 2013 + * Version: 5.86 + * Thu Jan 30 08:24:28 MST 2014 * */ -- 2.7.4