[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-101-g5fb3501

by Werner Koch cvs at cvs.gnupg.org
Wed Mar 20 17:53:12 CET 2013


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, master has been updated
       via  5fb3501aa0cf5f2b2a9012706bb9ad2b1c4bfd7d (commit)
       via  b402e550041782b770a6ae267c7c28ca8324a12e (commit)
       via  1eaad0a8c4cab227685a6a8768e539df2f1f4dac (commit)
       via  de07974d807b703a2554d6ba885ea249e648bd44 (commit)
      from  931e409e877d1e444edd53dead327ec8e64daf9a (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 5fb3501aa0cf5f2b2a9012706bb9ad2b1c4bfd7d
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Mar 20 17:23:54 2013 +0100

    Use finer grained on-the-fly helper computations for EC.
    
    * src/ec-context.h (mpi_ec_ctx_s): Replace NEED_SYNC by a bitfield.
    * mpi/ec.c (ec_p_sync): Remove.
    (ec_get_reset, ec_get_a_is_pminus3, ec_get_two_inv_p): New.
    (ec_p_init): Use ec_get_reset.
    (_gcry_mpi_ec_set_mpi, _gcry_mpi_ec_dup_point)
    (_gcry_mpi_ec_add_points): Replace ec_p_sync by the ec_get_ accessors.

diff --git a/mpi/ec.c b/mpi/ec.c
index 0a348d2..cd19c81 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -337,22 +337,46 @@ ec_invm (gcry_mpi_t x, gcry_mpi_t a, mpi_ec_t ctx)
 }
 
 
-/* Sync changed data in the context.  */
+/* Force recomputation of all helper variables.  */
 static void
-ec_p_sync (mpi_ec_t ec)
+ec_get_reset (mpi_ec_t ec)
+{
+  ec->t.valid.a_is_pminus3 = 0;
+  ec->t.valid.two_inv_p = 0;
+}
+
+
+/* Accessor for helper variable.  */
+static int
+ec_get_a_is_pminus3 (mpi_ec_t ec)
 {
   gcry_mpi_t tmp;
 
-  if (!ec->t.need_sync)
-    return;
+  if (!ec->t.valid.a_is_pminus3)
+    {
+      ec->t.valid.a_is_pminus3 = 1;
+      tmp = mpi_alloc_like (ec->p);
+      mpi_sub_ui (tmp, ec->p, 3);
+      ec->t.a_is_pminus3 = !mpi_cmp (ec->a, tmp);
+      mpi_free (tmp);
+    }
+
+  return ec->t.a_is_pminus3;
+}
 
-  tmp = mpi_alloc_like (ec->p);
-  mpi_sub_ui (tmp, ec->p, 3);
-  ec->t.a_is_pminus3 = !mpi_cmp (ec->a, tmp);
-  mpi_free (tmp);
 
-  ec_invm (ec->t.two_inv_p, mpi_const (MPI_C_TWO), ec);
-  ec->t.need_sync = 0;
+/* Accessor for helper variable.  */
+static gcry_mpi_t
+ec_get_two_inv_p (mpi_ec_t ec)
+{
+  if (!ec->t.valid.two_inv_p)
+    {
+      ec->t.valid.two_inv_p = 1;
+      if (!ec->t.two_inv_p)
+        ec->t.two_inv_p = mpi_alloc (0);
+      ec_invm (ec->t.two_inv_p, mpi_const (MPI_C_TWO), ec);
+    }
+  return ec->t.two_inv_p;
 }
 
 
@@ -370,8 +394,7 @@ ec_p_init (mpi_ec_t ctx, gcry_mpi_t p, gcry_mpi_t a)
   ctx->p = mpi_copy (p);
   ctx->a = mpi_copy (a);
 
-  ctx->t.need_sync = 1;
-  ctx->t.two_inv_p = mpi_alloc (0);
+  ec_get_reset (ctx);
 
   /* Allocate scratch variables.  */
   for (i=0; i< DIM(ctx->t.scratch); i++)
@@ -566,13 +589,13 @@ _gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue,
     {
       mpi_free (ec->p);
       ec->p = mpi_copy (newvalue);
-      ec->t.need_sync = 1;
+      ec_get_reset (ec);
     }
   else if (!strcmp (name, "a"))
     {
       mpi_free (ec->a);
       ec->a = mpi_copy (newvalue);
-      ec->t.need_sync = 1;
+      ec_get_reset (ec);
     }
   else if (!strcmp (name, "b"))
     {
@@ -669,8 +692,6 @@ _gcry_mpi_ec_dup_point (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx)
 #define l2 (ctx->t.scratch[4])
 #define l3 (ctx->t.scratch[5])
 
-  ec_p_sync (ctx);
-
   if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0))
     {
       /* P_y == 0 || P_z == 0 => [1:1:0] */
@@ -680,7 +701,7 @@ _gcry_mpi_ec_dup_point (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx)
     }
   else
     {
-      if (ctx->t.a_is_pminus3)  /* Use the faster case.  */
+      if (ec_get_a_is_pminus3 (ctx))  /* Use the faster case.  */
         {
           /* L1 = 3(X - Z^2)(X + Z^2) */
           /*                          T1: used for Z^2. */
@@ -768,8 +789,6 @@ _gcry_mpi_ec_add_points (mpi_point_t result,
 #define t1 (ctx->t.scratch[9])
 #define t2 (ctx->t.scratch[10])
 
-  ec_p_sync (ctx);
-
   if ( (!mpi_cmp (x1, x2)) && (!mpi_cmp (y1, y2)) && (!mpi_cmp (z1, z2)) )
     {
       /* Same point; need to call the duplicate function.  */
@@ -858,7 +877,7 @@ _gcry_mpi_ec_add_points (mpi_point_t result,
           ec_powm (t1, l3, mpi_const (MPI_C_THREE), ctx); /* fixme: Use saved value*/
           ec_mulm (t1, t1, l8, ctx);
           ec_subm (y3, l9, t1, ctx);
-          ec_mulm (y3, y3, ctx->t.two_inv_p, ctx);
+          ec_mulm (y3, y3, ec_get_two_inv_p (ctx), ctx);
         }
     }
 
@@ -899,8 +918,6 @@ _gcry_mpi_ec_mul_point (mpi_point_t result,
   unsigned int nbits;
   int i;
 
-  ec_p_sync (ctx);
-
   nbits = mpi_get_nbits (scalar);
   mpi_set_ui (result->x, 1);
   mpi_set_ui (result->y, 1);
@@ -918,8 +935,6 @@ _gcry_mpi_ec_mul_point (mpi_point_t result,
   unsigned int i, loops;
   mpi_point_struct p1, p2, p1inv;
 
-  ec_p_sync (ctx);
-
   x1 = mpi_alloc_like (ctx->p);
   y1 = mpi_alloc_like (ctx->p);
   h  = mpi_alloc_like (ctx->p);
diff --git a/src/ec-context.h b/src/ec-context.h
index 6827e18..7002d47 100644
--- a/src/ec-context.h
+++ b/src/ec-context.h
@@ -38,7 +38,10 @@ struct mpi_ec_ctx_s
 
   /* This structure is private to mpi/ec.c! */
   struct {
-    int need_sync;     /* Helper for ec_p_sync.  */
+    struct {
+      unsigned int a_is_pminus3:1;
+      unsigned int two_inv_p:1;
+    } valid; /* Flags to help setting the helper vars below.  */
 
     int a_is_pminus3;  /* True if A = P - 3. */
 

commit b402e550041782b770a6ae267c7c28ca8324a12e
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Nov 5 19:21:51 2012 +0100

    Allow building with w64-mingw32
    
    * autogen.sh <--build-w32>: Support the w64-mingw32 toolchain.  Also
    prepare for 64 bit building.
    --
    
    NB: Despite of this change in autogen.sh, there is no support for 64
    bit Windows yet.  The change has only be done to eventually allow to
    work on a W64 version.

diff --git a/autogen.sh b/autogen.sh
index a0bbd6b..841c2c2 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -102,12 +102,12 @@ if [ "$myhost" = "w32" ]; then
         64)
           w32root="$w64root"
           [ -z "$w32root" ] && w32root="$HOME/w64root"
-          toolprefixes="amd64-mingw32msvc"
+          toolprefixes="$amd64_toolprefixes amd64-mingw32msvc"
           ;;
         *)
           [ -z "$w32root" ] && w32root="$HOME/w32root"
-          toolprefixes="i586-mingw32msvc i386-mingw32msvc"
-          toolprefixes="i586-mingw32msvc i386-mingw32msvc i686-w64-mingw32"
+          toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc"
+          toolprefixes="$toolprefixes i386-mingw32msvc mingw32"
           ;;
     esac
     echo "Using $w32root as standard install directory" >&2

commit 1eaad0a8c4cab227685a6a8768e539df2f1f4dac
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Mar 18 15:31:34 2013 +0100

    Provide GCRYPT_VERSION_NUMBER macro, add build info to the binary.
    
    * src/gcrypt.h.in (GCRYPT_VERSION_NUMBER): New.
    * configure.ac (VERSION_NUMBER): New ac_subst.
    * src/global.c (_gcry_vcontrol): Move call to above function ...
    (gcry_check_version): .. here.
    
    * configure.ac (BUILD_REVISION, BUILD_FILEVERSION)
    (BUILD_TIMESTAMP): Define on all platforms.
    * compat/compat.c (_gcry_compat_identification): Include revision and
    timestamp.

diff --git a/NEWS b/NEWS
index 429f666..0d75680 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,7 @@ Noteworthy changes in version 1.6.0 (unreleased)
  gcry_mpi_ec_mul                 NEW.
  GCRYMPI_FLAG_IMMUTABLE          NEW.
  GCRYMPI_FLAG_CONST              NEW.
+ GCRYPT_VERSION_NUMBER           NEW.
 
 
 Noteworthy changes in version 1.5.0 (2011-06-29)
diff --git a/compat/compat.c b/compat/compat.c
index 96889d3..d259130 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -30,6 +30,9 @@ _gcry_compat_identification (void)
     "This is Libgcrypt " PACKAGE_VERSION " - The GNU Crypto Library\n"
     "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n"
     "          2010, 2011, 2012 Free Software Foundation, Inc.\n"
+    "Copyright 2012, 2013 g10 Code GmbH\n"
+    "\n"
+    "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n"
     "\n\n";
   return blurb;
 }
diff --git a/configure.ac b/configure.ac
index 7afd83d..7504d76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,12 +28,16 @@ min_automake_version="1.10"
 # bump the version number immediately after the release and do another
 # commit and push so that the git magic is able to work.  See below
 # for the LT versions.
-m4_define(mym4_version, [1.6.0])
+m4_define(mym4_version_major, [1])
+m4_define(mym4_version_minor, [6])
+m4_define(mym4_version_micro, [0])
 
 # Below is m4 magic to extract and compute the revision number, the
 # decimalized short revision number, a beta version string, and a flag
 # indicating a development version (mym4_isgit). Note that the m4
 # processing is done by autoconf and not during the configure run.
+m4_define(mym4_version,
+          [mym4_version_major.mym4_version_minor.mym4_version_micro])
 m4_define([mym4_revision],
           m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
 m4_define([mym4_revision_dec],
@@ -125,6 +129,9 @@ AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
+VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_version_major \
+                          mym4_version_minor mym4_version_micro)
+AC_SUBST(VERSION_NUMBER)
 
 
 ######################
@@ -1341,21 +1348,24 @@ esac
 AC_SUBST([GCRYPT_HWF_MODULES])
 
 
-# Generate extended version information for W32.
-if test "$have_w32_system" = yes; then
-   BUILD_TIMESTAMP=`date --iso-8601=minutes`
-   changequote(,)dnl
-   BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
-   changequote([,])dnl
-   BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
-fi
+#
+# Provide information about the build.
+#
 BUILD_REVISION="mym4_revision"
 AC_SUBST(BUILD_REVISION)
-AC_SUBST(BUILD_TIMESTAMP)
-AC_SUBST(BUILD_FILEVERSION)
 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
                    [GIT commit id revision used to build this package])
 
+changequote(,)dnl
+BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
+changequote([,])dnl
+BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
+AC_SUBST(BUILD_FILEVERSION)
+
+BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
+AC_SUBST(BUILD_TIMESTAMP)
+AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
+                   [The time this package was configured for a build])
 
 
 # And create the files.
diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index ad4da04..8343799 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -66,6 +66,11 @@ extern "C" {
    matches the installed library.  */
 #define GCRYPT_VERSION "@VERSION@"
 
+/* The version number of this header.  It may be used to handle minor
+   API incompatibilities.  */
+#define GCRYPT_VERSION_NUMBER @VERSION_NUMBER@
+
+
 /* Internal: We can't use the convenience macros for the multi
    precision integer functions when building this library. */
 #ifdef _GCRYPT_IN_LIBGCRYPT
diff --git a/src/global.c b/src/global.c
index 0c6fbbd..f873897 100644
--- a/src/global.c
+++ b/src/global.c
@@ -247,6 +247,9 @@ gcry_check_version( const char *req_version )
     int rq_major, rq_minor, rq_micro;
     const char *my_plvl;
 
+    if (req_version && req_version[0] == 1 && req_version[1] == 1)
+        return _gcry_compat_identification ();
+
     /* Initialize library.  */
     global_init ();
 
@@ -686,8 +689,6 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
 
     default:
       _gcry_set_preferred_rng_type (0);
-      /* A call to make sure that the dummy code is linked in.  */
-      _gcry_compat_identification ();
       err = GPG_ERR_INV_OP;
     }
 

commit de07974d807b703a2554d6ba885ea249e648bd44
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Mar 20 15:18:08 2013 +0100

    Fix a memory leak in the new EC code.
    
    * cipher/ecc.c (point_from_keyparam): Always call mpi_free on A.

diff --git a/cipher/ecc.c b/cipher/ecc.c
index c23ba08..8fcd57d 100644
--- a/cipher/ecc.c
+++ b/cipher/ecc.c
@@ -1763,10 +1763,10 @@ point_from_keyparam (gcry_mpi_point_t *r_a,
     {
       point = gcry_mpi_point_new (0);
       ec = os2ec (point, a);
+      mpi_free (a);
       if (ec)
         {
           gcry_mpi_point_release (point);
-          mpi_free (a);
           return ec;
         }
     }

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

Summary of changes:
 NEWS             |    1 +
 autogen.sh       |    6 ++--
 cipher/ecc.c     |    2 +-
 compat/compat.c  |    3 ++
 configure.ac     |   32 ++++++++++++++++++---------
 mpi/ec.c         |   63 +++++++++++++++++++++++++++++++++--------------------
 src/ec-context.h |    5 +++-
 src/gcrypt.h.in  |    5 ++++
 src/global.c     |    5 ++-
 9 files changed, 80 insertions(+), 42 deletions(-)


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




More information about the Gnupg-commits mailing list