[git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.0-24-gbb558c8

by Werner Koch cvs at cvs.gnupg.org
Wed Jan 29 10:50:57 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, LIBGCRYPT-1-6-BRANCH has been updated
       via  bb558c86a8c1c0fba2e58874a100c121b2fcd033 (commit)
       via  16d558bd22cd3b3c819ac98135b7812e7ec3f0e5 (commit)
       via  7259af184e6ca0b8e3fffc264fb5e047f25a08b8 (commit)
       via  f9948609a51fa10e440de19e877b1795534eff90 (commit)
      from  8ca5966198b4d0d3932978880dc21cb75bf75d56 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bb558c86a8c1c0fba2e58874a100c121b2fcd033
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 29 10:44:36 2014 +0100

    Reserve control code for FIPS extensions.
    
    * src/gcrypt.h.in (GCRYCTL_INACTIVATE_FIPS_FLAG): New.
    (GCRYCTL_REACTIVATE_FIPS_FLAG): New.
    * src/global.c (_gcry_vcontrol): Add them but return not_implemented.
    
    (cherry picked from commit aea96a64fbc58a0b6f9f435e97e93294c6eb1052)

diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index 9e94e87..dbf48e3 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -327,7 +327,9 @@ enum gcry_ctl_cmds
     GCRYCTL_DISABLE_LOCKED_SECMEM = 67,
     GCRYCTL_DISABLE_PRIV_DROP = 68,
     GCRYCTL_SET_CCM_LENGTHS = 69,
-    GCRYCTL_CLOSE_RANDOM_DEVICE = 70
+    GCRYCTL_CLOSE_RANDOM_DEVICE = 70,
+    GCRYCTL_INACTIVATE_FIPS_FLAG = 71,
+    GCRYCTL_REACTIVATE_FIPS_FLAG = 72
   };
 
 /* Perform various operations defined by CMD. */
diff --git a/src/global.c b/src/global.c
index 5677bde..6f9cbf9 100644
--- a/src/global.c
+++ b/src/global.c
@@ -675,6 +675,11 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
 			       | GCRY_SECMEM_FLAG_NO_PRIV_DROP));
       break;
 
+    case GCRYCTL_INACTIVATE_FIPS_FLAG:
+    case GCRYCTL_REACTIVATE_FIPS_FLAG:
+      rc = GPG_ERR_NOT_IMPLEMENTED;
+      break;
+
     default:
       _gcry_set_preferred_rng_type (0);
       rc = GPG_ERR_INV_OP;

commit 16d558bd22cd3b3c819ac98135b7812e7ec3f0e5
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 29 10:30:19 2014 +0100

    Support non weak symbol pthread platforms.
    
    * m4/lock.m4, m4/threadlib.m4: New.  From libgpg-error master.
    * m4/Makefile.am (EXTRA_DIST): Add them.
    * configure.ac (HAVE_PTHREAD): Remove test and ac_define.
    (gl_LOCK): Do not use under Windows.
    (LIBGCRYPT_CONFIG_LIBS): Add LIBTHREAD to support non-ELF pthread
    systems.
    * src/Makefile.am (dumpsexp_LDADD, mpicalc_LDADD, hmac256_LDADD)
    (gcryptrnd_LDADD): Add LIBTHREAD.
    * src/ath.c: Include pthread for any pthread version.
    (ath_init, ath_install, ath_mutex_init, ath_mutex_destroy)
    (ath_mutex_lock, ath_mutex_unlock): Support non-weak symbol pthread
    systems.
    * tests/Makefile.am (LDADD): Add LIBTHREAD.
    * tests/t-lock.c: Replace HAVE_PTHREAD by USE_POSIX_THREADS
    (run_test): Run only under W32 or pthread.
    --
    
    This has been tested on "AIX power-aix 1 7" using gcc 4.8.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/configure.ac b/configure.ac
index e6686a7..cb1a969 100644
--- a/configure.ac
+++ b/configure.ac
@@ -717,19 +717,27 @@ fi
 AC_SUBST(PTH_CFLAGS)
 AC_SUBST(PTH_LIBS)
 
-#
-# Check whether pthreads is available
-#
-AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
-if test "$have_pthread" = yes; then
-   AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
-fi
 
 #
 # See which thread system we have
-# FIXME: Thus duplicates the above check.
 #
-gl_LOCK
+# Windows has always thread support; thus we don't bother to test for
+# it as it may lead to false results when cross building.
+if test "$have_w32_system" = yes; then
+  AC_DEFINE([USE_WINDOWS_THREADS], [1])
+  LIBTHREAD=
+  LTLIBTHREAD=
+  LIBMULTITHREAD=
+  LTLIBMULTITHREAD=
+  THREADLIB_CPPFLAGS=""
+  AC_SUBST([LIBTHREAD])
+  AC_SUBST([LTLIBTHREAD])
+  AC_SUBST([LIBMULTITHREAD])
+  AC_SUBST([LTLIBMULTITHREAD])
+else
+  gl_LOCK
+fi
+
 
 # Solaris needs -lsocket and -lnsl. Unisys system includes
 # gethostbyname in libsocket but needs libnsl for socket.
@@ -1348,6 +1356,13 @@ if test "$use_hmac_binary_check" = yes ; then
 fi
 AC_SUBST(DL_LIBS)
 
+#
+# Check whether we need to link with a pthreads library.
+#
+if test "x$LIBTHREAD" != x; then
+  LIBGCRYPT_CONFIG_LIBS="${LIBGCRYPT_CONFIG_LIBS} ${LIBTHREAD}"
+fi
+
 
 #
 # Check whether we can use Linux capabilities as requested.
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 0c90875..0ee9ba7 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,2 +1,2 @@
 EXTRA_DIST = libtool.m4 onceonly.m4 socklen.m4 sys_socket_h.m4 noexecstack.m4
