I have installed this. Index: m4/ChangeLog =================================================================== RCS file: /cvsroot/gnulib/gnulib/m4/ChangeLog,v retrieving revision 1.737 diff -u -p -r1.737 ChangeLog --- m4/ChangeLog 12 Oct 2005 01:33:44 -0000 1.737 +++ m4/ChangeLog 12 Oct 2005 01:42:23 -0000 @@ -1,5 +1,7 @@ 2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> + * gc-sha1: New file. + * hmac-sha1.m4: New file. 2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> Index: m4/gc-sha1 =================================================================== RCS file: m4/gc-sha1 diff -N m4/gc-sha1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/gc-sha1 12 Oct 2005 01:42:23 -0000 @@ -0,0 +1,15 @@ +# gc-sha1.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_GC_SHA1], +[ + AC_REQUIRE([gl_GC]) + AC_DEFINE(GC_USE_SHA1, 1, + [Define to if you want to support SHA-1 through GC.]) + if test "$ac_cv_libgcrypt" != yes; then + gl_SHA1 + fi +]) Index: lib/ChangeLog =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v retrieving revision 1.1006 diff -u -p -r1.1006 ChangeLog --- lib/ChangeLog 12 Oct 2005 01:09:33 -0000 1.1006 +++ lib/ChangeLog 12 Oct 2005 01:42:24 -0000 @@ -1,5 +1,9 @@ 2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> + * gc.h, gc-gnulib.c, gc-libgcrypt.c: Support SHA-1. + +2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> + * gc-gnulib.c: Condition MD5 and HMAC-MD5 use on GC_USE_MD5 and GC_USE_HMAC_MD5, respectively. Index: lib/gc.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc.h,v retrieving revision 1.5 diff -u -p -r1.5 gc.h --- lib/gc.h 12 Oct 2005 00:23:38 -0000 1.5 +++ lib/gc.h 12 Oct 2005 01:42:24 -0000 @@ -41,11 +41,13 @@ typedef enum Gc_rc Gc_rc; /* Hash types. */ enum Gc_hash { - GC_MD5 + GC_MD5, + GC_SHA1 }; typedef enum Gc_hash Gc_hash; #define GC_MD5_DIGEST_SIZE 16 +#define GC_SHA1_DIGEST_SIZE 20 /* Call before respectively after any other functions. */ extern int gc_init (void); @@ -75,9 +77,13 @@ gc_hash_buffer (Gc_hash hash, const void /* One-call interface. */ extern int gc_md5 (const void *in, size_t inlen, void *resbuf); +extern int gc_sha1 (const void *in, size_t inlen, void *resbuf); extern int gc_hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf); +extern int gc_hmac_sha1 (const void *key, size_t keylen, + const void *in, size_t inlen, + char *resbuf); /* TODO: Index: lib/gc-gnulib.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc-gnulib.c,v retrieving revision 1.4 diff -u -p -r1.4 gc-gnulib.c --- lib/gc-gnulib.c 12 Oct 2005 01:09:33 -0000 1.4 +++ lib/gc-gnulib.c 12 Oct 2005 01:42:24 -0000 @@ -40,6 +40,9 @@ #ifdef GC_USE_MD5 # include "md5.h" #endif +#ifdef GC_USE_SHA1 +# include "sha1.h" +#endif #ifdef GC_USE_HMAC_MD5 # include "hmac.h" #endif @@ -152,6 +155,12 @@ gc_hash_buffer (Gc_hash hash, const void break; #endif +#ifdef GC_USE_SHA1 + case GC_SHA1: + sha1_buffer (in, inlen, resbuf); + break; +#endif + default: return GC_INVALID_HASH; } @@ -164,6 +173,15 @@ int gc_md5 (const void *in, size_t inlen, void *resbuf) { md5_buffer (in, inlen, resbuf); + return 0; +} +#endif + +#ifdef GC_USE_SHA1 +int +gc_sha1 (const void *in, size_t inlen, void *resbuf) +{ + sha1_buffer (in, inlen, resbuf); return 0; } #endif Index: lib/gc-libgcrypt.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gc-libgcrypt.c,v retrieving revision 1.4 diff -u -p -r1.4 gc-libgcrypt.c --- lib/gc-libgcrypt.c 12 Oct 2005 01:09:33 -0000 1.4 +++ lib/gc-libgcrypt.c 12 Oct 2005 01:42:24 -0000 @@ -109,6 +109,12 @@ gc_hash_buffer (Gc_hash hash, const void break; #endif +#ifdef GC_USE_SHA1 + case GC_SHA1: + gcryalg = GCRY_MD_SHA1; + break; +#endif + default: return GC_INVALID_HASH; } @@ -138,6 +144,38 @@ gc_md5 (const void *in, size_t inlen, vo gcry_md_write (hd, in, inlen); p = gcry_md_read (hd, GCRY_MD_MD5); + if (p == NULL) + { + gcry_md_close (hd); + return GC_INVALID_HASH; + } + + memcpy (resbuf, p, outlen); + + gcry_md_close (hd); + + return GC_OK; +} +#endif + +#ifdef GC_USE_SHA1 +int +gc_sha1 (const void *in, size_t inlen, void *resbuf) +{ + size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); + gcry_md_hd_t hd; + gpg_error_t err; + unsigned char *p; + + assert (outlen == GC_SHA1_DIGEST_SIZE); + + err = gcry_md_open (&hd, GCRY_MD_SHA1, 0); + if (err != GPG_ERR_NO_ERROR) + return GC_INVALID_HASH; + + gcry_md_write (hd, in, inlen); + + p = gcry_md_read (hd, GCRY_MD_SHA1); if (p == NULL) { gcry_md_close (hd); Index: ChangeLog =================================================================== RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v retrieving revision 1.414 diff -u -p -r1.414 ChangeLog --- ChangeLog 12 Oct 2005 01:33:44 -0000 1.414 +++ ChangeLog 12 Oct 2005 01:42:24 -0000 @@ -1,5 +1,9 @@ 2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> + * modules/gc-sha1: New file. + +2005-10-12 Simon Josefsson <[EMAIL PROTECTED]> + * tests/test-hmac-sha1.c: New file. * modules/hmac-sha1-tests: New file. Index: modules/gc-sha1 =================================================================== RCS file: modules/gc-sha1 diff -N modules/gc-sha1 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/gc-sha1 12 Oct 2005 01:42:24 -0000 @@ -0,0 +1,26 @@ +Description: +Generic crypto wrappers for SHA-1 functions. + +Files: +m4/gc-sha1.m4 +lib/sha1.h +lib/sha1.c +m4/sha1.m4 + +Depends-on: +stdint +gc + +configure.ac: +gl_GC_SHA1 + +Makefile.am: + +Include: +"gc.h" + +License: +LGPL + +Maintainer: +Simon Josefsson
_______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib