[svn] gcry - r1195 - in trunk: . cipher mpi src tests

svn author wk cvs at cvs.gnupg.org
Mon Dec 18 20:02:49 CET 2006


Author: wk
Date: 2006-12-18 20:02:48 +0100 (Mon, 18 Dec 2006)
New Revision: 1195

Modified:
   trunk/ChangeLog
   trunk/THANKS
   trunk/TODO
   trunk/autogen.sh
   trunk/cipher/ChangeLog
   trunk/cipher/Makefile.am
   trunk/cipher/random.c
   trunk/cipher/rndlinux.c
   trunk/cipher/serpent.c
   trunk/mpi/ChangeLog
   trunk/mpi/Makefile.am
   trunk/src/gcrypt.h.in
   trunk/tests/ChangeLog
   trunk/tests/Makefile.am
   trunk/tests/ac-data.c
   trunk/tests/keygen.c
Log:
* rndlinux.c (set_cloexec_flag): New.
(open_device): Set close-on-exit flags.  Suggested by Max
Kellermann.  Fixes Debian#403613.

Cleaned up last Makefile changes.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/ChangeLog	2006-12-18 19:02:48 UTC (rev 1195)
@@ -1,3 +1,7 @@
+2006-11-15  Werner Koch  <wk at g10code.com>
+
+	* autogen.sh: Add convenience option --build-amd64.
+
 2006-10-20  Werner Koch  <wk at g10code.com>
 
 	* Makefile.am (stowinstall): New convenience target.

Modified: trunk/THANKS
===================================================================
--- trunk/THANKS	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/THANKS	2006-12-18 19:02:48 UTC (rev 1195)
@@ -24,6 +24,7 @@
 David Ellement		   ellement at sdd.hp.com
 Detlef Lannert		   lannert at lannert.rz.uni-duesseldorf.de
 Dirk Lattermann 	   dlatt at t-online.de
+Dirk Stoecker              gcrypt at dstoecker.de
 Ed Boraas		   ecxjo at esperanto.org
 Enzo Michelangeli	   em at MailAndNews.com
 Ernst Molitor		   ernst.molitor at uni-bonn.de
@@ -70,6 +71,7 @@
 Martin Hamilton
 Martin Schulte		   schulte at thp.uni-koeln.de
 Matthew Skala		   mskala at ansuz.sooke.bc.ca
+Max Kellermann             max at duempel.org
 Max Valianskiy		   maxcom at maxcom.ml.org
 Michael Fischer v. Mollard mfvm at gmx.de
 Michael Roth		   mroth at nessie.de
@@ -92,6 +94,7 @@
 Peter Gutmann		   pgut001 at cs.auckland.ac.nz
 QingLong		   qinglong at bolizm.ihep.su
 Rafael Ávila de Espíndola  rafael.espindola at gmail.com
+Rafaël Carré               funman at videolan.org
 Ralf Fassel                ralf at akutech.de
 Ralf Hildebrandt           Ralf.Hildebrandt at innominate.com 
 Ralf Schneider             ralf at tapfere-schneiderleins.de
@@ -130,6 +133,7 @@
 Umberto Salsi		   salsi at icosaedro.it
 Uoti Urpala
 Urko Lusa		   ulusa at euskalnet.net
+Victor Stinner             haypo at inl.fr
 Walter Koch		   koch at u32.de
 Werner Koch		   wk at gnupg.org
 Wim Vandeputte		   wim at kd85.com

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/TODO	2006-12-18 19:02:48 UTC (rev 1195)
@@ -66,4 +66,16 @@
 
 * Add OAEP
 
+* Next API break:
+** gcry_ac_io_t
+  Remove use of anonymous union.
 
+* ac.c
+  There are still some things fishy.  The fixes I did todat
+  (2006-10-23) seem to cure just a symptom.  Needs a complete review.
+
+* gcryptrnd.c
+  Requires test for pth and other stuff.
+
+
+

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/autogen.sh	2006-12-18 19:02:48 UTC (rev 1195)
@@ -29,6 +29,103 @@
 }
 
 
+DIE=no
+
+# ***** W32 build script *******
+# Used to cross-compile for Windows.
+if test "$1" = "--build-w32"; then
+    tmp=`dirname $0`
+    tsdir=`cd "$tmp"; pwd`
+    shift
+    if [ ! -f $tsdir/config.guess ]; then
+        echo "$tsdir/config.guess not found" >&2
+        exit 1
+    fi
+    build=`$tsdir/config.guess`
+
+    [ -z "$w32root" ] && w32root="$HOME/w32root"
+    echo "Using $w32root as standard install directory" >&2
+    
+    # Locate the cross compiler
+    crossbindir=
+    for host in i586-mingw32msvc i386-mingw32msvc; do
+        if ${host}-gcc --version >/dev/null 2>&1 ; then
+            crossbindir=/usr/${host}/bin
+            conf_CC="CC=${host}-gcc"
+            break;
+        fi
+    done
+    if [ -z "$crossbindir" ]; then
+        echo "Cross compiler kit not installed" >&2
+        echo "Under Debian GNU/Linux, you may install it using" >&2
+        echo "  apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 
+        echo "Stop." >&2
+        exit 1
+    fi
+   
+    if [ -f "$tsdir/config.log" ]; then
+        if ! head $tsdir/config.log | grep "$host" >/dev/null; then
+            echo "Pease run a 'make distclean' first" >&2
+            exit 1
+        fi
+    fi
+
+    ./configure --enable-maintainer-mode  --prefix=${w32root}  \
+            --host=${host} --build=${build} \
+            --with-gpg-error-prefix=${w32root}  \
+            --disable-shared    
+
+    exit $?
+fi
+# ***** end W32 build script *******
+
+
+# ***** AMD64 cross build script *******
+# Used to cross-compile for AMD64 (for testing)
+if test "$1" = "--build-amd64"; then
+    tmp=`dirname $0`
+    tsdir=`cd "$tmp"; pwd`
+    shift
+    if [ ! -f $tsdir/config.guess ]; then
+        echo "$tsdir/config.guess not found" >&2
+        exit 1
+    fi
+    build=`$tsdir/config.guess`
+
+    [ -z "$amd64root" ] && amd64root="$HOME/amd64root"
+    echo "Using $amd64root as standard install directory" >&2
+    
+    # Locate the cross compiler
+    crossbindir=
+    for host in x86_64-linux-gnu amd64-linux-gnu; do
+        if ${host}-gcc --version >/dev/null 2>&1 ; then
+            crossbindir=/usr/${host}/bin
+            conf_CC="CC=${host}-gcc"
+            break;
+        fi
+    done
+    if [ -z "$crossbindir" ]; then
+        echo "Cross compiler kit not installed" >&2
+        echo "Stop." >&2
+        exit 1
+    fi
+   
+    if [ -f "$tsdir/config.log" ]; then
+        if ! head $tsdir/config.log | grep "$host" >/dev/null; then
+            echo "Please run a 'make distclean' first" >&2
+            exit 1
+        fi
+    fi
+
+    $tsdir/configure --enable-maintainer-mode --prefix=${amd64root}  \
+             --host=${host} --build=${build} \
+             --with-gpg-error-prefix=${amd64root} 
+ 
+    rc=$?
+    exit $rc
+fi
+# ***** end AMD64 cross build script *******
+
 # Grep the required versions from configure.ac
 autoconf_vers=`sed -n '/^AC_PREREQ(/ { 
 s/^.*(\(.*\))/\1/p
@@ -65,9 +162,7 @@
 #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
 #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
 
-DIE=no
 
-
 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
     check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
 fi

Modified: trunk/cipher/ChangeLog
===================================================================
--- trunk/cipher/ChangeLog	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/cipher/ChangeLog	2006-12-18 19:02:48 UTC (rev 1195)
@@ -1,3 +1,26 @@
+2006-12-18  Werner Koch  <wk at g10code.com>
+
+	* rndlinux.c (set_cloexec_flag): New.
+	(open_device): Set close-on-exit flags.  Suggested by Max
+	Kellermann.  Fixes Debian#403613.
+
+	* Makefile.am (AM_CPPFLAGS, AM_CFLAGS): Splitted and merged
+	Moritz' changes.
+	(INCLUDES): Removed.
+
+2006-11-30  Werner Koch  <wk at g10code.com>
+
+	* serpent.c (byte_swap_32): Remove trailing semicolon.
+
+2006-11-15  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (INCLUDES): Include ../src/
+
+2006-11-03  Werner Koch  <wk at g10code.com>
+
+	* random.c [HAVE_GETTIMEOFDAY]: Included sys/time.h and not
+	sys/times.h.  Reported by Rafaël Carré.
+
 2006-11-05  Moritz Schulte  <moritz at g10code.com>
 
 	* Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the

Modified: trunk/cipher/Makefile.am
===================================================================
--- trunk/cipher/Makefile.am	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/cipher/Makefile.am	2006-12-18 19:02:48 UTC (rev 1195)
@@ -21,8 +21,13 @@
 # Process this file with automake to produce Makefile.in
 
 EXTRA_DIST = Manifest
-INCLUDES = -I$(top_srcdir)/src 
 
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src 
+AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+
+
 noinst_LTLIBRARIES = libcipher.la
 
 GCRYPT_MODULES = @GCRYPT_CIPHERS@ @GCRYPT_PUBKEY_CIPHERS@ @GCRYPT_DIGESTS@ \
@@ -30,7 +35,6 @@
 
 libcipher_la_DEPENDENCIES = $(GCRYPT_MODULES)
 libcipher_la_LIBADD = $(GCRYPT_MODULES)
-AM_CFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 
 libcipher_la_SOURCES = \
 cipher.c pubkey.c ac.c md.c \

Modified: trunk/cipher/random.c
===================================================================
--- trunk/cipher/random.c	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/cipher/random.c	2006-12-18 19:02:48 UTC (rev 1195)
@@ -43,7 +43,7 @@
 #include <sys/times.h>
 #endif
 #ifdef HAVE_GETTIMEOFDAY
-#include <sys/times.h>
+#include <sys/time.h>
 #endif
 #ifdef HAVE_GETRUSAGE
 #include <sys/resource.h>

Modified: trunk/cipher/rndlinux.c
===================================================================
--- trunk/cipher/rndlinux.c	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/cipher/rndlinux.c	2006-12-18 19:02:48 UTC (rev 1195)
@@ -41,6 +41,21 @@
                                   int requester,
                                   size_t length, int level );
 
+
+static int
+set_cloexec_flag (int fd)
+{
+  int oldflags;
+
+  oldflags= fcntl (fd, F_GETFD, 0);
+  if (oldflags < 0)
+    return oldflags;
+  oldflags |= FD_CLOEXEC;
+  return fcntl (fd, F_SETFD, oldflags);
+}
+
+
+
 /*
  * Used to open the /dev/random devices (Linux, xBSD, Solaris (if it exists)).
  */
@@ -49,10 +64,14 @@
 {
   int fd;
 
-  fd = open( name, O_RDONLY );
-  if( fd == -1 )
+  fd = open ( name, O_RDONLY );
+  if ( fd == -1 )
     log_fatal ("can't open %s: %s\n", name, strerror(errno) );
 
+  if (set_cloexec_flag (fd))
+    log_error ("error setting FD_CLOEXEC on fd %d: %s\n",
+               fd, strerror (errno));
+
   /* We used to do the follwing check, however it turned out that this
      is not portable since more OSes provide a random device which is
      sometimes implemented as anoteher device type. 

Modified: trunk/cipher/serpent.c
===================================================================
--- trunk/cipher/serpent.c	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/cipher/serpent.c	2006-12-18 19:02:48 UTC (rev 1195)
@@ -59,7 +59,7 @@
 #define byte_swap_32(x) \
   (0 \
    | (((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) \
-   | (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24));
+   | (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
 
 /* These are the S-Boxes of Serpent.  They are copied from Serpents
    reference implementation (the optimized one, contained in

Modified: trunk/mpi/ChangeLog
===================================================================
--- trunk/mpi/ChangeLog	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/mpi/ChangeLog	2006-12-18 19:02:48 UTC (rev 1195)
@@ -1,3 +1,10 @@
+2006-11-15  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (.S.o): Check for srcdir also in in CPP pass.
+	(INCLUDES): Removed.
+	(AM_CPPFLAGS, AM_CFLAGS): New, modified. Merged with Moritz'
+	changes.
+
 2006-11-05  Moritz Schulte  <moritz at g10code.com>
 
 	* Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the

Modified: trunk/mpi/Makefile.am
===================================================================
--- trunk/mpi/Makefile.am	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/mpi/Makefile.am	2006-12-18 19:02:48 UTC (rev 1195)
@@ -21,10 +21,15 @@
 # I was not able to build it with 64Megs - 1.6 fixes this.
 # not anymore required: AUTOMAKE_OPTIONS = 1.6
 
-INCLUDES =  -I$(top_srcdir)/src
-ASFLAGS = @MPI_SFLAGS@
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
+AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+
+AM_ASFLAGS = $(MPI_SFLAGS)
 AM_CCASFLAGS = $(NOEXECSTACK_FLAGS)
 
+
 # We don't have .S sources listed, so automake does not autocreate these
 CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
 LTCCASCOMPILE = $(LIBTOOL) --mode=compile $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
@@ -151,7 +156,6 @@
 
 noinst_LTLIBRARIES = libmpi.la
 
-AM_CFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 libmpi_la_LDFLAGS =
 libmpi_la_SOURCES = longlong.h	   \
 	      mpi-add.c      \
@@ -182,7 +186,9 @@
 SUFFIXES = .S .o .obj .lo
 
 .S.o:
-	$(CPP) $(INCLUDES) $(DEFS) $< | grep -v '^#' > $*.s
+	$(CPP) $(INCLUDES) $(AM_CPPFLAGS) $(DEFS) \
+           `test -f '$<' || echo '$(srcdir)/'`$< \
+           | grep -v '^#' > $*.s
 	$(CCASCOMPILE) -c `test -f '$*.s' || echo '$(srcdir)/'`$*.s
 	rm $*.s
 
@@ -190,6 +196,8 @@
 	$(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
 
 .S.lo:
-	$(CPP) $(INCLUDES) $(DEFS) $< | grep -v '^#' > $*.s
+	$(CPP) $(INCLUDES) $(AM_CPPFLAGS) $(DEFS) \
+           `test -f '$<' || echo '$(srcdir)/'`$< \
+           | grep -v '^#' > $*.s
 	$(LTCCASCOMPILE) -c -o $@ `test -f '$*.s' || echo '$(srcdir)/'`$*.s
 	rm $*.s

Modified: trunk/src/gcrypt.h.in
===================================================================
--- trunk/src/gcrypt.h.in	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/src/gcrypt.h.in	2006-12-18 19:02:48 UTC (rev 1195)
@@ -1,4 +1,4 @@
-/* gcrypt.h -  GNU cryptographic library interface
+/* gcrypt.h -  GNU cryptographic library interface              -*- c -*-
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
  *               2004, 2006  Free Software Foundation, Inc.
  *

Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/tests/ChangeLog	2006-12-18 19:02:48 UTC (rev 1195)
@@ -1,3 +1,12 @@
+2006-12-18  Werner Koch  <wk at g10code.com>
+
+	* Makefile.am (AM_CFLAGS, AM_CPPFLAGS): Splitted and merged with
+	Moritz' changes.
+	(INCLUDES): Removed.
+
+	* keygen.c (progress_handler): New.
+	(main): Use it in verbose mode.
+
 2006-11-05  Moritz Schulte  <moritz at g10code.com>
 
 	* Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the

Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/tests/Makefile.am	2006-12-18 19:02:48 UTC (rev 1195)
@@ -21,10 +21,13 @@
 TESTS = t-mpi-bit prime register ac ac-schemes ac-data basic \
         tsexp keygen pubkey benchmark pkbench hmac keygrip
 
-INCLUDES = -I$(top_srcdir)/src
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
+AM_CFLAGS = $(GPG_ERROR_CFLAGS)
+
 LDADD = ../src/libgcrypt.la
 
 EXTRA_PROGRAMS = testapi
 noinst_PROGRAMS = $(TESTS)
 
-AM_CFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@

Modified: trunk/tests/ac-data.c
===================================================================
--- trunk/tests/ac-data.c	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/tests/ac-data.c	2006-12-18 19:02:48 UTC (rev 1195)
@@ -78,6 +78,8 @@
       assert_err (err);
       err = gcry_ac_data_get_index (data2, 0, i, &label2, &mpi2);
       assert_err (err);
+      fprintf (stderr, "Label1=`%s'\n", label1);
+      fprintf (stderr, "Label1=`%s'\n", label2);
       assert (! strcmp (label1, label2));
       assert (! gcry_mpi_cmp (mpi1, mpi2));
     }