-EXTRA_DIST += gpg-error.m4
+EXTRA_DIST += gpg-error.m4 lock.m4 threadlib.m4
diff --git a/m4/lock.m4 b/m4/lock.m4
new file mode 100644
index 0000000..73a3c54
--- /dev/null
+++ b/m4/lock.m4
@@ -0,0 +1,42 @@
+# lock.m4 serial 13 (gettext-0.18.2)
+dnl Copyright (C) 2005-2014 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.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_LOCK],
+[
+  AC_REQUIRE([gl_THREADLIB])
+  if test "$gl_threads_api" = posix; then
+    # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
+    # pthread_rwlock_* functions.
+    AC_CHECK_TYPE([pthread_rwlock_t],
+      [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
+         [Define if the POSIX multithreading library has read/write locks.])],
+      [],
+      [#include <pthread.h>])
+    # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM(
+        [[#include <pthread.h>]],
+        [[
+#if __FreeBSD__ == 4
+error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
+#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \
+       && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
+error "No, in Mac OS X < 10.7 recursive mutexes actually don't work."
+#else
+int x = (int)PTHREAD_MUTEX_RECURSIVE;
+return !x;
+#endif
+        ]])],
+      [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
+         [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
+  fi
+  gl_PREREQ_LOCK
+])
+
+# Prerequisites of lib/glthread/lock.c.
+AC_DEFUN([gl_PREREQ_LOCK], [:])
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
new file mode 100644
index 0000000..b015365
--- /dev/null
+++ b/m4/threadlib.m4
@@ -0,0 +1,349 @@
+# threadlib.m4 serial 10 (gettext-0.18.2) modified by wk 2014-01-24.
+dnl Copyright (C) 2005-2014 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.
+
+dnl From Bruno Haible.
+
+dnl gl_THREADLIB
+dnl ------------
+dnl Tests for a multithreading library to be used.
+dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO
+dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
+dnl default is 'no', otherwise it is system dependent. In both cases, the user
+dnl can change the choice through the options --enable-threads=choice or
+dnl --disable-threads.
+dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
+dnl USE_WINDOWS_THREADS
+dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
+dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
+dnl libtool).
+dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
+dnl programs that really need multithread functionality. The difference
+dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
+dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
+dnl Sets THREADLIB_CPPFLAGS to -D_REENTRANT or -D_THREAD_SAFE if needed for
+dnl multithread-safe programs and adds THREADLIB_CPPFLAGS to CPPFLAGS.
+
+AC_DEFUN([gl_THREADLIB_EARLY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+])
+
+dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_EARLY_BODY],
+[
+  dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
+  dnl influences the result of the autoconf tests that test for *_unlocked
+  dnl declarations, on AIX 5 at least. Therefore it must come early.
+  AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
+  AC_BEFORE([$0], [gl_ARGP])dnl
+
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
+  dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
+  dnl AC_GNU_SOURCE.
+  m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
+    [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
+    [AC_REQUIRE([AC_GNU_SOURCE])])
+  dnl Check for multithreading.
+  THREADLIB_CPPFLAGS=""
+  m4_ifdef([gl_THREADLIB_DEFAULT_NO],
+    [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
+    [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
+  AC_ARG_ENABLE([threads],
+AC_HELP_STRING([--enable-threads={posix|solaris|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
+AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
+    [gl_use_threads=$enableval],
+    [if test -n "$gl_use_threads_default"; then
+       gl_use_threads="$gl_use_threads_default"
+     else
+changequote(,)dnl
+       case "$host_os" in
+         dnl Disable multithreading by default on OSF/1, because it interferes
+         dnl with fork()/exec(): When msgexec is linked with -lpthread, its
+         dnl child process gets an endless segmentation fault inside execvp().
+         dnl Disable multithreading by default on Cygwin 1.5.x, because it has
+         dnl bugs that lead to endless loops or crashes. See
+         dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
+         osf*) gl_use_threads=no ;;
+         cygwin*)
+               case `uname -r` in
+                 1.[0-5].*) gl_use_threads=no ;;
+                 *)         gl_use_threads=yes ;;
+               esac
+               ;;
+         *)    gl_use_threads=yes ;;
+       esac
+changequote([,])dnl
+     fi
+    ])
+  if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+    # For using <pthread.h>:
+    case "$host_os" in
+      osf*)
+        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
+        # groks <pthread.h>. cc also understands the flag -pthread, but
+        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
+        # 2. putting a flag into CPPFLAGS that has an effect on the linker
+        # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
+        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
+        THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT"
+        ;;
+    esac
+    # Some systems optimize for single-threaded programs by default, and
+    # need special flags to disable these optimizations. For example, the
+    # definition of 'errno' in <errno.h>.
+    case "$host_os" in
+      aix* | freebsd*)
+           THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_THREAD_SAFE"
+           ;;
+      solaris*)
+           THREADLIB_CPPFLAGS="$THREADLIB_CPPFLAGS -D_REENTRANT"
+           ;;
+    esac
+  fi
+  if test x"$THREADLIB_CPPFLAGS" != x ; then
+      CPPFLAGS="$CPPFLAGS $THREADLIB_CPPFLAGS"
+  fi
+])
+
+dnl The guts of gl_THREADLIB. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_BODY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+  gl_threads_api=none
+  LIBTHREAD=
+  LTLIBTHREAD=
+  LIBMULTITHREAD=
+  LTLIBMULTITHREAD=
+  if test "$gl_use_threads" != no; then
+    dnl Check whether the compiler and linker support weak declarations.
+    AC_CACHE_CHECK([whether imported symbols can be declared weak],
+      [gl_cv_have_weak],
+      [gl_cv_have_weak=no
+       dnl First, test whether the compiler accepts it syntactically.
+       AC_LINK_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[extern void xyzzy ();
+#pragma weak xyzzy]],
+            [[xyzzy();]])],
+         [gl_cv_have_weak=maybe])
+       if test $gl_cv_have_weak = maybe; then
+         dnl Second, test whether it actually works. On Cygwin 1.7.2, with
+         dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
+         AC_RUN_IFELSE(
+           [AC_LANG_SOURCE([[
+#include <stdio.h>
+#pragma weak fputs
+int main ()
+{
+  return (fputs == NULL);
+}]])],
+           [gl_cv_have_weak=yes],
+           [gl_cv_have_weak=no],
+           [dnl When cross-compiling, assume that only ELF platforms support
+            dnl weak symbols.
+            AC_EGREP_CPP([Extensible Linking Format],
+              [#ifdef __ELF__
+               Extensible Linking Format
+               #endif
+              ],
+              [gl_cv_have_weak="guessing yes"],
+              [gl_cv_have_weak="guessing no"])
+           ])
+       fi
+      ])
+    if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+      # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
+      # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
+      AC_CHECK_HEADER([pthread.h],
+        [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
+      if test "$gl_have_pthread_h" = yes; then
+        # Other possible tests:
+        #   -lpthreads (FSU threads, PCthreads)
+        #   -lgthreads
+        gl_have_pthread=
+        # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
+        # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
+        # the second one only in libpthread, and lock.c needs it.
+        AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[#include <pthread.h>]],
+             [[pthread_mutex_lock((pthread_mutex_t*)0);
+               pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
+          [gl_have_pthread=yes])
+        # Test for libpthread by looking for pthread_kill. (Not pthread_self,
+        # since it is defined as a macro on OSF/1.)
+        if test -n "$gl_have_pthread"; then
+          # The program links fine without libpthread. But it may actually
+          # need to link with libpthread in order to create multiple threads.
+          AC_CHECK_LIB([pthread], [pthread_kill],
+            [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
+             # On Solaris and HP-UX, most pthread functions exist also in libc.
+             # Therefore pthread_in_use() needs to actually try to create a
+             # thread: pthread_create from libc will fail, whereas
+             # pthread_create will actually create a thread.
+             case "$host_os" in
+               solaris* | hpux*)
+                 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
+                   [Define if the pthread_in_use() detection is hard.])
+             esac
+            ])
+        else
+          # Some library is needed. Try libpthread and libc_r.
+          AC_CHECK_LIB([pthread], [pthread_kill],
+            [gl_have_pthread=yes
+             LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
+             LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
+          if test -z "$gl_have_pthread"; then
+            # For FreeBSD 4.
+            AC_CHECK_LIB([c_r], [pthread_kill],
+              [gl_have_pthread=yes
+               LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
+               LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
+          fi
+        fi
+        if test -n "$gl_have_pthread"; then
+          gl_threads_api=posix
+          AC_DEFINE([USE_POSIX_THREADS], [1],
+            [Define if the POSIX multithreading library can be used.])
+          if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+            if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+              AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
+                [Define if references to the POSIX multithreading library should be made weak.])
+              LIBTHREAD=
+              LTLIBTHREAD=
+            fi
+          fi
+        fi
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
+        gl_have_solaristhread=
+        gl_save_LIBS="$LIBS"
+        LIBS="$LIBS -lthread"
+        AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[
+#include <thread.h>
+#include <synch.h>
+             ]],
+             [[thr_self();]])],
+          [gl_have_solaristhread=yes])
+        LIBS="$gl_save_LIBS"
+        if test -n "$gl_have_solaristhread"; then
+          gl_threads_api=solaris
+          LIBTHREAD=-lthread
+          LTLIBTHREAD=-lthread
+          LIBMULTITHREAD="$LIBTHREAD"
+          LTLIBMULTITHREAD="$LTLIBTHREAD"
+          AC_DEFINE([USE_SOLARIS_THREADS], [1],
+            [Define if the old Solaris multithreading library can be used.])
+          if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
+            AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
+              [Define if references to the old Solaris multithreading library should be made weak.])
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      case "$gl_use_threads" in
+        yes | windows | win32) # The 'win32' is for backward compatibility.
+          if { case "$host_os" in
+                 mingw*) true;;
+                 *) false;;
+               esac
+             }; then
+            gl_threads_api=windows
+            AC_DEFINE([USE_WINDOWS_THREADS], [1],
+              [Define if the native Windows multithreading API can be used.])
+          fi
+          ;;
+      esac
+    fi
+  fi
+  AC_MSG_CHECKING([for multithread API to use])
+  AC_MSG_RESULT([$gl_threads_api])
+  AC_SUBST([LIBTHREAD])
+  AC_SUBST([LTLIBTHREAD])
+  AC_SUBST([LIBMULTITHREAD])
+  AC_SUBST([LTLIBMULTITHREAD])
+])
+
+AC_DEFUN([gl_THREADLIB],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY])
+  AC_REQUIRE([gl_THREADLIB_BODY])
+])
+
+
+dnl gl_DISABLE_THREADS
+dnl ------------------
+dnl Sets the gl_THREADLIB default so that threads are not used by default.
+dnl The user can still override it at installation time, by using the
+dnl configure option '--enable-threads'.
+
+AC_DEFUN([gl_DISABLE_THREADS], [
+  m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
+])
+
+
+dnl Survey of platforms:
+dnl
+dnl Platform           Available  Compiler    Supports   test-lock
+dnl                    flavours   option      weak       result
+dnl ---------------    ---------  ---------   --------   ---------
+dnl Linux 2.4/glibc    posix      -lpthread       Y      OK
+dnl
+dnl GNU Hurd/glibc     posix
+dnl
+dnl FreeBSD 5.3        posix      -lc_r           Y
+dnl                    posix      -lkse ?         Y
+dnl                    posix      -lpthread ?     Y
+dnl                    posix      -lthr           Y
+dnl
+dnl FreeBSD 5.2        posix      -lc_r           Y
+dnl                    posix      -lkse           Y
+dnl                    posix      -lthr           Y
+dnl
+dnl FreeBSD 4.0,4.10   posix      -lc_r           Y      OK
+dnl
+dnl NetBSD 1.6         --
+dnl
+dnl OpenBSD 3.4        posix      -lpthread       Y      OK
+dnl
+dnl Mac OS X 10.[123]  posix      -lpthread       Y      OK
+dnl
+dnl Solaris 7,8,9      posix      -lpthread       Y      Sol 7,8: 0.0; Sol 9: OK
+dnl                    solaris    -lthread        Y      Sol 7,8: 0.0; Sol 9: OK
+dnl
+dnl HP-UX 11           posix      -lpthread       N (cc) OK
+dnl                                               Y (gcc)
+dnl
+dnl IRIX 6.5           posix      -lpthread       Y      0.5
+dnl
+dnl AIX 4.3,5.1        posix      -lpthread       N      AIX 4: 0.5; AIX 5: OK
+dnl
+dnl OSF/1 4.0,5.1      posix      -pthread (cc)   N      OK
+dnl                               -lpthread (gcc) Y
+dnl
+dnl Cygwin             posix      -lpthread       Y      OK
+dnl
+dnl Any of the above   pth        -lpth                  0.0
+dnl
+dnl Mingw              windows                    N      OK
+dnl
+dnl BeOS 5             --
+dnl
+dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
+dnl turned off:
+dnl   OK if all three tests terminate OK,
+dnl   0.5 if the first test terminates OK but the second one loops endlessly,
+dnl   0.0 if the first test already loops endlessly.
diff --git a/src/Makefile.am b/src/Makefile.am
index c020239..2d4800f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -126,20 +126,20 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
 
 dumpsexp_SOURCES = dumpsexp.c
 dumpsexp_CFLAGS = $(arch_gpg_error_cflags)
