From bb504c0f66100dc2664823655e2e19fbd37199f9 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Wed, 12 Oct 2005 01:09:32 +0000 Subject: [PATCH] Split parts of the gc module into gc-md5 and gc-hmac-md5 modules. --- ChangeLog | 6 ++++++ lib/ChangeLog | 3 +++ lib/gc-gnulib.c | 14 ++++++++++++-- lib/gc-libgcrypt.c | 6 ++++++ m4/ChangeLog | 6 ++++++ m4/gc-hmac-md5.m4 | 17 +++++++++++++++++ m4/gc-md5.m4 | 14 ++++++++++++++ m4/gc.m4 | 3 --- modules/gc | 10 ---------- modules/gc-hmac-md5 | 32 ++++++++++++++++++++++++++++++++ modules/gc-md5 | 26 ++++++++++++++++++++++++++ 11 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 m4/gc-hmac-md5.m4 create mode 100644 m4/gc-md5.m4 create mode 100644 modules/gc-hmac-md5 create mode 100644 modules/gc-md5 diff --git a/ChangeLog b/ChangeLog index de50dc6dd..64e8d396c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-12 Simon Josefsson + + * modules/gc-md5, modules/gc-hmac-md5: New files. + + * modules/gc (Files): Remove md5, memxor and hmac files. + 2005-10-11 Bruno Haible * modules/c-strcasestr: New file. diff --git a/lib/ChangeLog b/lib/ChangeLog index 413e3c179..b67eec2a8 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,8 @@ 2005-10-12 Simon Josefsson + * gc-gnulib.c: Condition MD5 and HMAC-MD5 use on GC_USE_MD5 and + GC_USE_HMAC_MD5, respectively. + * gc-libgcrypt.c (gc_md5): Fix assert call. (gc_md5): Fix typo. diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c index eac903908..00bab976d 100644 --- a/lib/gc-gnulib.c +++ b/lib/gc-gnulib.c @@ -37,8 +37,12 @@ #include #include -#include "md5.h" -#include "hmac.h" +#ifdef GC_USE_MD5 +# include "md5.h" +#endif +#ifdef GC_USE_HMAC_MD5 +# include "hmac.h" +#endif int gc_init (void) @@ -142,9 +146,11 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) { switch (hash) { +#ifdef GC_USE_MD5 case GC_MD5: md5_buffer (in, inlen, resbuf); break; +#endif default: return GC_INVALID_HASH; @@ -153,13 +159,16 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) return GC_OK; } +#ifdef GC_USE_MD5 int gc_md5 (const void *in, size_t inlen, void *resbuf) { md5_buffer (in, inlen, resbuf); return 0; } +#endif +#ifdef GC_USE_HMAC_MD5 int gc_hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) @@ -167,3 +176,4 @@ gc_hmac_md5 (const void *key, size_t keylen, hmac_md5 (key, keylen, in, inlen, resbuf); return 0; } +#endif diff --git a/lib/gc-libgcrypt.c b/lib/gc-libgcrypt.c index d821c1d49..0c7e2c34f 100644 --- a/lib/gc-libgcrypt.c +++ b/lib/gc-libgcrypt.c @@ -103,9 +103,11 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) switch (hash) { +#ifdef GC_USE_MD5 case GC_MD5: gcryalg = GCRY_MD_MD5; break; +#endif default: return GC_INVALID_HASH; @@ -118,6 +120,7 @@ gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf) /* One-call interface. */ +#ifdef GC_USE_MD5 int gc_md5 (const void *in, size_t inlen, void *resbuf) { @@ -147,7 +150,9 @@ gc_md5 (const void *in, size_t inlen, void *resbuf) return GC_OK; } +#endif +#ifdef GC_USE_HMAC_MD5 int gc_hmac_md5 (const void *key, size_t keylen, const void *in, size_t inlen, char *resbuf) @@ -185,3 +190,4 @@ gc_hmac_md5 (const void *key, size_t keylen, return GC_OK; } +#endif diff --git a/m4/ChangeLog b/m4/ChangeLog index b2b564197..5678658c4 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,9 @@ +2005-10-12 Simon Josefsson + + * gc-md5.m4, gc-hmac-md5: New files. + + * gc.m4: Don't call gl_MD5, gl_MEMXOR or gl_HMAC_MD5. + 2005-10-11 Simon Josefsson * crc.m4: New file. diff --git a/m4/gc-hmac-md5.m4 b/m4/gc-hmac-md5.m4 new file mode 100644 index 000000000..bae70b673 --- /dev/null +++ b/m4/gc-hmac-md5.m4 @@ -0,0 +1,17 @@ +# gc-hmac-md5.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_MD5], +[ + AC_REQUIRE([gl_GC]) + AC_DEFINE(GC_USE_HMAC_MD5, 1, + [Define to if you want to support HMAC-MD5 through GC.]) + if test "$ac_cv_libgcrypt" != yes; then + gl_MD5 + gl_HMAC_MD5 + gl_MEMXOR + fi +]) diff --git a/m4/gc-md5.m4 b/m4/gc-md5.m4 new file mode 100644 index 000000000..bb9a2b3c1 --- /dev/null +++ b/m4/gc-md5.m4 @@ -0,0 +1,14 @@ +# gc-md5.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_MD5], +[ + AC_REQUIRE([gl_GC]) + AC_DEFINE(GC_USE_MD5, 1, [Define to if you want to support MD5 through GC.]) + if test "$ac_cv_libgcrypt" != yes; then + gl_MD5 + fi +]) diff --git a/m4/gc.m4 b/m4/gc.m4 index a36c2a9ac..bf46b92e6 100644 --- a/m4/gc.m4 +++ b/m4/gc.m4 @@ -18,9 +18,6 @@ AC_DEFUN([gl_GC], AC_LIBOBJ([gc-libgcrypt]) else AC_LIBOBJ([gc-gnulib]) - gl_MD5 - gl_MEMXOR - gl_HMAC_MD5 # Devices with randomness. # FIXME: Are these the best defaults? diff --git a/modules/gc b/modules/gc index 129cf6dc3..cb771c367 100644 --- a/modules/gc +++ b/modules/gc @@ -6,16 +6,6 @@ lib/gc.h lib/gc-libgcrypt.c lib/gc-gnulib.c m4/gc.m4 -lib/md5.h -lib/md5.c -m4/md5.m4 -m4/uint32_t.m4 -lib/hmac.h -lib/hmac-md5.c -m4/hmac-md5.m4 -lib/memxor.h -lib/memxor.c -m4/memxor.m4 Depends-on: havelib diff --git a/modules/gc-hmac-md5 b/modules/gc-hmac-md5 new file mode 100644 index 000000000..40917361b --- /dev/null +++ b/modules/gc-hmac-md5 @@ -0,0 +1,32 @@ +Description: +Generic crypto wrappers for HMAC-MD5 functions. + +Files: +m4/gc-hmac-md5.m4 +lib/md5.h +lib/md5.c +m4/md5.m4 +lib/hmac.h +lib/hmac-md5.c +m4/hmac-md5.m4 +lib/memxor.h +lib/memxor.c +m4/memxor.m4 + +Depends-on: +stdint +gc + +configure.ac: +gl_GC_HMAC_MD5 + +Makefile.am: + +Include: +"gc.h" + +License: +LGPL + +Maintainer: +Simon Josefsson diff --git a/modules/gc-md5 b/modules/gc-md5 new file mode 100644 index 000000000..662ed5f81 --- /dev/null +++ b/modules/gc-md5 @@ -0,0 +1,26 @@ +Description: +Generic crypto wrappers for MD5 functions. + +Files: +m4/gc-md5.m4 +lib/md5.h +lib/md5.c +m4/md5.m4 + +Depends-on: +stdint +gc + +configure.ac: +gl_GC_MD5 + +Makefile.am: + +Include: +"gc.h" + +License: +LGPL + +Maintainer: +Simon Josefsson -- 2.11.0