diff options
-rw-r--r-- | ext/Digest/SHA/Changes | 9 | ||||
-rw-r--r-- | ext/Digest/SHA/README | 2 | ||||
-rw-r--r-- | ext/Digest/SHA/SHA.pm | 5 | ||||
-rwxr-xr-x | ext/Digest/SHA/bin/shasum | 8 | ||||
-rw-r--r-- | ext/Digest/SHA/src/hmac.c | 4 | ||||
-rw-r--r-- | ext/Digest/SHA/src/hmac.h | 60 | ||||
-rw-r--r-- | ext/Digest/SHA/src/sha.c | 108 | ||||
-rw-r--r-- | ext/Digest/SHA/src/sha.h | 74 | ||||
-rw-r--r-- | ext/Digest/SHA/src/sha64bit.c | 7 |
9 files changed, 119 insertions, 158 deletions
diff --git a/ext/Digest/SHA/Changes b/ext/Digest/SHA/Changes index a71c9cb0ed..42bce4f8d5 100644 --- a/ext/Digest/SHA/Changes +++ b/ext/Digest/SHA/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension Digest::SHA. +5.43 Sat Aug 5 02:36:18 MST 2006 + - undid Perl Best Practice of favoring 3-argument "open" + -- 3-arg version uses different semantics for "-" + causing bugs in addfile and shasum + - modified underlying C functions to use ANSI prototypes + -- requested by Steve Hay (ref. Smoke [5.9.4] 28630) + -- K&R style was causing numerous warnings from + Borland compiler + 5.42 Mon Jul 24 04:04:40 MST 2006 - minor code changes suggested by Perl::Critic -- e.g. no bareword filehandles, no 2-argument open's diff --git a/ext/Digest/SHA/README b/ext/Digest/SHA/README index f4352c8d40..550f7bca60 100644 --- a/ext/Digest/SHA/README +++ b/ext/Digest/SHA/README @@ -1,4 +1,4 @@ -Digest::SHA version 5.42 +Digest::SHA version 5.43 ======================== 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 d257996cb0..bcb8bce4eb 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.42_01'; +our $VERSION = '5.43'; require Exporter; our @ISA = qw(Exporter); @@ -118,7 +118,8 @@ sub Addfile { my ($binary, $portable) = map { $_ eq $mode } ("b", "p"); my $text = -T $file; - open(my $fh, q{<}, $file) or _bail("Open failed"); + open(my $fh, "<$file") ## no critic + or _bail("Open failed"); binmode($fh) if $binary || $portable; unless ($portable && $text) { diff --git a/ext/Digest/SHA/bin/shasum b/ext/Digest/SHA/bin/shasum index 1001ded7b5..101afcf59c 100755 --- a/ext/Digest/SHA/bin/shasum +++ b/ext/Digest/SHA/bin/shasum @@ -4,8 +4,8 @@ # # Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved # - # Version: 5.42 - # Mon Jul 24 04:04:40 MST 2006 + # Version: 5.43 + # Sat Aug 5 02:36:18 MST 2006 =head1 NAME @@ -52,7 +52,7 @@ L<Digest::SHA::PurePerl>. use strict; use Getopt::Long; -my $VERSION = "5.42"; +my $VERSION = "5.43"; # Try to use Digest::SHA, since it's faster. If not installed, @@ -201,7 +201,7 @@ if ($check) { my ($fh, $sum, $fname, $rsp); die "shasum: $checkfile: $!\n" - unless open($fh, q{<}, $checkfile); + unless open($fh, "<$checkfile"); ## no critic while (<$fh>) { s/\s+$//; ($sum, $modesym, $fname) = /^(\S+) (.)(.*)$/; diff --git a/ext/Digest/SHA/src/hmac.c b/ext/Digest/SHA/src/hmac.c index abb1bf5c35..95d5c396ba 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.42 - * Mon Jul 24 04:04:40 MST 2006 + * Version: 5.43 + * Sat Aug 5 02:36:18 MST 2006 * */ diff --git a/ext/Digest/SHA/src/hmac.h b/ext/Digest/SHA/src/hmac.h index 28c5dd4d0d..4a80501c62 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.42 - * Mon Jul 24 04:04:40 MST 2006 + * Version: 5.43 + * Sat Aug 5 02:36:18 MST 2006 * */ @@ -22,39 +22,37 @@ typedef struct { unsigned char key[SHA_MAX_BLOCK_BITS/8]; } HMAC; -#if defined(__STDC__) && __STDC__ != 0 - #define _HMAC_P(protos) protos -#else - #define _HMAC_P(protos) () -#endif - #define _HMAC_STATE HMAC *h #define _HMAC_ALG int alg #define _HMAC_DATA unsigned char *bitstr, unsigned long bitcnt #define _HMAC_KEY unsigned char *key, unsigned int keylen -HMAC *hmacopen _HMAC_P((_HMAC_ALG, _HMAC_KEY)); -unsigned long hmacwrite _HMAC_P((_HMAC_DATA, _HMAC_STATE)); -void hmacfinish _HMAC_P((_HMAC_STATE)); -unsigned char *hmacdigest _HMAC_P((_HMAC_STATE)); -char *hmachex _HMAC_P((_HMAC_STATE)); -char *hmacbase64 _HMAC_P((_HMAC_STATE)); -int hmacclose _HMAC_P((_HMAC_STATE)); - -unsigned char *hmac1digest _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac1hex _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac1base64 _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -unsigned char *hmac224digest _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac224hex _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac224base64 _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -unsigned char *hmac256digest _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac256hex _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac256base64 _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -unsigned char *hmac384digest _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac384hex _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac384base64 _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -unsigned char *hmac512digest _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac512hex _HMAC_P((_HMAC_DATA, _HMAC_KEY)); -char *hmac512base64 _HMAC_P((_HMAC_DATA, _HMAC_KEY)); +HMAC *hmacopen (_HMAC_ALG, _HMAC_KEY); +unsigned long hmacwrite (_HMAC_DATA, _HMAC_STATE); +void hmacfinish (_HMAC_STATE); +unsigned char *hmacdigest (_HMAC_STATE); +char *hmachex (_HMAC_STATE); +char *hmacbase64 (_HMAC_STATE); +int hmacclose (_HMAC_STATE); + +#ifndef SHA_PERL_MODULE + +unsigned char *hmac1digest (_HMAC_DATA, _HMAC_KEY); +char *hmac1hex (_HMAC_DATA, _HMAC_KEY); +char *hmac1base64 (_HMAC_DATA, _HMAC_KEY); +unsigned char *hmac224digest (_HMAC_DATA, _HMAC_KEY); +char *hmac224hex (_HMAC_DATA, _HMAC_KEY); +char *hmac224base64 (_HMAC_DATA, _HMAC_KEY); +unsigned char *hmac256digest (_HMAC_DATA, _HMAC_KEY); +char *hmac256hex (_HMAC_DATA, _HMAC_KEY); +char *hmac256base64 (_HMAC_DATA, _HMAC_KEY); +unsigned char *hmac384digest (_HMAC_DATA, _HMAC_KEY); +char *hmac384hex (_HMAC_DATA, _HMAC_KEY); +char *hmac384base64 (_HMAC_DATA, _HMAC_KEY); +unsigned char *hmac512digest (_HMAC_DATA, _HMAC_KEY); +char *hmac512hex (_HMAC_DATA, _HMAC_KEY); +char *hmac512base64 (_HMAC_DATA, _HMAC_KEY); + +#endif #endif /* _INCLUDE_HMAC_H_ */ diff --git a/ext/Digest/SHA/src/sha.c b/ext/Digest/SHA/src/sha.c index 3a5baccfbc..d5d7aad635 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.42 - * Mon Jul 24 04:04:40 MST 2006 + * Version: 5.43 + * Sat Aug 5 02:36:18 MST 2006 * */ @@ -83,9 +83,7 @@ static W32 H0256[8] = /* SHA-256 initial hash value */ C32(0x510e527f), C32(0x9b05688c), C32(0x1f83d9ab), C32(0x5be0cd19) }; -static void sha1(s, block) /* SHA-1 transform */ -SHA *s; -UCHR *block; +static void sha1(SHA *s, UCHR *block) /* SHA-1 transform */ { W32 a, b, c, d, e; SHA_STO_CLASS W32 W[16]; @@ -152,9 +150,7 @@ UCHR *block; H[0] += a; H[1] += b; H[2] += c; H[3] += d; H[4] += e; } -static void sha256(s, block) /* SHA-224/256 transform */ -SHA *s; -UCHR *block; +static void sha256(SHA *s, UCHR *block) /* SHA-224/256 transform */ { W32 a, b, c, d, e, f, g, h, T1; SHA_STO_CLASS W32 W[16]; @@ -226,9 +222,7 @@ UCHR *block; : ((nbytes) / 3) * 4 + ((nbytes) % 3) + 1) /* w32mem: writes 32-bit word to memory in big-endian order */ -static void w32mem(mem, w32) -UCHR *mem; -W32 w32; +static void w32mem(UCHR *mem, W32 w32) { int i; @@ -237,8 +231,7 @@ W32 w32; } /* digcpy: writes current state to digest buffer */ -static void digcpy(s) -SHA *s; +static void digcpy(SHA *s) { UINT i; UCHR *d = s->digest; @@ -265,8 +258,7 @@ SHA *s; } while (0) /* sharewind: re-initializes the digest object */ -void sharewind(s) -SHA *s; +void sharewind(SHA *s) { if (s->alg == SHA1) SHA_INIT(1, 1); else if (s->alg == SHA224) SHA_INIT(224, 256); @@ -276,8 +268,7 @@ SHA *s; } /* shaopen: creates a new digest object */ -SHA *shaopen(alg) -int alg; +SHA *shaopen(int alg) { SHA *s; @@ -295,10 +286,7 @@ int alg; } /* shadirect: updates state directly (w/o going through s->block) */ -static ULNG shadirect(bitstr, bitcnt, s) -UCHR *bitstr; -ULNG bitcnt; -SHA *s; +static ULNG shadirect(UCHR *bitstr, ULNG bitcnt, SHA *s) { ULNG savecnt = bitcnt; @@ -315,10 +303,7 @@ SHA *s; } /* shabytes: updates state for byte-aligned input data */ -static ULNG shabytes(bitstr, bitcnt, s) -UCHR *bitstr; -ULNG bitcnt; -SHA *s; +static ULNG shabytes(UCHR *bitstr, ULNG bitcnt, SHA *s) { UINT offset; UINT nbits; @@ -341,10 +326,7 @@ SHA *s; } /* shabits: updates state for bit-aligned input data */ -static ULNG shabits(bitstr, bitcnt, s) -UCHR *bitstr; -ULNG bitcnt; -SHA *s; +static ULNG shabits(UCHR *bitstr, ULNG bitcnt, SHA *s) { UINT i; UINT gap; @@ -380,10 +362,7 @@ SHA *s; } /* shawrite: triggers a state update using data in bitstr/bitcnt */ -ULNG shawrite(bitstr, bitcnt, s) -UCHR *bitstr; -ULNG bitcnt; -SHA *s; +ULNG shawrite(UCHR *bitstr, ULNG bitcnt, SHA *s) { if (bitcnt < 1) return(0); @@ -400,8 +379,7 @@ SHA *s; } /* shafinish: pads remaining block(s) and computes final digest state */ -void shafinish(s) -SHA *s; +void shafinish(SHA *s) { UINT lenpos, lhpos, llpos; @@ -426,16 +404,14 @@ SHA *s; } /* shadigest: returns pointer to current digest (binary) */ -UCHR *shadigest(s) -SHA *s; +UCHR *shadigest(SHA *s) { digcpy(s); return(s->digest); } /* shahex: returns pointer to current digest (hexadecimal) */ -char *shahex(s) -SHA *s; +char *shahex(SHA *s) { int i; @@ -453,10 +429,7 @@ static char map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* encbase64: encodes input (0 to 3 bytes) into Base 64 */ -static void encbase64(in, n, out) -UCHR *in; -int n; -char *out; +static void encbase64(UCHR *in, int n, char *out) { UCHR byte[3] = {0, 0, 0}; @@ -472,8 +445,7 @@ char *out; } /* shabase64: returns pointer to current digest (Base 64) */ -char *shabase64(s) -SHA *s; +char *shabase64(SHA *s) { int n; UCHR *q; @@ -493,15 +465,13 @@ SHA *s; } /* shadsize: returns length of digest in bytes */ -int shadsize(s) -SHA *s; +int shadsize(SHA *s) { return(s->digestlen); } /* shadup: duplicates current digest object */ -SHA *shadup(s) -SHA *s; +SHA *shadup(SHA *s) { SHA *p; @@ -513,9 +483,7 @@ SHA *s; } /* shadump: dumps digest object to a human-readable ASCII file */ -int shadump(file, s) -char *file; -SHA *s; +int shadump(char *file, SHA *s) { int i, j; SHA_FILE *f; @@ -542,10 +510,7 @@ SHA *s; } /* fgetstr: reads (and returns pointer to) next line of file */ -static char *fgetstr(line, maxsize, f) -char *line; -UINT maxsize; -SHA_FILE *f; +static char *fgetstr(char *line, UINT maxsize, SHA_FILE *f) { char *p; @@ -559,8 +524,7 @@ SHA_FILE *f; } /* empty: returns true if line contains only whitespace characters */ -static int empty(line) -char *line; +static int empty(char *line) { char *p; @@ -571,9 +535,7 @@ char *line; } /* getval: null-terminates field value, and sets pointer to rest of line */ -static char *getval(line, pprest) -char *line; -char **pprest; +static char *getval(char *line, char **pprest) { char *p, *v; @@ -596,13 +558,13 @@ char **pprest; #define T_Q 4 /* 64-bit value */ /* ldvals: checks next line in dump file against tag, and loads values */ -static int ldvals(f, tag, type, pval, reps, base) -SHA_FILE *f; -char *tag; -int type; -void *pval; -int reps; -int base; +static int ldvals( + SHA_FILE *f, + char *tag, + int type, + void *pval, + int reps, + int base) { char *p, *pr, line[512]; UCHR *pc = (UCHR *) pval; UINT *pi = (UINT *) pval; @@ -627,9 +589,7 @@ int base; } /* closeall: closes dump file and de-allocates digest object */ -static SHA *closeall(f, s) -SHA_FILE *f; -SHA *s; +static SHA *closeall(SHA_FILE *f, SHA *s) { if (f != NULL && f != SHA_stdin()) SHA_close(f); @@ -639,8 +599,7 @@ SHA *s; } /* shaload: creates digest object corresponding to contents of dump file */ -SHA *shaload(file) -char *file; +SHA *shaload(char *file) { int alg; SHA *s = NULL; @@ -671,8 +630,7 @@ char *file; } /* shaclose: de-allocates digest object */ -int shaclose(s) -SHA *s; +int shaclose(SHA *s) { if (s != NULL) { memset(s, 0, sizeof(SHA)); diff --git a/ext/Digest/SHA/src/sha.h b/ext/Digest/SHA/src/sha.h index 122926afc7..305f5d6bd4 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.42 - * Mon Jul 24 04:04:40 MST 2006 + * Version: 5.43 + * Sat Aug 5 02:36:18 MST 2006 * */ @@ -174,9 +174,9 @@ #define SHA_H_SIZE sizeof(SHA32) * 8 #endif -typedef struct { +typedef struct SHA { int alg; - void (*sha)(); + void (*sha)(struct SHA *, unsigned char *); unsigned char H[SHA_H_SIZE]; unsigned char block[SHA_MAX_BLOCK_BITS/8]; unsigned int blockcnt; @@ -192,44 +192,42 @@ typedef struct { #define SHA_FMT_HEX 2 #define SHA_FMT_BASE64 3 -#if defined(__STDC__) && __STDC__ != 0 - #define _SHA_P(protos) protos -#else - #define _SHA_P(protos) () -#endif - #define _SHA_STATE SHA *s #define _SHA_ALG int alg #define _SHA_DATA unsigned char *bitstr, unsigned long bitcnt #define _SHA_FNAME char *filename -SHA *shaopen _SHA_P((_SHA_ALG)); -unsigned long shawrite _SHA_P((_SHA_DATA, _SHA_STATE)); -void shafinish _SHA_P((_SHA_STATE)); -void sharewind _SHA_P((_SHA_STATE)); -unsigned char *shadigest _SHA_P((_SHA_STATE)); -char *shahex _SHA_P((_SHA_STATE)); -char *shabase64 _SHA_P((_SHA_STATE)); -int shadsize _SHA_P((_SHA_STATE)); -SHA *shadup _SHA_P((_SHA_STATE)); -int shadump _SHA_P((_SHA_FNAME, _SHA_STATE)); -SHA *shaload _SHA_P((_SHA_FNAME)); -int shaclose _SHA_P((_SHA_STATE)); - -unsigned char *sha1digest _SHA_P((_SHA_DATA)); -char *sha1hex _SHA_P((_SHA_DATA)); -char *sha1base64 _SHA_P((_SHA_DATA)); -unsigned char *sha224digest _SHA_P((_SHA_DATA)); -char *sha224hex _SHA_P((_SHA_DATA)); -char *sha224base64 _SHA_P((_SHA_DATA)); -unsigned char *sha256digest _SHA_P((_SHA_DATA)); -char *sha256hex _SHA_P((_SHA_DATA)); -char *sha256base64 _SHA_P((_SHA_DATA)); -unsigned char *sha384digest _SHA_P((_SHA_DATA)); -char *sha384hex _SHA_P((_SHA_DATA)); -char *sha384base64 _SHA_P((_SHA_DATA)); -unsigned char *sha512digest _SHA_P((_SHA_DATA)); -char *sha512hex _SHA_P((_SHA_DATA)); -char *sha512base64 _SHA_P((_SHA_DATA)); +SHA *shaopen (_SHA_ALG); +unsigned long shawrite (_SHA_DATA, _SHA_STATE); +void shafinish (_SHA_STATE); +void sharewind (_SHA_STATE); +unsigned char *shadigest (_SHA_STATE); +char *shahex (_SHA_STATE); +char *shabase64 (_SHA_STATE); +int shadsize (_SHA_STATE); +SHA *shadup (_SHA_STATE); +int shadump (_SHA_FNAME, _SHA_STATE); +SHA *shaload (_SHA_FNAME); +int shaclose (_SHA_STATE); + +#ifndef SHA_PERL_MODULE + +unsigned char *sha1digest (_SHA_DATA); +char *sha1hex (_SHA_DATA); +char *sha1base64 (_SHA_DATA); +unsigned char *sha224digest (_SHA_DATA); +char *sha224hex (_SHA_DATA); +char *sha224base64 (_SHA_DATA); +unsigned char *sha256digest (_SHA_DATA); +char *sha256hex (_SHA_DATA); +char *sha256base64 (_SHA_DATA); +unsigned char *sha384digest (_SHA_DATA); +char *sha384hex (_SHA_DATA); +char *sha384base64 (_SHA_DATA); +unsigned char *sha512digest (_SHA_DATA); +char *sha512hex (_SHA_DATA); +char *sha512base64 (_SHA_DATA); + +#endif #endif /* _INCLUDE_SHA_H_ */ diff --git a/ext/Digest/SHA/src/sha64bit.c b/ext/Digest/SHA/src/sha64bit.c index 0e499a6ff3..87a8e43dd6 100644 --- a/ext/Digest/SHA/src/sha64bit.c +++ b/ext/Digest/SHA/src/sha64bit.c @@ -66,8 +66,7 @@ C64(0x1f83d9abfb41bd6b), C64(0x5be0cd19137e2179) }; /* strto64: converts hex string to a 64-bit word */ -static W64 strto64(s) -char *s; +static W64 strto64(char *s) { char str[2] = {0, 0}; W64 u = C64(0); @@ -77,9 +76,7 @@ char *s; return(u); } -static void sha512(s, block) /* SHA-384/512 transform */ -SHA *s; -unsigned char *block; +static void sha512(SHA *s, unsigned char *block) /* SHA-384/512 transform */ { W64 a, b, c, d, e, f, g, h, T1, T2; SHA_STO_CLASS W64 W[80]; |