-dumpsexp_LDADD = $(arch_gpg_error_libs)
+dumpsexp_LDADD = $(arch_gpg_error_libs) $(LIBTHREAD)
 
 mpicalc_SOURCES = mpicalc.c
 mpicalc_CFLAGS = $(GPG_ERROR_CFLAGS)
-mpicalc_LDADD = libgcrypt.la $(GPG_ERROR_LIBS)
+mpicalc_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(LIBTHREAD)
 
 hmac256_SOURCES = hmac256.c
 hmac256_CFLAGS = -DSTANDALONE $(arch_gpg_error_cflags)
-hmac256_LDADD = $(arch_gpg_error_libs)
+hmac256_LDADD = $(arch_gpg_error_libs) $(LIBTHREAD)
 
 if USE_RANDOM_DAEMON
 gcryptrnd_SOURCES = gcryptrnd.c
 gcryptrnd_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS)
-gcryptrnd_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(PTH_LIBS)
+gcryptrnd_LDADD = libgcrypt.la $(GPG_ERROR_LIBS) $(PTH_LIBS) $(LIBTHREAD)
 
 getrandom_SOURCES = getrandom.c
 endif USE_RANDOM_DAEMON
diff --git a/src/ath.c b/src/ath.c
index ca40de5..9085d3e 100644
--- a/src/ath.c
+++ b/src/ath.c
@@ -26,12 +26,17 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#if USE_POSIX_THREADS_WEAK
+#if USE_POSIX_THREADS
 # include <pthread.h>
 #endif
 
 #include "ath.h"
 
