Hello community, here is the log from the commit of package booth for openSUSE:Factory checked in at 2015-07-21 13:27:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/booth (Old) and /work/SRC/openSUSE:Factory/.booth.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "booth" Changes: -------- --- /work/SRC/openSUSE:Factory/booth/booth.changes 2015-07-14 17:44:47.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.booth.new/booth.changes 2015-07-21 13:29:04.000000000 +0200 @@ -1,0 +2,6 @@ +Sat Jul 18 10:09:17 UTC 2015 - [email protected] + +- Update to version v0.2.0_87_gf59231b: + + auth: add support for libgcrypt (bsc#938403) + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ booth.spec ++++++ --- /var/tmp/diff_new_pack.onF4LE/_old 2015-07-21 13:29:05.000000000 +0200 +++ /var/tmp/diff_new_pack.onF4LE/_new 2015-07-21 13:29:05.000000000 +0200 @@ -54,7 +54,7 @@ BuildRequires: autoconf BuildRequires: automake BuildRequires: glib2-devel -BuildRequires: mhash-devel +BuildRequires: libgcrypt-devel %if 0%{?fedora} || 0%{?centos} || 0%{?rhel} BuildRequires: cluster-glue-libs-devel BuildRequires: pacemaker-libs-devel ++++++ booth.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/.git_info new/booth/.git_info --- old/booth/.git_info 2015-07-10 12:21:58.000000000 +0200 +++ new/booth/.git_info 2015-07-17 18:31:28.000000000 +0200 @@ -1 +1 @@ -v0.2.0-86-g62eee28 +v0.2.0-87-gf59231b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/booth.spec new/booth/booth.spec --- old/booth/booth.spec 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/booth.spec 2015-07-17 18:08:48.000000000 +0200 @@ -37,7 +37,7 @@ BuildRequires: autoconf BuildRequires: automake BuildRequires: glib2-devel -BuildRequires: mhash-devel +BuildRequires: libgcrypt-devel %if 0%{?fedora} || 0%{?centos} || 0%{?rhel} BuildRequires: cluster-glue-libs-devel BuildRequires: pacemaker-libs-devel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/configure.ac new/booth/configure.ac --- old/booth/configure.ac 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/configure.ac 2015-07-17 18:08:48.000000000 +0200 @@ -69,11 +69,18 @@ AC_CHECK_LIB([nsl], [t_open]) AC_CHECK_LIB([gpl], [cl_log]) -# mhash for hmac -mhash_installed="yes" -AC_CHECK_HEADERS(mhash.h, , [mhash_installed="no"],) -AC_CHECK_LIB(mhash, mhash_init, , [mhash_installed="no"]) -AM_CONDITIONAL(BUILD_AUTH_C, test "x${mhash_installed}" = "xyes") +# libgcrypt or mhash for hmac +libgcrypt_installed="yes" +AC_CHECK_HEADERS(gcrypt.h, , [libgcrypt_installed="no"],) +AC_CHECK_LIB(gcrypt, gcry_md_open, , [libgcrypt_installed="no"]) +AM_CONDITIONAL(BUILD_AUTH_C, test "x${libgcrypt_installed}" = "xyes") + +if test "x$libgcrypt_installed" = "xno"; then + mhash_installed="yes" + AC_CHECK_HEADERS(mhash.h, , [mhash_installed="no"],) + AC_CHECK_LIB(mhash, mhash_init, , [mhash_installed="no"]) + AM_CONDITIONAL(BUILD_AUTH_C, test "x${mhash_installed}" = "xyes") +fi PKG_CHECK_MODULES(GLIB, [glib-2.0]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/src/auth.c new/booth/src/auth.c --- old/booth/src/auth.c 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/src/auth.c 2015-07-17 18:08:48.000000000 +0200 @@ -18,6 +18,60 @@ #include "auth.h" +#if HAVE_LIBGCRYPT +/* calculate the HMAC of the message in data and store it in result + * it is up to the caller to make sure that there's enough space + * at result for the MAC + */ +int calc_hmac(const void *data, size_t datalen, + int hid, unsigned char *result, char *key, int keylen) +{ + static gcry_md_hd_t digest; + gcry_error_t err; + + if (!digest) { + err = gcry_md_open(&digest, hid, GCRY_MD_FLAG_HMAC); + if (err) { + log_error("gcry_md_open: %s", gcry_strerror(err)); + return -1; + } + err = gcry_md_setkey(digest, key, keylen); + if (err) { + log_error("gcry_md_open: %s", gcry_strerror(err)); + return -1; + } + } + gcry_md_write(digest, data, datalen); + memcpy(result, gcry_md_read(digest, 0), gcry_md_get_algo_dlen(hid)); + gcry_md_reset(digest); + return 0; +} + +/* test HMAC + */ +int verify_hmac(const void *data, size_t datalen, + int hid, unsigned char *hmac, char *key, int keylen) +{ + unsigned char *our_hmac; + int rc; + + our_hmac = malloc(gcry_md_get_algo_dlen(hid)); + if (!our_hmac) + return -1; + + rc = calc_hmac(data, datalen, hid, our_hmac, key, keylen); + if (rc) + goto out_free; + rc = memcmp(our_hmac, hmac, gcry_md_get_algo_dlen(hid)); + +out_free: + if (our_hmac) + free(our_hmac); + return rc; +} +#endif + +#if HAVE_LIBMHASH /* calculate the HMAC of the message in data and store it in result * it is up to the caller to make sure that there's enough space * at result for the MAC @@ -72,3 +126,5 @@ free(our_hmac); return rc; } + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/src/auth.h new/booth/src/auth.h --- old/booth/src/auth.h 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/src/auth.h 2015-07-17 18:08:48.000000000 +0200 @@ -17,9 +17,23 @@ */ #include "b_config.h" +#include "log.h" #include <sys/types.h> +#if HAVE_LIBGCRYPT + +#include <gcrypt.h> + +#define BOOTH_HASH GCRY_MD_SHA1 + +int calc_hmac(const void *data, size_t datalen, + int hid, unsigned char *result, char *key, int keylen); +int verify_hmac(const void *data, size_t datalen, + int hid, unsigned char *hmac, char *key, int keylen); +#endif + #if HAVE_LIBMHASH + #include <mhash.h> #define BOOTH_HASH MHASH_SHA1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/src/config.c new/booth/src/config.c --- old/booth/src/config.c 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/src/config.c 2015-07-17 18:08:48.000000000 +0200 @@ -549,7 +549,7 @@ continue; } -#if HAVE_LIBMHASH +#if HAVE_LIBGCRYPT || HAVE_LIBMHASH if (strcmp(key, "authfile") == 0) { safe_copy(booth_conf->authfile, val, BOOTH_PATH_LEN, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/booth/src/transport.c new/booth/src/transport.c --- old/booth/src/transport.c 2015-07-10 12:16:12.000000000 +0200 +++ new/booth/src/transport.c 2015-07-17 18:08:48.000000000 +0200 @@ -842,7 +842,7 @@ int add_hmac(void *data, int len) { int rv = 0; -#if HAVE_LIBMHASH +#if HAVE_LIBGCRYPT || HAVE_LIBMHASH int payload_len; struct hmac *hp; @@ -862,7 +862,7 @@ return rv; } -#if HAVE_LIBMHASH +#if HAVE_LIBGCRYPT || HAVE_LIBMHASH /* TODO: we need some client identification for logging */ #define peer_string(p) (p ? site_string(p) : "client") @@ -916,7 +916,7 @@ int check_auth(struct booth_site *from, void *buf, int len) { int rv = 0; -#if HAVE_LIBMHASH +#if HAVE_LIBGCRYPT || HAVE_LIBMHASH int payload_len; struct hmac *hp;