Modified: trunk/tests/keygen.c
===================================================================
--- trunk/tests/keygen.c	2006-12-18 18:06:38 UTC (rev 1194)
+++ trunk/tests/keygen.c	2006-12-18 19:02:48 UTC (rev 1195)
@@ -30,6 +30,7 @@
 
 
 static int verbose;
+static int debug;
 static int error_count;
 
 static void
@@ -122,11 +123,32 @@
 {
   gcry_sexp_t keyparm, key;
   int rc;
+  int i;
 
   /* Check that DSA generation works and that it can grok the qbits
      argument. */
   if (verbose)
-    fprintf (stderr, "creating 1536 bit DSA key using old interface\n");
+    fprintf (stderr, "creating 5 1024 bit DSA keys\n");
+  for (i=0; i < 5; i++)
+    {
+      rc = gcry_sexp_new (&keyparm, 
+                          "(genkey\n"
+                          " (dsa\n"
+                          "  (nbits 4:1024)\n"
+                          " ))", 0, 1);
+      if (rc)
+        die ("error creating S-expression: %s\n", gpg_strerror (rc));
+      rc = gcry_pk_genkey (&key, keyparm);
+      gcry_sexp_release (keyparm);
+      if (rc)
+        die ("error generating DSA key: %s\n", gpg_strerror (rc));
+      gcry_sexp_release (key);
+      if (verbose)
+        fprintf (stderr, "  done\n");
+    }
+
+  if (verbose)
+    fprintf (stderr, "creating 1536 bit DSA key\n");
   rc = gcry_sexp_new (&keyparm, 
                       "(genkey\n"
                       " (dsa\n"
@@ -139,17 +161,18 @@
   gcry_sexp_release (keyparm);
   if (rc)
     die ("error generating DSA key: %s\n", gpg_strerror (rc));
-  {
-    char buffer[20000];
-    gcry_sexp_sprint (key, GCRYSEXP_FMT_ADVANCED, buffer, sizeof buffer);
-    if (verbose)
-      printf ("=============================\n%s\n"
-              "=============================\n", buffer);
-  }
+  if (debug)
+    {
+      char buffer[20000];
+      gcry_sexp_sprint (key, GCRYSEXP_FMT_ADVANCED, buffer, sizeof buffer);
+      if (verbose)
+        printf ("=============================\n%s\n"
+                "=============================\n", buffer);
+    }
   gcry_sexp_release (key);
 
   if (verbose)
-    fprintf (stderr, "creating 1024 bit RSA key using old interface\n");
+    fprintf (stderr, "creating 1024 bit RSA key\n");
   rc = gcry_sexp_new (&keyparm, 
                       "(genkey\n"
                       " (rsa\n"
@@ -243,11 +266,19 @@
     }
 }
 
+
+static void
+progress_cb (void *cb_data, const char *what, int printchar,
+		  int current, int total)
+{
+  putchar (printchar);
+  fflush (stdout);
+}
+
+
 int
 main (int argc, char **argv)
 {
-  int debug = 0;
-
   if (argc > 1 && !strcmp (argv[1], "--verbose"))
     verbose = 1;
   else if (argc > 1 && !strcmp (argv[1], "--debug"))
@@ -261,6 +292,8 @@
     gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0);
   /* No valuable keys are create, so we can speed up our RNG. */
   gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
+  if (verbose)
+    gcry_set_progress_handler ( progress_cb, NULL );
 
   check_rsa_keys ();
   check_nonce ();




More information about the Gnupg-commits mailing list