+#if USE_POSIX_THREADS_WEAK
+# if  !USE_POSIX_THREADS
+#  error USE_POSIX_THREADS_WEAK but no USE_POSIX_THREADS
+# endif
+#endif
 
 

 /* On an ELF system it is easy to use pthreads using weak references.
@@ -101,10 +106,12 @@ ath_init (void)
     {
 #if HAVE_W32_SYSTEM
       thread_model = ath_model_w32;
-#else /*!HAVE_W32_SYSTEM*/
+#elif USE_POSIX_THREADS && !USE_POSIX_THREADS_WEAK
+      thread_model = ath_model_pthreads;
+#else /*!USE_POSIX_THREADS*/
       /* Assume a single threaded application.  */
       thread_model = ath_model_none;
-#endif /*!HAVE_W32_SYSTEM*/
+#endif /*!USE_POSIX_THREADS*/
     }
 
   return err;
@@ -155,15 +162,16 @@ ath_install (struct ath_ops *ath_ops)
      configured one.  */
   if (0)
     ;
-#if USE_POSIX_THREADS_WEAK
-  else if (thread_model == ath_model_pthreads_weak)
+#if USE_POSIX_THREADS
+  else if (thread_model == ath_model_pthreads
+           || thread_model == ath_model_pthreads_weak)
     {
       if (thread_option == ATH_THREAD_OPTION_PTHREAD)
         return 0; /* Okay - compatible.  */
       if (thread_option == ATH_THREAD_OPTION_PTH)
         return 0; /* Okay - compatible.  */
     }
-#endif /*USE_POSIX_THREADS_WEAK*/
+#endif /*USE_POSIX_THREADS*/
   else if (thread_option == ATH_THREAD_OPTION_PTH)
     {
       if (thread_model == ath_model_none)
@@ -195,7 +203,8 @@ ath_mutex_init (ath_mutex_t *lock)
       err = 0;
       break;
 
-#if USE_POSIX_THREADS_WEAK
+#if USE_POSIX_THREADS
+    case ath_model_pthreads:
     case ath_model_pthreads_weak:
       {
         pthread_mutex_t *plck;
@@ -213,7 +222,7 @@ ath_mutex_init (ath_mutex_t *lock)
           }
       }
       break;
-#endif /*USE_POSIX_THREADS_WEAK*/
+#endif /*USE_POSIX_THREADS*/
 
 #if HAVE_W32_SYSTEM
     case ath_model_w32:
@@ -265,7 +274,8 @@ ath_mutex_destroy (ath_mutex_t *lock)
         }
       break;
 
-#if USE_POSIX_THREADS_WEAK
+#if USE_POSIX_THREADS
+    case ath_model_pthreads:
     case ath_model_pthreads_weak:
       {
         pthread_mutex_t *plck = (pthread_mutex_t*) (*lock);
@@ -278,7 +288,7 @@ ath_mutex_destroy (ath_mutex_t *lock)
           }
       }
       break;
-#endif /*USE_POSIX_THREADS_WEAK*/
+#endif /*USE_POSIX_THREADS*/
 
 #if HAVE_W32_SYSTEM
     case ath_model_w32:
@@ -322,11 +332,12 @@ ath_mutex_lock (ath_mutex_t *lock)
         err = EDEADLK;
       break;
 
-#if USE_POSIX_THREADS_WEAK
+#if USE_POSIX_THREADS
+    case ath_model_pthreads:
     case ath_model_pthreads_weak:
       err = pthread_mutex_lock ((pthread_mutex_t*)(*lock));
       break;
-#endif /*USE_POSIX_THREADS_WEAK*/
+#endif /*USE_POSIX_THREADS*/
 
 #if HAVE_W32_SYSTEM
     case ath_model_w32:
@@ -368,11 +379,12 @@ ath_mutex_unlock (ath_mutex_t *lock)
         err = EPERM;
       break;
 
-#if USE_POSIX_THREADS_WEAK
+#if USE_POSIX_THREADS
+    case ath_model_pthreads:
     case ath_model_pthreads_weak:
       err = pthread_mutex_unlock ((pthread_mutex_t*)(*lock));
       break;
-#endif /*USE_POSIX_THREADS_WEAK*/
+#endif /*USE_POSIX_THREADS*/
 
 #if HAVE_W32_SYSTEM
     case ath_model_w32:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6cde99f..9645471 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,5 +58,5 @@ EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \
 	     pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \
 	     t-ed25519.inp stopwatch.h hashtest-256g.in
 
-LDADD = $(default_ldadd)
+LDADD = $(default_ldadd) $(LIBTHREAD)
 t_lock_LDADD = $(default_ldadd) $(LIBMULTITHREAD)
diff --git a/tests/t-lock.c b/tests/t-lock.c
index cae5748..e370f3e 100644
--- a/tests/t-lock.c
+++ b/tests/t-lock.c
@@ -27,7 +27,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <unistd.h>
-#if HAVE_PTHREAD
+#if USE_POSIX_THREADS
 # include <pthread.h>
 #endif
 
@@ -193,7 +193,7 @@ check_nonce_lock (void)
       CloseHandle (threads[i]);
     }
 
-#elif HAVE_PTHREAD
+#elif USE_POSIX_THREADS
   pthread_t threads[N_NONCE_THREADS];
   int rc, i;
 
@@ -360,7 +360,7 @@ run_test (void)
     fail ("waiting for revision thread failed: %d", (int)GetLastError ());
   CloseHandle (rthread);
 
-#else /*!_WIN32*/
+#elif USE_POSIX_THREADS
   pthread_t rthread;
   pthread_t athreads[N_ACCOUNTANTS];
   int rc, i;
@@ -389,7 +389,7 @@ run_test (void)
   else
     show ("revision thread has terminated");
 
-#endif /*!_WIN32*/
+#endif /*USE_POSIX_THREADS*/
 
   external_lock_test_destroy (__LINE__);
 }

commit 7259af184e6ca0b8e3fffc264fb5e047f25a08b8
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 29 09:43:00 2014 +0100

    tests: Remove non-portable format specifiers.
    
    * tests/basic.c: Replace "%zi" by "%d" and casts.

diff --git a/tests/basic.c b/tests/basic.c
index bebfa67..86be89d 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -4067,11 +4067,11 @@ check_digests (void)
           continue;
         }
       if (verbose)
-	fprintf (stderr, "  checking %s [%i] for length %zi\n",
+	fprintf (stderr, "  checking %s [%i] for length %d\n",
 		 gcry_md_algo_name (algos[i].md),
 		 algos[i].md,
                  !strcmp (algos[i].data, "!")?
-                 1000000 : strlen(algos[i].data));
+                 1000000 : (int)strlen(algos[i].data));
 
       check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data),
 		    algos[i].expect);
@@ -4492,10 +4492,10 @@ check_hmac (void)
         }
       if (verbose)
 	fprintf (stderr,
-                 "  checking %s [%i] for %zi byte key and %zi byte data\n",
+                 "  checking %s [%i] for %d byte key and %d byte data\n",
 		 gcry_md_algo_name (algos[i].md),
 		 algos[i].md,
-		 strlen(algos[i].key), strlen(algos[i].data));
+		 (int)strlen(algos[i].key), (int)strlen(algos[i].data));
 
       check_one_hmac (algos[i].md, algos[i].data, strlen (algos[i].data),
 		      algos[i].key, strlen(algos[i].key),
@@ -5089,10 +5089,10 @@ check_mac (void)
         }
       if (verbose)
 	fprintf (stderr,
-                 "  checking %s [%i] for %zi byte key and %zi byte data\n",
+                 "  checking %s [%i] for %d byte key and %d byte data\n",
 		 gcry_mac_algo_name (algos[i].algo),
 		 algos[i].algo,
-		 strlen(algos[i].key), strlen(algos[i].data));
+		 (int)strlen(algos[i].key), (int)strlen(algos[i].data));
 
       check_one_mac (algos[i].algo, algos[i].data, strlen (algos[i].data),
 		     algos[i].key, strlen(algos[i].key), algos[i].iv,

commit f9948609a51fa10e440de19e877b1795534eff90
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Wed Jan 29 08:32:46 2014 +0900

    Fix RSA Blinding.
    
    * cipher/rsa.c (rsa_decrypt): Loop to get multiplicative inverse.
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
    (cherry picked from commit 121a90d8931944974054f7d94f63b7f89df87fa5)

diff --git a/cipher/rsa.c b/cipher/rsa.c
index e595e38..9a8d235 100644
--- a/cipher/rsa.c
+++ b/cipher/rsa.c
@@ -1023,13 +1023,12 @@ rsa_decrypt (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms)
       ri = mpi_snew (ctx.nbits);
       bldata = mpi_snew (ctx.nbits);
 
-      _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM);
-      mpi_mod (r, r, sk.n);
-      if (!mpi_invm (ri, r, sk.n))
+      do
         {
-          rc = GPG_ERR_INTERNAL;
-          goto leave;
+          _gcry_mpi_randomize (r, ctx.nbits, GCRY_WEAK_RANDOM);
+          mpi_mod (r, r, sk.n);
         }
+      while (!mpi_invm (ri, r, sk.n));
 
       /* Do blinding.  We calculate: y = (x * r^e) mod n, where r is
          the random number, e is the public exponent, x is the

-----------------------------------------------------------------------

Summary of changes:
 cipher/rsa.c      |    9 +-
 configure.ac      |   33 +++--
 m4/Makefile.am    |    2 +-
 m4/lock.m4        |   42 +++++++
 m4/threadlib.m4   |  349 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am   |    8 +-
 src/ath.c         |   40 +++---
 src/gcrypt.h.in   |    4 +-
 src/global.c      |    5 +
 tests/Makefile.am |    2 +-
 tests/basic.c     |   12 +-
 tests/t-lock.c    |    8 +-
 12 files changed, 469 insertions(+), 45 deletions(-)
 create mode 100644 m4/lock.m4
 create mode 100644 m4/threadlib.m4


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list