+2005-10-12 Simon Josefsson <jas@extundo.com>
+
+ * gc-libgcrypt.c (gc_hmac_sha1): New function.
+
+ * gc-gnulib.c (gc_hmac_sha1): New function.
+
2005-10-12 Simon Josefsson <jas@extundo.com>
* gc.h, gc-gnulib.c, gc-libgcrypt.c: Support SHA-1.
return 0;
}
#endif
+
+#ifdef GC_USE_HMAC_SHA1
+int
+gc_hmac_sha1 (const void *key, size_t keylen,
+ const void *in, size_t inlen, char *resbuf)
+{
+ hmac_sha1 (key, keylen, in, inlen, resbuf);
+ return 0;
+}
+#endif
return GC_OK;
}
#endif
+
+#ifdef GC_USE_HMAC_SHA1
+int
+gc_hmac_sha1 (const void *key, size_t keylen,
+ const void *in, size_t inlen, char *resbuf)
+{
+ size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
+ gcry_md_hd_t mdh;
+ unsigned char *hash;
+ gpg_error_t err;
+
+ assert (hlen == 16);
+
+ err = gcry_md_open (&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
+ if (err != GPG_ERR_NO_ERROR)
+ return GC_INVALID_HASH;
+
+ err = gcry_md_setkey (mdh, key, keylen);
+ if (err != GPG_ERR_NO_ERROR)
+ {
+ gcry_md_close (mdh);
+ return GC_INVALID_HASH;
+ }
+
+ gcry_md_write (mdh, in, inlen);
+
+ hash = gcry_md_read (mdh, GCRY_MD_SHA1);
+ if (hash == NULL)
+ {
+ gcry_md_close (mdh);
+ return GC_INVALID_HASH;
+ }
+
+ memcpy (resbuf, hash, hlen);
+
+ gcry_md_close (mdh);
+
+ return GC_OK;
+}
+#endif
2005-10-12 Simon Josefsson <jas@extundo.com>
+ * gc-hmac-sha1.m4: New file.
+
* gc-sha1: New file.
* hmac-sha1.m4: New file.
--- /dev/null
+# gc-hmac-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_HMAC_SHA1],
+[
+ AC_REQUIRE([gl_GC])
+ AC_DEFINE(GC_USE_HMAC_SHA1, 1,
+ [Define to if you want to support HMAC-SHA1 through GC.])
+ if test "$ac_cv_libgcrypt" != yes; then
+ gl_SHA1
+ gl_HMAC_SHA1
+ gl_MEMXOR
+ fi
+])
--- /dev/null
+Description:
+Generic crypto wrappers for HMAC-SHA1 functions.
+
+Files:
+m4/gc-hmac-md5.m4
+lib/sha1.h
+lib/sha1.c
+m4/sha1.m4
+lib/hmac.h
+lib/hmac-sha1.c
+m4/hmac-sha1.m4
+lib/memxor.h
+lib/memxor.c
+m4/memxor.m4
+
+Depends-on:
+stdint
+gc
+
+configure.ac:
+gl_GC_HMAC_SHA1
+
+Makefile.am:
+
+Include:
+"gc.h"
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson