I have installed this. It may look a bit redundant now, but will make sense later on, compare how the file look and is used in GnuTLS.
Review most appreciated, as always. 2005-10-08 Simon Josefsson <[EMAIL PROTECTED]> * gc.h: Add gc_hash and gc_hash_buffer. * gc-gnulib.c (gc_hash_buffer): Add. Reorder #include's. * gc-libgcrypt.c (gc_hash_buffer): Add. Index: lib/gc.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc.h,v retrieving revision 1.1 diff -u -p -r1.1 gc.h --- lib/gc.h 8 Oct 2005 08:33:07 -0000 1.1 +++ lib/gc.h 8 Oct 2005 09:26:14 -0000 @@ -24,8 +24,6 @@ /* Get size_t. */ # include <stddef.h> -#define GC_MD5_DIGEST_SIZE 16 - enum Gc_rc { GC_OK = 0, @@ -40,6 +38,16 @@ enum Gc_rc }; typedef enum Gc_rc Gc_rc; +/* Hash types. */ +enum Gc_hash + { + GC_MD5 + }; +typedef enum Gc_hash Gc_hash; + +#define GC_MD5_DIGEST_SIZE 16 + +/* Call before respectively after any other functions. */ extern int gc_init (void); extern void gc_done (void); @@ -53,6 +61,10 @@ extern void gc_set_allocators (gc_malloc gc_secure_check_t secure_check, gc_realloc_t func_realloc, gc_free_t func_free); + +/* Hashes. */ +extern int +gc_hash_buffer (int hash, const void *in, size_t inlen, char *out); /* One-call interface. */ extern int gc_md5 (const void *in, size_t inlen, void *resbuf); Index: lib/gc-gnulib.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc-gnulib.c,v retrieving revision 1.1 diff -u -p -r1.1 gc-gnulib.c --- lib/gc-gnulib.c 8 Oct 2005 08:33:08 -0000 1.1 +++ lib/gc-gnulib.c 8 Oct 2005 09:26:14 -0000 @@ -24,11 +24,12 @@ # include <config.h> #endif -#include <stdlib.h> - /* Get prototype. */ #include <gc.h> +#include <stdlib.h> +#include <string.h> + /* For randomize. */ #include <unistd.h> #include <sys/types.h> @@ -36,7 +37,8 @@ #include <fcntl.h> #include <errno.h> -#include <string.h> +#include "md5.h" +#include "hmac.h" int gc_init (void) @@ -133,7 +135,23 @@ gc_set_allocators (gc_malloc_t func_mall return; } -#include "md5.h" +/* Hashes. */ + +int +gc_hash_buffer (int hash, const void *in, size_t inlen, char *resbuf) +{ + switch (hash) + { + case GC_MD5: + md5_buffer (in, inlen, resbuf); + break; + + default: + return GC_INVALID_HASH; + } + + return GC_OK; +} int gc_md5 (const void *in, size_t inlen, void *resbuf) @@ -141,8 +159,6 @@ gc_md5 (const void *in, size_t inlen, vo md5_buffer (in, inlen, resbuf); return 0; } - -#include "hmac.h" int gc_hmac_md5 (const void *key, size_t keylen, Index: lib/gc-libgcrypt.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc-libgcrypt.c,v retrieving revision 1.1 diff -u -p -r1.1 gc-libgcrypt.c --- lib/gc-libgcrypt.c 8 Oct 2005 08:33:08 -0000 1.1 +++ lib/gc-libgcrypt.c 8 Oct 2005 09:26:14 -0000 @@ -94,6 +94,28 @@ gc_set_allocators (gc_malloc_t func_mall func_realloc, func_free); } +/* Hashes. */ + +int +gc_hash_buffer (int hash, const void *in, size_t inlen, char *resbuf) +{ + int gcryalg; + + switch (hash) + { + case GC_MD5: + gcryalg = GCRY_MD_MD5; + break; + + default: + return GC_INVALID_HASH; + } + + gcry_md_hash_buffer (gcryalg, resbuf, in, inlen); + + return GC_OK; +} + /* One-call interface. */ int _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib