summaryrefslogtreecommitdiff
path: root/cpan/Digest-SHA
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-03-05 14:49:52 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-03-05 14:49:52 +0000
commita5b310e3129d1a2cd55b8d79445eb65964c997d1 (patch)
treeb52a5d24c5c6f64c130bcda570160536a7702531 /cpan/Digest-SHA
parent8fcd75a0901066653077fee994c723f2d3327555 (diff)
downloadperl-a5b310e3129d1a2cd55b8d79445eb65964c997d1.tar.gz
Update Digest-SHA to CPAN version 5.83
[DELTA] 5.83 Mon Mar 4 08:12:00 MST 2013 - removed code for standalone C operation (no longer used) -- eliminates need for external symbols -- consolidates SHA and HMAC code -- reduces size of object files -- thanks to Marc Lehmann for suggestions - tweaked Makefile.PL to show dependencies of SHA.c
Diffstat (limited to 'cpan/Digest-SHA')
-rw-r--r--cpan/Digest-SHA/Changes8
-rw-r--r--cpan/Digest-SHA/Makefile.PL7
-rw-r--r--cpan/Digest-SHA/README2
-rw-r--r--cpan/Digest-SHA/SHA.xs4
-rw-r--r--cpan/Digest-SHA/lib/Digest/SHA.pm25
-rw-r--r--cpan/Digest-SHA/shasum6
-rw-r--r--cpan/Digest-SHA/src/hmac.c103
-rw-r--r--cpan/Digest-SHA/src/hmac.h64
-rw-r--r--cpan/Digest-SHA/src/hmacxtra.c62
-rw-r--r--cpan/Digest-SHA/src/sha.c124
-rw-r--r--cpan/Digest-SHA/src/sha.h71
-rw-r--r--cpan/Digest-SHA/src/shaxtra.c57
12 files changed, 149 insertions, 384 deletions
diff --git a/cpan/Digest-SHA/Changes b/cpan/Digest-SHA/Changes
index de996623e8..17d67eeed7 100644
--- a/cpan/Digest-SHA/Changes
+++ b/cpan/Digest-SHA/Changes
@@ -1,5 +1,13 @@
Revision history for Perl extension Digest::SHA.
+5.83 Mon Mar 4 08:12:00 MST 2013
+ - removed code for standalone C operation (no longer used)
+ -- eliminates need for external symbols
+ -- consolidates SHA and HMAC code
+ -- reduces size of object files
+ -- thanks to Marc Lehmann for suggestions
+ - tweaked Makefile.PL to show dependencies of SHA.c
+
5.82 Thu Jan 24 04:54:12 MST 2013
- introduced workaround to SvPVbyte bug in Perl 5.6
-- module behavior now consistent under all Perls 5.6+
diff --git a/cpan/Digest-SHA/Makefile.PL b/cpan/Digest-SHA/Makefile.PL
index 721aaeb0c6..f367dfa89b 100644
--- a/cpan/Digest-SHA/Makefile.PL
+++ b/cpan/Digest-SHA/Makefile.PL
@@ -11,7 +11,7 @@ my %opts;
getopts('tx', \%opts); # -t is no longer used, but allow it anyway
my @defines;
-push(@defines, '-DSHA_PERL_MODULE') if $] >= 5.004;
+push(@defines, '-DSHA_PerlIO') if $] >= 5.004;
push(@defines, '-DNO_SHA_384_512') if $opts{'x'};
my $define = join(' ', @defines);
@@ -33,6 +33,10 @@ if ($Config{archname} =~ /^i[3456]86/ && $Config{ccname} eq 'gcc') {
push(@extra, OPTIMIZE => '-O1 -fomit-frame-pointer');
}
+my @srcs = map { "src/$_" } qw(sha.c sha64bit.c);
+my @hdrs = map { "src/$_" } qw(sha.h sha64bit.h);
+my $deps = join(' ', @srcs, @hdrs);
+
my %att = (
'NAME' => 'Digest::SHA',
'VERSION_FROM' => $PM,
@@ -41,6 +45,7 @@ my %att = (
'INC' => '-I.',
'EXE_FILES' => [ 'shasum' ],
'INSTALLDIRS' => ($] >= 5.010 and $] < 5.011) ? 'perl' : 'site',
+ 'depend' => { 'SHA.c' => $deps },
@extra,
);
diff --git a/cpan/Digest-SHA/README b/cpan/Digest-SHA/README
index 510a56c104..7b6f216af1 100644
--- a/cpan/Digest-SHA/README
+++ b/cpan/Digest-SHA/README
@@ -1,4 +1,4 @@
-Digest::SHA version 5.82
+Digest::SHA version 5.83
========================
Digest::SHA is a complete implementation of the NIST Secure Hash
diff --git a/cpan/Digest-SHA/SHA.xs b/cpan/Digest-SHA/SHA.xs
index 3f5d07bf55..b93c232d72 100644
--- a/cpan/Digest-SHA/SHA.xs
+++ b/cpan/Digest-SHA/SHA.xs
@@ -13,7 +13,6 @@
#endif
#include "src/sha.c"
-#include "src/hmac.c"
static int ix2alg[] =
{1,1,1,224,224,224,256,256,256,384,384,384,512,512,512,
@@ -23,9 +22,6 @@ MODULE = Digest::SHA PACKAGE = Digest::SHA
PROTOTYPES: ENABLE
-#include "src/sha.h"
-#include "src/hmac.h"
-
#ifndef INT2PTR
#define INT2PTR(p, i) (p) (i)
#endif
diff --git a/cpan/Digest-SHA/lib/Digest/SHA.pm b/cpan/Digest-SHA/lib/Digest/SHA.pm
index 8372eb0360..0c409f6feb 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.82';
+$VERSION = '5.83';
require Exporter;
require DynaLoader;
@@ -331,17 +331,17 @@ contain wide characters, namely, characters whose ordinal values are
greater than 255. This can cause problems for digest algorithms such
as SHA that are specified to operate on sequences of bytes.
-The rule by which Digest::SHA handles a Unicode string is easy to
-state, but potentially confusing to grasp: the string is interpreted
-as a sequence of bytes, where each byte is equal to the ordinal value
-(viz. code point) of its corresponding Unicode character. That way,
-the Unicode version of the string 'abc' has exactly the same digest
-value as the ordinary string 'abc'.
+The rule by which Digest::SHA handles a Unicode string is easy
+to state, but potentially confusing to grasp: the string is interpreted
+as a sequence of byte values, where each byte value is equal to the
+ordinal value (viz. code point) of its corresponding Unicode character.
+That way, the Unicode string 'abc' has exactly the same digest value as
+the ordinary string 'abc'.
-Since a wide character does not fit into a byte, the Digest::SHA routines
-croak if they encounter one. Whereas if a Unicode string contains no
-wide characters, the module accepts it quite happily. The following
-code illustrates the two cases:
+Since a wide character does not fit into a byte, the Digest::SHA
+routines croak if they encounter one. Whereas if a Unicode string
+contains no wide characters, the module accepts it quite happily.
+The following code illustrates the two cases:
$str1 = pack('U*', (0..255));
print sha1_hex($str1); # ok
@@ -351,7 +351,8 @@ code illustrates the two cases:
Be aware that the digest routines silently convert UTF-8 input into its
equivalent byte sequence in the native encoding (cf. utf8::downgrade).
-This side effect only influences the way Perl stores data internally.
+This side effect influences only the way Perl stores the data internally,
+but otherwise leaves the actual value of the data intact.
=head1 NIST STATEMENT ON SHA-1
diff --git a/cpan/Digest-SHA/shasum b/cpan/Digest-SHA/shasum
index e72ccc6512..ed8ceeea3f 100644
--- a/cpan/Digest-SHA/shasum
+++ b/cpan/Digest-SHA/shasum
@@ -4,8 +4,8 @@
##
## Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved
##
- ## Version: 5.82
- ## Thu Jan 24 04:54:12 MST 2013
+ ## Version: 5.83
+ ## Mon Mar 4 08:12:00 MST 2013
## shasum SYNOPSIS adapted from GNU Coreutils sha1sum.
## Add an "-a" option for algorithm selection, a "-p"
@@ -97,7 +97,7 @@ use strict;
use Fcntl;
use Getopt::Long;
-my $VERSION = "5.82";
+my $VERSION = "5.83";
## Try to use Digest::SHA. If not installed, use the slower
diff --git a/cpan/Digest-SHA/src/hmac.c b/cpan/Digest-SHA/src/hmac.c
deleted file mode 100644
index 7380a74fc5..0000000000
--- a/cpan/Digest-SHA/src/hmac.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * hmac.c: routines to compute HMAC-SHA-1/224/256/384/512 digests
- *
- * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code
- *
- * Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved
- *
- * Version: 5.82
- * Thu Jan 24 04:54:12 MST 2013
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "hmac.h"
-#include "sha.h"
-
-/* hmacopen: creates a new HMAC-SHA digest object */
-HMAC *hmacopen(int alg, unsigned char *key, unsigned int keylen)
-{
- unsigned int i;
- HMAC *h;
-
- SHA_newz(0, h, 1, HMAC);
- if (h == NULL)
- return(NULL);
- if ((h->isha = shaopen(alg)) == NULL) {
- SHA_free(h);
- return(NULL);
- }
- if ((h->osha = shaopen(alg)) == NULL) {
- shaclose(h->isha);
- SHA_free(h);
- return(NULL);
- }
- if (keylen <= h->osha->blocksize / 8)
- memcpy(h->key, key, keylen);
- else {
- if ((h->ksha = shaopen(alg)) == NULL) {
- shaclose(h->isha);
- shaclose(h->osha);
- SHA_free(h);
- return(NULL);
- }
- shawrite(key, keylen * 8, h->ksha);
- shafinish(h->ksha);
- memcpy(h->key, shadigest(h->ksha), h->ksha->digestlen);
- shaclose(h->ksha);
- }
- for (i = 0; i < h->osha->blocksize / 8; i++)
- h->key[i] ^= 0x5c;
- shawrite(h->key, h->osha->blocksize, h->osha);
- for (i = 0; i < h->isha->blocksize / 8; i++)
- h->key[i] ^= (0x5c ^ 0x36);
- shawrite(h->key, h->isha->blocksize, h->isha);
- memset(h->key, 0, sizeof(h->key));
- return(h);
-}
-
-/* hmacwrite: triggers a state update using data in bitstr/bitcnt */
-unsigned long hmacwrite(unsigned char *bitstr, unsigned long bitcnt, HMAC *h)
-{
- return(shawrite(bitstr, bitcnt, h->isha));
-}
-
-/* hmacfinish: computes final digest state */
-void hmacfinish(HMAC *h)
-{
- shafinish(h->isha);
- shawrite(shadigest(h->isha), h->isha->digestlen * 8, h->osha);
- shaclose(h->isha);
- shafinish(h->osha);
-}
-
-/* hmacdigest: returns pointer to digest (binary) */
-unsigned char *hmacdigest(HMAC *h)
-{
- return(shadigest(h->osha));
-}
-
-/* hmachex: returns pointer to digest (hexadecimal) */
-char *hmachex(HMAC *h)
-{
- return(shahex(h->osha));
-}
-
-/* hmacbase64: returns pointer to digest (Base 64) */
-char *hmacbase64(HMAC *h)
-{
- return(shabase64(h->osha));
-}
-
-/* hmacclose: de-allocates digest object */
-int hmacclose(HMAC *h)
-{
- if (h != NULL) {
- shaclose(h->osha);
- memset(h, 0, sizeof(HMAC));
- SHA_free(h);
- }
- return(0);
-}
diff --git a/cpan/Digest-SHA/src/hmac.h b/cpan/Digest-SHA/src/hmac.h
deleted file mode 100644
index 6fb860225e..0000000000
--- a/cpan/Digest-SHA/src/hmac.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * hmac.h: header file for HMAC-SHA-1/224/256/384/512 routines
- *
- * Ref: FIPS PUB 198 The Keyed-Hash Message Authentication Code
- *
- * Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved
- *
- * Version: 5.82
- * Thu Jan 24 04:54:12 MST 2013
- *
- */
-
-#ifndef _INCLUDE_HMAC_H_
-#define _INCLUDE_HMAC_H_
-
-#include "sha.h"
-
-typedef struct {
- SHA *ksha;
- SHA *isha;
- SHA *osha;
- unsigned char key[SHA_MAX_BLOCK_BITS/8];
-} HMAC;
-
-#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_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);
-unsigned char *hmac512224digest (_HMAC_DATA, _HMAC_KEY);
-char *hmac512224hex (_HMAC_DATA, _HMAC_KEY);
-char *hmac512224base64 (_HMAC_DATA, _HMAC_KEY);
-unsigned char *hmac512256digest (_HMAC_DATA, _HMAC_KEY);
-char *hmac512256hex (_HMAC_DATA, _HMAC_KEY);
-char *hmac512256base64 (_HMAC_DATA, _HMAC_KEY);
-
-#endif
-
-#endif /* _INCLUDE_HMAC_H_ */
diff --git a/cpan/Digest-SHA/src/hmacxtra.c b/cpan/Digest-SHA/src/hmacxtra.c
deleted file mode 100644
index 041a291041..0000000000
--- a/cpan/Digest-SHA/src/hmacxtra.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "hmac.h"
-
-static unsigned char *hmaccomp(alg, fmt, bitstr, bitcnt, key, keylen)
-int alg;
-int fmt;
-unsigned char *bitstr;
-unsigned long bitcnt;
-unsigned char *key;
-unsigned int keylen;
-{
- HMAC *h;
- static unsigned char digest[SHA_MAX_HEX_LEN+1];
- unsigned char *ret = digest;
-
- if ((h = hmacopen(alg, key, keylen)) == NULL)
- return(NULL);
- hmacwrite(bitstr, bitcnt, h);
- hmacfinish(h);
- if (fmt == SHA_FMT_RAW)
- memcpy(digest, hmacdigest(h), h->osha->digestlen);
- else if (fmt == SHA_FMT_HEX)
- strcpy((char *) digest, hmachex(h));
- else if (fmt == SHA_FMT_BASE64)
- strcpy((char *) digest, hmacbase64(h));
- else
- ret = NULL;
- hmacclose(h);
- return(ret);
-}
-
-#define HMAC_DIRECT(type, name, alg, fmt) \
-type name(bitstr, bitcnt, key, keylen) \
-unsigned char *bitstr; \
-unsigned long bitcnt; \
-unsigned char *key; \
-unsigned int keylen; \
-{ \
- return((type) hmaccomp(alg, fmt, bitstr, bitcnt, \
- key, keylen)); \
-}
-
-HMAC_DIRECT(unsigned char *, hmac1digest, SHA1, SHA_FMT_RAW)
-HMAC_DIRECT(char *, hmac1hex, SHA1, SHA_FMT_HEX)
-HMAC_DIRECT(char *, hmac1base64, SHA1, SHA_FMT_BASE64)
-
-HMAC_DIRECT(unsigned char *, hmac224digest, SHA224, SHA_FMT_RAW)
-HMAC_DIRECT(char *, hmac224hex, SHA224, SHA_FMT_HEX)
-HMAC_DIRECT(char *, hmac224base64, SHA224, SHA_FMT_BASE64)
-
-HMAC_DIRECT(unsigned char *, hmac256digest, SHA256, SHA_FMT_RAW)
-HMAC_DIRECT(char *, hmac256hex, SHA256, SHA_FMT_HEX)
-HMAC_DIRECT(char *, hmac256base64, SHA256, SHA_FMT_BASE64)
-
-HMAC_DIRECT(unsigned char *, hmac384digest, SHA384, SHA_FMT_RAW)
-HMAC_DIRECT(char *, hmac384hex, SHA384, SHA_FMT_HEX)
-HMAC_DIRECT(char *, hmac384base64, SHA384, SHA_FMT_BASE64)
-
-HMAC_DIRECT(unsigned char *, hmac512digest, SHA512, SHA_FMT_RAW)
-HMAC_DIRECT(char *, hmac512hex, SHA512, SHA_FMT_HEX)
-HMAC_DIRECT(char *, hmac512base64, SHA512, SHA_FMT_BASE64)
diff --git a/cpan/Digest-SHA/src/sha.c b/cpan/Digest-SHA/src/sha.c
index 61b782e7d3..5c2f417f8d 100644
--- a/cpan/Digest-SHA/src/sha.c
+++ b/cpan/Digest-SHA/src/sha.c
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved
*
- * Version: 5.82
- * Thu Jan 24 04:54:12 MST 2013
+ * Version: 5.83
+ * Mon Mar 4 08:12:00 MST 2013
*
*/
@@ -258,7 +258,7 @@ static void digcpy(SHA *s)
} while (0)
/* sharewind: re-initializes the digest object */
-void sharewind(SHA *s)
+static void sharewind(SHA *s)
{
if (s->alg == SHA1) SHA_INIT(1, 1);
else if (s->alg == SHA224) SHA_INIT(224, 256);
@@ -270,7 +270,7 @@ void sharewind(SHA *s)
}
/* shaopen: creates a new digest object */
-SHA *shaopen(int alg)
+static SHA *shaopen(int alg)
{
SHA *s = NULL;
@@ -288,6 +288,16 @@ SHA *shaopen(int alg)
return(s);
}
+/* shaclose: de-allocates digest object */
+static int shaclose(SHA *s)
+{
+ if (s != NULL) {
+ memset(s, 0, sizeof(SHA));
+ SHA_free(s);
+ }
+ return(0);
+}
+
/* shadirect: updates state directly (w/o going through s->block) */
static ULNG shadirect(UCHR *bitstr, ULNG bitcnt, SHA *s)
{
@@ -365,7 +375,7 @@ static ULNG shabits(UCHR *bitstr, ULNG bitcnt, SHA *s)
}
/* shawrite: triggers a state update using data in bitstr/bitcnt */
-ULNG shawrite(UCHR *bitstr, ULNG bitcnt, SHA *s)
+static ULNG shawrite(UCHR *bitstr, ULNG bitcnt, SHA *s)
{
if (bitcnt < 1)
return(0);
@@ -382,7 +392,7 @@ ULNG shawrite(UCHR *bitstr, ULNG bitcnt, SHA *s)
}
/* shafinish: pads remaining block(s) and computes final digest state */
-void shafinish(SHA *s)
+static void shafinish(SHA *s)
{
UINT lenpos, lhpos, llpos;
@@ -407,14 +417,14 @@ void shafinish(SHA *s)
}
/* shadigest: returns pointer to current digest (binary) */
-UCHR *shadigest(SHA *s)
+static UCHR *shadigest(SHA *s)
{
digcpy(s);
return(s->digest);
}
/* shahex: returns pointer to current digest (hexadecimal) */
-char *shahex(SHA *s)
+static char *shahex(SHA *s)
{
int i;
@@ -448,7 +458,7 @@ static void encbase64(UCHR *in, int n, char *out)
}
/* shabase64: returns pointer to current digest (Base 64) */
-char *shabase64(SHA *s)
+static char *shabase64(SHA *s)
{
int n;
UCHR *q;
@@ -468,19 +478,19 @@ char *shabase64(SHA *s)
}
/* shadsize: returns length of digest in bytes */
-int shadsize(SHA *s)
+static int shadsize(SHA *s)
{
return(s->digestlen);
}
/* shaalg: returns which SHA algorithm is being used */
-int shaalg(SHA *s)
+static int shaalg(SHA *s)
{
return(s->alg);
}
/* shadup: duplicates current digest object */
-SHA *shadup(SHA *s)
+static SHA *shadup(SHA *s)
{
SHA *p;
@@ -492,7 +502,7 @@ SHA *shadup(SHA *s)
}
/* shadump: dumps digest object to a human-readable ASCII file */
-int shadump(char *file, SHA *s)
+static int shadump(char *file, SHA *s)
{
int i, j;
SHA_FILE *f;
@@ -608,7 +618,7 @@ static SHA *closeall(SHA_FILE *f, SHA *s)
}
/* shaload: creates digest object corresponding to contents of dump file */
-SHA *shaload(char *file)
+static SHA *shaload(char *file)
{
int alg;
SHA *s = NULL;
@@ -638,12 +648,88 @@ SHA *shaload(char *file)
return(s);
}
-/* shaclose: de-allocates digest object */
-int shaclose(SHA *s)
+/* hmacopen: creates a new HMAC-SHA digest object */
+static HMAC *hmacopen(int alg, UCHR *key, UINT keylen)
{
- if (s != NULL) {
- memset(s, 0, sizeof(SHA));
- SHA_free(s);
+ UINT i;
+ HMAC *h;
+
+ SHA_newz(0, h, 1, HMAC);
+ if (h == NULL)
+ return(NULL);
+ if ((h->isha = shaopen(alg)) == NULL) {
+ SHA_free(h);
+ return(NULL);
+ }
+ if ((h->osha = shaopen(alg)) == NULL) {
+ shaclose(h->isha);
+ SHA_free(h);
+ return(NULL);
+ }
+ if (keylen <= h->osha->blocksize / 8)
+ memcpy(h->key, key, keylen);
+ else {
+ if ((h->ksha = shaopen(alg)) == NULL) {
+ shaclose(h->isha);
+ shaclose(h->osha);
+ SHA_free(h);
+ return(NULL);
+ }
+ shawrite(key, keylen * 8, h->ksha);
+ shafinish(h->ksha);
+ memcpy(h->key, shadigest(h->ksha), h->ksha->digestlen);
+ shaclose(h->ksha);
+ }
+ for (i = 0; i < h->osha->blocksize / 8; i++)
+ h->key[i] ^= 0x5c;
+ shawrite(h->key, h->osha->blocksize, h->osha);
+ for (i = 0; i < h->isha->blocksize / 8; i++)
+ h->key[i] ^= (0x5c ^ 0x36);
+ shawrite(h->key, h->isha->blocksize, h->isha);
+ memset(h->key, 0, sizeof(h->key));
+ return(h);
+}
+
+/* hmacwrite: triggers a state update using data in bitstr/bitcnt */
+static ULNG hmacwrite(UCHR *bitstr, ULNG bitcnt, HMAC *h)
+{
+ return(shawrite(bitstr, bitcnt, h->isha));
+}
+
+/* hmacfinish: computes final digest state */
+static void hmacfinish(HMAC *h)
+{
+ shafinish(h->isha);
+ shawrite(shadigest(h->isha), h->isha->digestlen * 8, h->osha);
+ shaclose(h->isha);
+ shafinish(h->osha);
+}
+
+/* hmacdigest: returns pointer to digest (binary) */
+static UCHR *hmacdigest(HMAC *h)
+{
+ return(shadigest(h->osha));
+}
+
+/* hmachex: returns pointer to digest (hexadecimal) */
+static char *hmachex(HMAC *h)
+{
+ return(shahex(h->osha));
+}
+
+/* hmacbase64: returns pointer to digest (Base 64) */
+static char *hmacbase64(HMAC *h)
+{
+ return(shabase64(h->osha));
+}
+
+/* hmacclose: de-allocates digest object */
+static int hmacclose(HMAC *h)
+{
+ if (h != NULL) {
+ shaclose(h->osha);
+ memset(h, 0, sizeof(HMAC));
+ SHA_free(h);
}
return(0);
}
diff --git a/cpan/Digest-SHA/src/sha.h b/cpan/Digest-SHA/src/sha.h
index 7103493e01..1633763869 100644
--- a/cpan/Digest-SHA/src/sha.h
+++ b/cpan/Digest-SHA/src/sha.h
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2013 Mark Shelor, All Rights Reserved
*
- * Version: 5.82
- * Thu Jan 24 04:54:12 MST 2013
+ * Version: 5.83
+ * Mon Mar 4 08:12:00 MST 2013
*
*/
@@ -102,11 +102,11 @@
(SHA64) b[6] << 8 | (SHA64) b[7]; }
#endif
-/* Configure memory management and I/O for Perl or standalone C */
-#ifdef SHA_PERL_MODULE
- #define SHA_new New
- #define SHA_newz Newz
- #define SHA_free Safefree
+#define SHA_new New
+#define SHA_newz Newz
+#define SHA_free Safefree
+
+#ifdef SHA_PerlIO
#define SHA_FILE PerlIO
#define SHA_stdin() PerlIO_stdin()
#define SHA_stdout() PerlIO_stdout()
@@ -116,9 +116,6 @@
#define SHA_feof PerlIO_eof
#define SHA_getc PerlIO_getc
#else
- #define SHA_new(id, p, n, t) p = (t *) malloc(sizeof(t))
- #define SHA_newz(id, p, n, t) p = (t *) calloc(n, sizeof(t))
- #define SHA_free free
#define SHA_FILE FILE
#define SHA_stdin() stdin
#define SHA_stdout() stdout
@@ -178,53 +175,11 @@ typedef struct SHA {
char base64[SHA_MAX_BASE64_LEN+1];
} SHA;
-#define SHA_FMT_RAW 1
-#define SHA_FMT_HEX 2
-#define SHA_FMT_BASE64 3
-
-#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_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);
-int shaalg (_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);
-unsigned char *sha512224digest (_SHA_DATA);
-char *sha512224hex (_SHA_DATA);
-char *sha512224base64 (_SHA_DATA);
-unsigned char *sha512256digest (_SHA_DATA);
-char *sha512256hex (_SHA_DATA);
-char *sha512256base64 (_SHA_DATA);
-
-#endif
+typedef struct {
+ SHA *ksha;
+ SHA *isha;
+ SHA *osha;
+ unsigned char key[SHA_MAX_BLOCK_BITS/8];
+} HMAC;
#endif /* _INCLUDE_SHA_H_ */
diff --git a/cpan/Digest-SHA/src/shaxtra.c b/cpan/Digest-SHA/src/shaxtra.c
deleted file mode 100644
index 7301fc7cc1..0000000000
--- a/cpan/Digest-SHA/src/shaxtra.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "sha.h"
-
-static unsigned char *shacomp(alg, fmt, bitstr, bitcnt)
-int alg;
-int fmt;
-unsigned char *bitstr;
-unsigned long bitcnt;
-{
- SHA *s;
- static unsigned char digest[SHA_MAX_HEX_LEN+1];
- unsigned char *ret = digest;
-
- if ((s = shaopen(alg)) == NULL)
- return(NULL);
- shawrite(bitstr, bitcnt, s);
- shafinish(s);
- if (fmt == SHA_FMT_RAW)
- memcpy(digest, shadigest(s), s->digestlen);
- else if (fmt == SHA_FMT_HEX)
- strcpy((char *) digest, shahex(s));
- else if (fmt == SHA_FMT_BASE64)
- strcpy((char *) digest, shabase64(s));
- else
- ret = NULL;
- shaclose(s);
- return(ret);
-}
-
-#define SHA_DIRECT(type, name, alg, fmt) \
-type name(bitstr, bitcnt) \
-unsigned char *bitstr; \
-unsigned long bitcnt; \
-{ \
- return((type) shacomp(alg, fmt, bitstr, bitcnt)); \
-}
-
-SHA_DIRECT(unsigned char *, sha1digest, SHA1, SHA_FMT_RAW)
-SHA_DIRECT(char *, sha1hex, SHA1, SHA_FMT_HEX)
-SHA_DIRECT(char *, sha1base64, SHA1, SHA_FMT_BASE64)
-
-SHA_DIRECT(unsigned char *, sha224digest, SHA224, SHA_FMT_RAW)
-SHA_DIRECT(char *, sha224hex, SHA224, SHA_FMT_HEX)
-SHA_DIRECT(char *, sha224base64, SHA224, SHA_FMT_BASE64)
-
-SHA_DIRECT(unsigned char *, sha256digest, SHA256, SHA_FMT_RAW)
-SHA_DIRECT(char *, sha256hex, SHA256, SHA_FMT_HEX)
-SHA_DIRECT(char *, sha256base64, SHA256, SHA_FMT_BASE64)
-
-SHA_DIRECT(unsigned char *, sha384digest, SHA384, SHA_FMT_RAW)
-SHA_DIRECT(char *, sha384hex, SHA384, SHA_FMT_HEX)
-SHA_DIRECT(char *, sha384base64, SHA384, SHA_FMT_BASE64)
-
-SHA_DIRECT(unsigned char *, sha512digest, SHA512, SHA_FMT_RAW)
-SHA_DIRECT(char *, sha512hex, SHA512, SHA_FMT_HEX)
-SHA_DIRECT(char *, sha512base64, SHA512, SHA_FMT_BASE64)