summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog31
-rw-r--r--ext/digest/digest.c64
-rw-r--r--ext/digest/digest.h6
-rw-r--r--ext/digest/md5/md5.c20
-rw-r--r--ext/digest/md5/md5.h7
-rw-r--r--ext/digest/md5/md5init.c3
-rw-r--r--ext/digest/md5/md5ossl.c8
-rw-r--r--ext/digest/md5/md5ossl.h2
-rw-r--r--ext/digest/rmd160/depend2
-rw-r--r--ext/digest/rmd160/extconf.rb2
-rw-r--r--ext/digest/rmd160/rmd160.c2
-rw-r--r--ext/digest/rmd160/rmd160.h14
-rw-r--r--ext/digest/rmd160/rmd160hl.c96
-rw-r--r--ext/digest/rmd160/rmd160init.c3
-rw-r--r--ext/digest/rmd160/rmd160ossl.c27
-rw-r--r--ext/digest/rmd160/rmd160ossl.h3
-rw-r--r--ext/digest/sha1/extconf.rb2
-rw-r--r--ext/digest/sha1/sha1.c16
-rw-r--r--ext/digest/sha1/sha1.h15
-rw-r--r--ext/digest/sha1/sha1hl.c102
-rw-r--r--ext/digest/sha1/sha1init.c3
-rw-r--r--ext/digest/sha1/sha1ossl.c32
-rw-r--r--ext/digest/sha1/sha1ossl.h2
-rw-r--r--ext/digest/sha2/extconf.rb1
-rw-r--r--ext/digest/sha2/sha2.c6
-rw-r--r--ext/digest/sha2/sha2.h30
-rw-r--r--ext/digest/sha2/sha2hl.c252
-rw-r--r--ext/digest/sha2/sha2init.c3
28 files changed, 123 insertions, 631 deletions
diff --git a/ChangeLog b/ChangeLog
index fb4a8e59aa..f92ec8d035 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+Thu Oct 5 19:28:35 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/digest.[ch]: Since the argument order of
+ hash_final_func_t was inconsistent with others, change it and
+ rename to hash_finish_func_t to avoid confusion.
+
+ * ext/digest/digest.[ch]: Remove and eliminate the use of
+ hash_end_func_t. Implement hexdigest conversion in the base
+ class.
+
+ * ext/digest/md5/md5.c, ext/digest/md5/md5.h,
+ ext/digest/md5/md5init.c, ext/digest/md5/md5ossl.c,
+ ext/digest/md5/md5ossl.h: Remove MD5_End() and change
+ MD5_Final() to MD5_Finish().
+
+ * ext/digest/rmd160/depend, ext/digest/rmd160/extconf.rb,
+ ext/digest/rmd160/rmd160.c, ext/digest/rmd160/rmd160.h,
+ ext/digest/rmd160/rmd160hl.c, ext/digest/rmd160/rmd160init.c,
+ ext/digest/rmd160/rmd160ossl.c, ext/digest/rmd160/rmd160ossl.h:
+ Remove unused functions RMD160_End(), RMD160_File(),
+ RMD160_Data() and change RMD160_Final() to RMD160_Finish().
+
+ * ext/digest/sha1/extconf.rb, ext/digest/sha1/sha1.c,
+ ext/digest/sha1/sha1.h, ext/digest/sha1/sha1hl.c,
+ ext/digest/sha1/sha1init.c, ext/digest/sha1/sha1ossl.c,
+ ext/digest/sha1/sha1ossl.h: Likewise.
+
+ * ext/digest/sha2/extconf.rb, ext/digest/sha2/sha2.c,
+ ext/digest/sha2/sha2.h, ext/digest/sha2/sha2hl.c,
+ ext/digest/sha2/sha2init.c: Likewise.
+
Wed Oct 4 18:47:25 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: bugfix and update
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index a2e0d55c91..f56a1921f8 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -40,6 +40,26 @@ get_digest_base_metadata(VALUE klass)
}
static VALUE
+hexdigest_str_new(const unsigned char *digest, size_t digest_len)
+{
+ int i;
+ VALUE str;
+ char *p;
+ static const char hex[] = "0123456789abcdef";
+
+ str = rb_str_new(0, digest_len * 2);
+
+ for (i = 0, p = RSTRING_PTR(str); i < digest_len; i++) {
+ unsigned char byte = digest[i];
+
+ p[i + i] = hex[byte >> 4];
+ p[i + i + 1] = hex[byte & 0x0f];
+ }
+
+ return str;
+}
+
+static VALUE
rb_digest_base_alloc(VALUE klass)
{
algo_t *algo;
@@ -52,7 +72,7 @@ rb_digest_base_alloc(VALUE klass)
algo = get_digest_base_metadata(klass);
- /* XXX: An uninitialized buffer leads ALGO_Equal() to fail */
+ /* XXX: An uninitialized buffer may lead ALGO_Equal() to fail */
pctx = xcalloc(algo->ctx_size, 1);
algo->init_func(pctx);
@@ -75,7 +95,7 @@ rb_digest_base_s_digest(VALUE klass, VALUE str)
algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
str = rb_str_new(0, algo->digest_len);
- algo->final_func(RSTRING_PTR(str), pctx);
+ algo->finish_func(pctx, RSTRING_PTR(str));
return str;
}
@@ -85,6 +105,8 @@ rb_digest_base_s_hexdigest(VALUE klass, VALUE str)
{
algo_t *algo;
void *pctx;
+ void *digest;
+ size_t len;
volatile VALUE obj = rb_digest_base_alloc(klass);
algo = get_digest_base_metadata(klass);
@@ -93,10 +115,11 @@ rb_digest_base_s_hexdigest(VALUE klass, VALUE str)
StringValue(str);
algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
- str = rb_str_new(0, algo->digest_len * 2);
- algo->end_func(pctx, RSTRING_PTR(str));
+ len = algo->digest_len;
+ digest = xmalloc(len);
+ algo->finish_func(pctx, digest);
- return str;
+ return hexdigest_str_new(digest, len);
}
static VALUE
@@ -150,19 +173,18 @@ rb_digest_base_digest(VALUE self)
{
algo_t *algo;
void *pctx1, *pctx2;
- size_t len;
+ size_t ctx_size;
VALUE str;
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx1);
- str = rb_str_new(0, algo->digest_len);
-
- len = algo->ctx_size;
- pctx2 = xmalloc(len);
- memcpy(pctx2, pctx1, len);
+ ctx_size = algo->ctx_size;
+ pctx2 = xmalloc(ctx_size);
+ memcpy(pctx2, pctx1, ctx_size);
- algo->final_func(RSTRING_PTR(str), pctx2);
+ str = rb_str_new(0, algo->digest_len);
+ algo->finish_func(pctx2, RSTRING_PTR(str));
free(pctx2);
return str;
@@ -173,22 +195,22 @@ rb_digest_base_hexdigest(VALUE self)
{
algo_t *algo;
void *pctx1, *pctx2;
- size_t len;
- VALUE str;
+ void *digest;
+ size_t ctx_size, len;
algo = get_digest_base_metadata(rb_obj_class(self));
Data_Get_Struct(self, void, pctx1);
- str = rb_str_new(0, algo->digest_len * 2);
+ ctx_size = algo->ctx_size;
+ pctx2 = xmalloc(ctx_size);
+ memcpy(pctx2, pctx1, ctx_size);
- len = algo->ctx_size;
- pctx2 = xmalloc(len);
- memcpy(pctx2, pctx1, len);
-
- algo->end_func(pctx2, RSTRING_PTR(str));
+ len = algo->digest_len;
+ digest = xmalloc(len);
+ algo->finish_func(pctx2, digest);
free(pctx2);
- return str;
+ return hexdigest_str_new(digest, len);
}
static VALUE
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 878aaddd02..d9e5c70096 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -17,8 +17,7 @@
typedef void (*hash_init_func_t)(void *);
typedef void (*hash_update_func_t)(void *, unsigned char *, size_t);
-typedef void (*hash_end_func_t)(void *, unsigned char *);
-typedef void (*hash_final_func_t)(unsigned char *, void *);
+typedef void (*hash_finish_func_t)(void *, unsigned char *);
typedef int (*hash_equal_func_t)(void *, void *);
typedef struct {
@@ -26,7 +25,6 @@ typedef struct {
size_t ctx_size;
hash_init_func_t init_func;
hash_update_func_t update_func;
- hash_end_func_t end_func;
- hash_final_func_t final_func;
+ hash_finish_func_t finish_func;
hash_equal_func_t equal_func;
} algo_t;
diff --git a/ext/digest/md5/md5.c b/ext/digest/md5/md5.c
index 6b61f031c4..8f49476a19 100644
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -41,6 +41,12 @@
1999-05-03 lpd Original version.
*/
+/*
+ This code was modified for use in Ruby.
+
+ - Akinori MUSHA <knu@idaemons.org>
+ */
+
/*$OrigId: md5c.c,v 1.2 2001/03/26 08:57:14 matz Exp $ */
/*$RoughId: md5.c,v 1.2 2001/07/13 19:48:41 knu Exp $ */
/*$Id$ */
@@ -391,7 +397,7 @@ MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
}
void
-MD5_Final(uint8_t *digest, MD5_CTX *pms)
+MD5_Finish(MD5_CTX *pms, uint8_t *digest)
{
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -413,18 +419,6 @@ MD5_Final(uint8_t *digest, MD5_CTX *pms)
digest[i] = (uint8_t)(pms->state[i >> 2] >> ((i & 3) << 3));
}
-void
-MD5_End(MD5_CTX *pctx, uint8_t *hexdigest)
-{
- unsigned char digest[16];
- size_t i;
-
- MD5_Final(digest, pctx);
-
- for (i = 0; i < 16; i++)
- sprintf(hexdigest + i * 2, "%02x", digest[i]);
-}
-
int MD5_Equal(MD5_CTX* pctx1, MD5_CTX* pctx2) {
return memcmp(pctx1->count, pctx2->count, sizeof(pctx1->count)) == 0
&& memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
diff --git a/ext/digest/md5/md5.h b/ext/digest/md5/md5.h
index fc41380d38..a5de6fd97e 100644
--- a/ext/digest/md5/md5.h
+++ b/ext/digest/md5/md5.h
@@ -63,17 +63,16 @@ typedef struct md5_state_s {
} MD5_CTX;
#ifdef RUBY
+/* avoid name clash */
#define MD5_Init rb_Digest_MD5_Init
#define MD5_Update rb_Digest_MD5_Update
-#define MD5_Final rb_Digest_MD5_Final
-#define MD5_End rb_Digest_MD5_End
+#define MD5_Finish rb_Digest_MD5_Finish
#define MD5_Equal rb_Digest_MD5_Equal
#endif
void MD5_Init _((MD5_CTX *pms));
void MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
-void MD5_Final _((uint8_t *digest, MD5_CTX *pms));
-void MD5_End _((MD5_CTX *pctx, uint8_t *hexdigest));
+void MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
int MD5_Equal _((MD5_CTX *pctx1, MD5_CTX *pctx2));
#define MD5_BLOCK_LENGTH 64
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
index 3de597dc89..5fddb21c65 100644
--- a/ext/digest/md5/md5init.c
+++ b/ext/digest/md5/md5init.c
@@ -13,8 +13,7 @@ static algo_t md5 = {
sizeof(MD5_CTX),
(hash_init_func_t)MD5_Init,
(hash_update_func_t)MD5_Update,
- (hash_end_func_t)MD5_End,
- (hash_final_func_t)MD5_Final,
+ (hash_finish_func_t)MD5_Finish,
(hash_equal_func_t)MD5_Equal,
};
diff --git a/ext/digest/md5/md5ossl.c b/ext/digest/md5/md5ossl.c
index d930c7ab51..963243c7c9 100644
--- a/ext/digest/md5/md5ossl.c
+++ b/ext/digest/md5/md5ossl.c
@@ -6,15 +6,9 @@
#include <string.h>
void
-MD5_End(MD5_CTX *pctx, unsigned char *hexdigest)
+MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
{
- unsigned char digest[16];
- size_t i;
-
MD5_Final(digest, pctx);
-
- for (i = 0; i < 16; i++)
- sprintf(hexdigest + i * 2, "%02x", digest[i]);
}
int
diff --git a/ext/digest/md5/md5ossl.h b/ext/digest/md5/md5ossl.h
index 610f58db06..bccbe05f2a 100644
--- a/ext/digest/md5/md5ossl.h
+++ b/ext/digest/md5/md5ossl.h
@@ -6,7 +6,7 @@
#include <stddef.h>
#include <openssl/md5.h>
-void MD5_End(MD5_CTX *pctx, unsigned char *hexdigest);
+void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
int MD5_Equal(MD5_CTX *pctx1, MD5_CTX *pctx2);
#endif
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index 0ca79c5f40..a21d7188dc 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -1,7 +1,5 @@
rmd160.o: rmd160.c rmd160.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
$(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
-rmd160hl.o: rmd160hl.c rmd160.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
- $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
rmd160init.o: rmd160init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
$(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
rmd160.h $(srcdir)/../defs.h
diff --git a/ext/digest/rmd160/extconf.rb b/ext/digest/rmd160/extconf.rb
index d38dadd041..09359944f2 100644
--- a/ext/digest/rmd160/extconf.rb
+++ b/ext/digest/rmd160/extconf.rb
@@ -14,7 +14,7 @@ if !with_config("bundled-rmd160") &&
have_library("crypto") && have_header("openssl/ripemd.h")
$objs << "rmd160ossl.#{$OBJEXT}"
else
- $objs << "rmd160.#{$OBJEXT}" << "rmd160hl.#{$OBJEXT}"
+ $objs << "rmd160.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
diff --git a/ext/digest/rmd160/rmd160.c b/ext/digest/rmd160/rmd160.c
index 2de3c99b29..64ec0fb427 100644
--- a/ext/digest/rmd160/rmd160.c
+++ b/ext/digest/rmd160/rmd160.c
@@ -409,7 +409,7 @@ RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
/********************************************************************/
void
-RMD160_Final(uint8_t digest[20], RMD160_CTX *context)
+RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
{
uint32_t i;
uint32_t X[16];
diff --git a/ext/digest/rmd160/rmd160.h b/ext/digest/rmd160/rmd160.h
index 24f9a025f0..ac52fb0ec3 100644
--- a/ext/digest/rmd160/rmd160.h
+++ b/ext/digest/rmd160/rmd160.h
@@ -39,26 +39,16 @@ typedef struct {
#define RMD160_Init rb_Digest_RMD160_Init
#define RMD160_Transform rb_Digest_RMD160_Transform
#define RMD160_Update rb_Digest_RMD160_Update
-#define RMD160_Final rb_Digest_RMD160_Final
+#define RMD160_Finish rb_Digest_RMD160_Finish
#define RMD160_Equal rb_Digest_RMD160_Equal
-#ifndef _KERNEL
-#define RMD160_End rb_Digest_RMD160_End
-#define RMD160_File rb_Digest_RMD160_File
-#define RMD160_Data rb_Digest_RMD160_Data
-#endif /* _KERNEL */
#endif
__BEGIN_DECLS
void RMD160_Init _((RMD160_CTX *));
void RMD160_Transform _((uint32_t[5], const uint32_t[16]));
void RMD160_Update _((RMD160_CTX *, const uint8_t *, size_t));
-void RMD160_Final _((uint8_t[20], RMD160_CTX *));
+void RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
int RMD160_Equal _((RMD160_CTX *, RMD160_CTX *));
-#ifndef _KERNEL
-char *RMD160_End _((RMD160_CTX *, char *));
-char *RMD160_File _((char *, char *));
-char *RMD160_Data _((const uint8_t *, size_t, char *));
-#endif /* _KERNEL */
__END_DECLS
#define RMD160_BLOCK_LENGTH 64
diff --git a/ext/digest/rmd160/rmd160hl.c b/ext/digest/rmd160/rmd160hl.c
deleted file mode 100644
index 4c5e0217d9..0000000000
--- a/ext/digest/rmd160/rmd160hl.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* $NetBSD: rmd160hl.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $ */
-/* $RoughId: rmd160hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
-/* $Id$ */
-
-/* rmd160hl.c
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * from OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $
- */
-
-#include "rmd160.h"
-
-#ifndef lint
-/* __RCSID("$NetBSD: rmd160hl.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $"); */
-#endif /* not lint */
-
-/* #include "namespace.h" */
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if defined(HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-
-char *
-RMD160_End(RMD160_CTX *ctx, char *buf)
-{
- size_t i;
- char *p = buf;
- uint8_t digest[20];
- static const char hex[]="0123456789abcdef";
-
- _DIAGASSERT(ctx != NULL);
- /* buf may be NULL */
-
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
-
- RMD160_Final(digest,ctx);
- for (i = 0; i < 20; i++) {
- p[i + i] = hex[(uint32_t)digest[i] >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
- }
- p[i + i] = '\0';
- return(p);
-}
-
-char *
-RMD160_File(char *filename, char *buf)
-{
- uint8_t buffer[BUFSIZ];
- RMD160_CTX ctx;
- int fd, num, oerrno;
-
- _DIAGASSERT(filename != NULL);
- /* XXX: buf may be NULL ? */
-
- RMD160_Init(&ctx);
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return(0);
-
- while ((num = read(fd, buffer, sizeof(buffer))) > 0)
- RMD160_Update(&ctx, buffer, (size_t)num);
-
- oerrno = errno;
- close(fd);
- errno = oerrno;
- return(num < 0 ? 0 : RMD160_End(&ctx, buf));
-}
-
-char *
-RMD160_Data(const uint8_t *data, size_t len, char *buf)
-{
- RMD160_CTX ctx;
-
- _DIAGASSERT(data != NULL);
- /* XXX: buf may be NULL ? */
-
- RMD160_Init(&ctx);
- RMD160_Update(&ctx, data, len);
- return(RMD160_End(&ctx, buf));
-}
diff --git a/ext/digest/rmd160/rmd160init.c b/ext/digest/rmd160/rmd160init.c
index eae329ae04..b56211f8c7 100644
--- a/ext/digest/rmd160/rmd160init.c
+++ b/ext/digest/rmd160/rmd160init.c
@@ -13,8 +13,7 @@ static algo_t rmd160 = {
sizeof(RMD160_CTX),
(hash_init_func_t)RMD160_Init,
(hash_update_func_t)RMD160_Update,
- (hash_end_func_t)RMD160_End,
- (hash_final_func_t)RMD160_Final,
+ (hash_finish_func_t)RMD160_Finish,
(hash_equal_func_t)RMD160_Equal,
};
diff --git a/ext/digest/rmd160/rmd160ossl.c b/ext/digest/rmd160/rmd160ossl.c
index 2989ffd00e..247fd04afd 100644
--- a/ext/digest/rmd160/rmd160ossl.c
+++ b/ext/digest/rmd160/rmd160ossl.c
@@ -5,31 +5,8 @@
#include <assert.h>
#include <stdlib.h>
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-char *
-RMD160_End(RMD160_CTX *ctx, char *buf)
-{
- size_t i;
- char *p = buf;
- uint8_t digest[20];
- static const char hex[]="0123456789abcdef";
-
- _DIAGASSERT(ctx != NULL);
- /* buf may be NULL */
-
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
-
- RMD160_Final(digest,ctx);
- for (i = 0; i < 20; i++) {
- p[i + i] = hex[(uint32_t)digest[i] >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
- }
- p[i + i] = '\0';
- return(p);
+void RMD160_Finish(RMD160_CTX *ctx, char *buf) {
+ RIPEMD160_Final(buf, ctx);
}
int RMD160_Equal(RMD160_CTX* pctx1, RMD160_CTX* pctx2) {
diff --git a/ext/digest/rmd160/rmd160ossl.h b/ext/digest/rmd160/rmd160ossl.h
index e8928d164b..ea6bd57cc6 100644
--- a/ext/digest/rmd160/rmd160ossl.h
+++ b/ext/digest/rmd160/rmd160ossl.h
@@ -10,12 +10,11 @@
#define RMD160_Init RIPEMD160_Init
#define RMD160_Update RIPEMD160_Update
-#define RMD160_Final RIPEMD160_Final
#define RMD160_BLOCK_LENGTH RIPEMD160_CBLOCK
#define RMD160_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH
-char *RMD160_End(RMD160_CTX *ctx, char *buf);
+void RMD160_Finish(RMD160_CTX *ctx, char *buf);
int RMD160_Equal(RMD160_CTX *pctx1, RMD160_CTX *pctx2);
#endif
diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb
index d7b8126de5..87b74c34af 100644
--- a/ext/digest/sha1/extconf.rb
+++ b/ext/digest/sha1/extconf.rb
@@ -14,7 +14,7 @@ if !with_config("bundled-sha1") &&
have_library("crypto") && have_header("openssl/sha.h")
$objs << "sha1ossl.#{$OBJEXT}"
else
- $objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}"
+ $objs << "sha1.#{$OBJEXT}"
end
have_header("sys/cdefs.h")
diff --git a/ext/digest/sha1/sha1.c b/ext/digest/sha1/sha1.c
index 1012ef8751..6545744bed 100644
--- a/ext/digest/sha1/sha1.c
+++ b/ext/digest/sha1/sha1.c
@@ -129,9 +129,7 @@ do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LON
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
-void SHA1_Transform(state, buffer)
- uint32_t state[5];
- const uint8_t buffer[64];
+void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
{
uint32_t a, b, c, d, e;
CHAR64LONG16 *block;
@@ -201,8 +199,7 @@ void SHA1_Transform(state, buffer)
/*
* SHA1_Init - Initialize new context
*/
-void SHA1_Init(context)
- SHA1_CTX *context;
+void SHA1_Init(SHA1_CTX *context)
{
_DIAGASSERT(context != 0);
@@ -220,10 +217,7 @@ void SHA1_Init(context)
/*
* Run your data through this.
*/
-void SHA1_Update(context, data, len)
- SHA1_CTX *context;
- const uint8_t *data;
- size_t len;
+void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
{
uint32_t i, j;
@@ -250,9 +244,7 @@ void SHA1_Update(context, data, len)
/*
* Add padding and return the message digest.
*/
-void SHA1_Final(digest, context)
- uint8_t digest[20];
- SHA1_CTX* context;
+void SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
{
size_t i;
uint8_t finalcount[8];
diff --git a/ext/digest/sha1/sha1.h b/ext/digest/sha1/sha1.h
index 2303cecc2b..c9f84562fc 100644
--- a/ext/digest/sha1/sha1.h
+++ b/ext/digest/sha1/sha1.h
@@ -20,28 +20,19 @@ typedef struct {
} SHA1_CTX;
#ifdef RUBY
+/* avoid name clash */
#define SHA1_Transform rb_Digest_SHA1_Transform
#define SHA1_Init rb_Digest_SHA1_Init
#define SHA1_Update rb_Digest_SHA1_Update
-#define SHA1_Final rb_Digest_SHA1_Final
+#define SHA1_Finish rb_Digest_SHA1_Finish
#define SHA1_Equal rb_Digest_SHA1_Equal
-#ifndef _KERNEL
-#define SHA1_End rb_Digest_SHA1_End
-#define SHA1_File rb_Digest_SHA1_File
-#define SHA1_Data rb_Digest_SHA1_Data
-#endif /* _KERNEL */
#endif
void SHA1_Transform _((uint32_t state[5], const uint8_t buffer[64]));
void SHA1_Init _((SHA1_CTX *context));
void SHA1_Update _((SHA1_CTX *context, const uint8_t *data, size_t len));
-void SHA1_Final _((uint8_t digest[20], SHA1_CTX *context));
+void SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
int SHA1_Equal _((SHA1_CTX *pctx1, SHA1_CTX *pctx2));
-#ifndef _KERNEL
-char *SHA1_End _((SHA1_CTX *, char *));
-char *SHA1_File _((char *, char *));
-char *SHA1_Data _((const uint8_t *, size_t, char *));
-#endif /* _KERNEL */
#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
diff --git a/ext/digest/sha1/sha1hl.c b/ext/digest/sha1/sha1hl.c
deleted file mode 100644
index d1a236b22c..0000000000
--- a/ext/digest/sha1/sha1hl.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* $NetBSD: sha1hl.c,v 1.2 2001/03/10 15:55:14 tron Exp $ */
-/* $RoughId: sha1hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
-/* $Id$ */
-
-/* sha1hl.c
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- */
-
-/* #include "namespace.h" */
-
-#include "sha1.h"
-#include <fcntl.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if defined(HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/* __RCSID("$NetBSD: sha1hl.c,v 1.2 2001/03/10 15:55:14 tron Exp $"); */
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-
-/* ARGSUSED */
-char *
-SHA1_End(ctx, buf)
- SHA1_CTX *ctx;
- char *buf;
-{
- int i;
- char *p = buf;
- uint8_t digest[20];
- static const char hex[]="0123456789abcdef";
-
- _DIAGASSERT(ctx != NULL);
- /* buf may be NULL */
-
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
-
- SHA1_Final(digest,ctx);
- for (i = 0; i < 20; i++) {
- p[i + i] = hex[((uint32_t)digest[i]) >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
- }
- p[i + i] = '\0';
- return(p);
-}
-
-char *
-SHA1_File (filename, buf)
- char *filename;
- char *buf;
-{
- uint8_t buffer[BUFSIZ];
- SHA1_CTX ctx;
- int fd, num, oerrno;
-
- _DIAGASSERT(filename != NULL);
- /* XXX: buf may be NULL ? */
-
- SHA1_Init(&ctx);
-
- if ((fd = open(filename,O_RDONLY)) < 0)
- return(0);
-
- while ((num = read(fd, buffer, sizeof(buffer))) > 0)
- SHA1_Update(&ctx, buffer, (size_t)num);
-
- oerrno = errno;
- close(fd);
- errno = oerrno;
- return(num < 0 ? 0 : SHA1_End(&ctx, buf));
-}
-
-char *
-SHA1_Data (data, len, buf)
- const uint8_t *data;
- size_t len;
- char *buf;
-{
- SHA1_CTX ctx;
-
- _DIAGASSERT(data != NULL);
- /* XXX: buf may be NULL ? */
-
- SHA1_Init(&ctx);
- SHA1_Update(&ctx, data, len);
- return(SHA1_End(&ctx, buf));
-}
diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c
index 304a266893..a704dcbfde 100644
--- a/ext/digest/sha1/sha1init.c
+++ b/ext/digest/sha1/sha1init.c
@@ -13,8 +13,7 @@ static algo_t sha1 = {
sizeof(SHA1_CTX),
(hash_init_func_t)SHA1_Init,
(hash_update_func_t)SHA1_Update,
- (hash_end_func_t)SHA1_End,
- (hash_final_func_t)SHA1_Final,
+ (hash_finish_func_t)SHA1_Finish,
(hash_equal_func_t)SHA1_Equal,
};
diff --git a/ext/digest/sha1/sha1ossl.c b/ext/digest/sha1/sha1ossl.c
index 82a4f6f057..96365c7974 100644
--- a/ext/digest/sha1/sha1ossl.c
+++ b/ext/digest/sha1/sha1ossl.c
@@ -2,37 +2,17 @@
#include "defs.h"
#include "sha1ossl.h"
-#include <assert.h>
#include <stdlib.h>
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-char *
-SHA1_End(SHA1_CTX *ctx, char *buf)
+void
+SHA1_Finish(SHA1_CTX *ctx, char *buf)
{
- int i;
- char *p = buf;
- uint8_t digest[20];
- static const char hex[]="0123456789abcdef";
-
- _DIAGASSERT(ctx != NULL);
- /* buf may be NULL */
-
- if (p == NULL && (p = malloc(41)) == NULL)
- return 0;
-
- SHA1_Final(digest,ctx);
- for (i = 0; i < 20; i++) {
- p[i + i] = hex[((uint32_t)digest[i]) >> 4];
- p[i + i + 1] = hex[digest[i] & 0x0f];
- }
- p[i + i] = '\0';
- return(p);
+ SHA1_Final(buf, ctx);
}
-int SHA1_Equal(SHA1_CTX* pctx1, SHA1_CTX* pctx2) {
+int
+SHA1_Equal(SHA1_CTX* pctx1, SHA1_CTX* pctx2)
+{
return pctx1->num == pctx2->num
&& pctx1->h0 == pctx2->h0
&& pctx1->h1 == pctx2->h1
diff --git a/ext/digest/sha1/sha1ossl.h b/ext/digest/sha1/sha1ossl.h
index c271cc47c6..c2e19d66e8 100644
--- a/ext/digest/sha1/sha1ossl.h
+++ b/ext/digest/sha1/sha1ossl.h
@@ -11,7 +11,7 @@
#define SHA1_BLOCK_LENGTH SHA_BLOCK_LENGTH
#define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
-char *SHA1_End(SHA1_CTX *ctx, char *buf);
+void SHA1_Finish(SHA1_CTX *ctx, char *buf);
int SHA1_Equal(SHA1_CTX *pctx1, SHA1_CTX *pctx2);
#endif
diff --git a/ext/digest/sha2/extconf.rb b/ext/digest/sha2/extconf.rb
index 200d386bef..c084a51a64 100644
--- a/ext/digest/sha2/extconf.rb
+++ b/ext/digest/sha2/extconf.rb
@@ -8,7 +8,6 @@ $INCFLAGS << " -I$(srcdir)/.."
$objs = [
"sha2.#{$OBJEXT}",
- "sha2hl.#{$OBJEXT}",
"sha2init.#{$OBJEXT}",
]
diff --git a/ext/digest/sha2/sha2.c b/ext/digest/sha2/sha2.c
index 41ed2df106..1dd69c4e85 100644
--- a/ext/digest/sha2/sha2.c
+++ b/ext/digest/sha2/sha2.c
@@ -515,7 +515,7 @@ void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
usedspace = freespace = 0;
}
-void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+void SHA256_Finish(SHA256_CTX* context, sha2_byte digest[]) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@@ -852,7 +852,7 @@ void SHA512_Last(SHA512_CTX* context) {
SHA512_Transform(context, (const sha2_word64*)context->buffer);
}
-void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
@@ -901,7 +901,7 @@ void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
SHA512_Update((SHA512_CTX*)context, data, len);
}
-void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+void SHA384_Finish(SHA384_CTX* context, sha2_byte digest[]) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
diff --git a/ext/digest/sha2/sha2.h b/ext/digest/sha2/sha2.h
index 4689ad93ce..db72cbbd3b 100644
--- a/ext/digest/sha2/sha2.h
+++ b/ext/digest/sha2/sha2.h
@@ -77,52 +77,34 @@ typedef SHA512_CTX SHA384_CTX;
#ifdef RUBY
#define SHA256_Init rb_Digest_SHA256_Init
#define SHA256_Update rb_Digest_SHA256_Update
-#define SHA256_Final rb_Digest_SHA256_Final
-#define SHA256_End rb_Digest_SHA256_End
-#define SHA256_Data rb_Digest_SHA256_Data
-#define SHA256_File rb_Digest_SHA256_File
+#define SHA256_Finish rb_Digest_SHA256_Finish
#define SHA256_Equal rb_Digest_SHA256_Equal
#define SHA384_Init rb_Digest_SHA384_Init
#define SHA384_Update rb_Digest_SHA384_Update
-#define SHA384_Final rb_Digest_SHA384_Final
-#define SHA384_End rb_Digest_SHA384_End
-#define SHA384_Data rb_Digest_SHA384_Data
-#define SHA384_File rb_Digest_SHA384_File
+#define SHA384_Finish rb_Digest_SHA384_Finish
#define SHA384_Equal rb_Digest_SHA384_Equal
#define SHA512_Init rb_Digest_SHA512_Init
#define SHA512_Update rb_Digest_SHA512_Update
-#define SHA512_Final rb_Digest_SHA512_Final
-#define SHA512_End rb_Digest_SHA512_End
-#define SHA512_Data rb_Digest_SHA512_Data
-#define SHA512_File rb_Digest_SHA512_File
+#define SHA512_Finish rb_Digest_SHA512_Finish
#define SHA512_Equal rb_Digest_SHA512_Equal
#endif
/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init _((SHA256_CTX *));
void SHA256_Update _((SHA256_CTX*, const uint8_t*, size_t));
-void SHA256_Final _((uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*));
-char* SHA256_End _((SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]));
-char* SHA256_Data _((const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]));
-char *SHA256_File _((char *, char *));
+void SHA256_Finish _((SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]));
int SHA256_Equal _((SHA256_CTX*, SHA256_CTX*));
void SHA384_Init _((SHA384_CTX*));
void SHA384_Update _((SHA384_CTX*, const uint8_t*, size_t));
-void SHA384_Final _((uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*));
-char* SHA384_End _((SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]));
-char* SHA384_Data _((const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]));
-char *SHA384_File _((char *, char *));
+void SHA384_Finish _((SHA384_CTX*, uint8_t[SHA384_DIGEST_LENGTH]));
int SHA384_Equal _((SHA384_CTX*, SHA384_CTX*));
void SHA512_Init _((SHA512_CTX*));
void SHA512_Update _((SHA512_CTX*, const uint8_t*, size_t));
-void SHA512_Final _((uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*));
-char* SHA512_End _((SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]));
-char* SHA512_Data _((const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]));
-char *SHA512_File _((char *, char *));
+void SHA512_Finish _((SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]));
int SHA512_Equal _((SHA512_CTX*, SHA512_CTX*));
#ifdef __cplusplus
diff --git a/ext/digest/sha2/sha2hl.c b/ext/digest/sha2/sha2hl.c
deleted file mode 100644
index 03fde538c3..0000000000
--- a/ext/digest/sha2/sha2hl.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* $NetBSD: sha2hl.c,v 1.1 2001/03/12 09:08:40 agc Exp $ */
-/* $RoughId: sha2hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
-/* $Id$ */
-
-/*
- * sha2hl.c
- * This code includes some functions taken from sha2.c, hence the
- * following licence reproduction.
- *
- * This code is not a verbatim copy, since some routines have been added,
- * and some bugs have been fixed.
- *
- * Version 1.0.0beta1
- *
- * Written by Aaron D. Gifford <me@aarongifford.com>
- *
- * Copyright 2000 Aaron D. Gifford. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include "sha2.h"
-
-#ifndef lint
-/* __RCSID("$NetBSD: sha2hl.c,v 1.1 2001/03/12 09:08:40 agc Exp $"); */
-#endif /* not lint */
-
-/* #include "namespace.h" */
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#if defined(HAVE_UNISTD_H)
-# include <unistd.h>
-#endif
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-/*
- * Constant used by SHA256/384/512_End() functions for converting the
- * digest to a readable hexadecimal character string:
- */
-static const char sha2_hex_digits[] = "0123456789abcdef";
-
-char *
-SHA256_File(char *filename, char *buf)
-{
- uint8_t buffer[BUFSIZ * 20];
- SHA256_CTX ctx;
- int fd, num, oerrno;
-
- _DIAGASSERT(filename != NULL);
- /* XXX: buf may be NULL ? */
-
- SHA256_Init(&ctx);
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return (0);
-
- while ((num = read(fd, buffer, sizeof(buffer))) > 0)
- SHA256_Update(&ctx, buffer, (size_t) num);
-
- oerrno = errno;
- close(fd);
- errno = oerrno;
- return (num < 0 ? 0 : SHA256_End(&ctx, buf));
-}
-
-
-char *
-SHA256_End(SHA256_CTX *ctx, char buffer[])
-{
- uint8_t digest[SHA256_DIGEST_LENGTH], *d = digest;
- uint8_t *ret;
- int i;
-
- /* Sanity check: */
- assert(ctx != NULL);
-
- if ((ret = buffer) != NULL) {
- SHA256_Final(digest, ctx);
-
- for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
- *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
- *buffer++ = sha2_hex_digits[*d & 0x0f];
- d++;
- }
- *buffer = (char) 0;
- } else {
- (void) memset(ctx, 0, sizeof(SHA256_CTX));
- }
- (void) memset(digest, 0, SHA256_DIGEST_LENGTH);
- return ret;
-}
-
-char *
-SHA256_Data(const uint8_t * data, size_t len, char *digest)
-{
- SHA256_CTX ctx;
-
- SHA256_Init(&ctx);
- SHA256_Update(&ctx, data, len);
- return SHA256_End(&ctx, digest);
-}
-
-char *
-SHA384_File(char *filename, char *buf)
-{
- SHA384_CTX ctx;
- uint8_t buffer[BUFSIZ * 20];
- int fd, num, oerrno;
-
- _DIAGASSERT(filename != NULL);
- /* XXX: buf may be NULL ? */
-
- SHA384_Init(&ctx);
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return (0);
-
- while ((num = read(fd, buffer, sizeof(buffer))) > 0)
- SHA384_Update(&ctx, buffer, (size_t) num);
-
- oerrno = errno;
- close(fd);
- errno = oerrno;
- return (num < 0 ? 0 : SHA384_End(&ctx, buf));
-}
-
-char *
-SHA384_End(SHA384_CTX * ctx, char buffer[])
-{
- uint8_t digest[SHA384_DIGEST_LENGTH], *d = digest;
- uint8_t *ret;
- int i;
-
- /* Sanity check: */
- assert(ctx != NULL);
-
- if ((ret = buffer) != NULL) {
- SHA384_Final(digest, ctx);
-
- for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
- *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
- *buffer++ = sha2_hex_digits[*d & 0x0f];
- d++;
- }
- *buffer = (char) 0;
- } else {
- (void) memset(ctx, 0, sizeof(SHA384_CTX));
- }
- (void) memset(digest, 0, SHA384_DIGEST_LENGTH);
- return ret;
-}
-
-char *
-SHA384_Data(const uint8_t * data, size_t len, char *digest)
-{
- SHA384_CTX ctx;
-
- SHA384_Init(&ctx);
- SHA384_Update(&ctx, data, len);
- return SHA384_End(&ctx, digest);
-}
-
-char *
-SHA512_File(char *filename, char *buf)
-{
- SHA512_CTX ctx;
- uint8_t buffer[BUFSIZ * 20];
- int fd, num, oerrno;
-
- _DIAGASSERT(filename != NULL);
- /* XXX: buf may be NULL ? */
-
- SHA512_Init(&ctx);
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return (0);
-
- while ((num = read(fd, buffer, sizeof(buffer))) > 0)
- SHA512_Update(&ctx, buffer, (size_t) num);
-
- oerrno = errno;
- close(fd);
- errno = oerrno;
- return (num < 0 ? 0 : SHA512_End(&ctx, buf));
-}
-
-char *
-SHA512_End(SHA512_CTX * ctx, char buffer[])
-{
- uint8_t digest[SHA512_DIGEST_LENGTH], *d = digest;
- uint8_t *ret;
- int i;
-
- /* Sanity check: */
- assert(ctx != NULL);
-
- if ((ret = buffer) != NULL) {
- SHA512_Final(digest, ctx);
-
- for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
- *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
- *buffer++ = sha2_hex_digits[*d & 0x0f];
- d++;
- }
- *buffer = (char) 0;
- } else {
- (void) memset(ctx, 0, sizeof(SHA512_CTX));
- }
- (void) memset(digest, 0, SHA512_DIGEST_LENGTH);
- return ret;
-}
-
-char *
-SHA512_Data(const uint8_t * data, size_t len, char *digest)
-{
- SHA512_CTX ctx;
-
- SHA512_Init(&ctx);
- SHA512_Update(&ctx, data, len);
- return SHA512_End(&ctx, digest);
-}
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
index 27a2b7ee89..9484f2a7ba 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -12,8 +12,7 @@ static algo_t sha##bitlen = { \
sizeof(SHA##bitlen##_CTX), \
(hash_init_func_t)SHA##bitlen##_Init, \
(hash_update_func_t)SHA##bitlen##_Update, \
- (hash_end_func_t)SHA##bitlen##_End, \
- (hash_final_func_t)SHA##bitlen##_Final, \
+ (hash_finish_func_t)SHA##bitlen##_Finish, \
(hash_equal_func_t)SHA##bitlen##_Equal, \
};