[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-120-ga078436

by Werner Koch cvs at cvs.gnupg.org
Wed Oct 8 14:51:37 CEST 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, master has been updated
       via  a078436be5b656e4a2acfaeb5f054b9991f617e5 (commit)
       via  5c906e2cdb14e93fb4915fdc69c7353a5fa35709 (commit)
      from  de0ccd4dce7ec185a678d78878d4538dd609ca0f (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 a078436be5b656e4a2acfaeb5f054b9991f617e5
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 8 14:42:36 2014 +0200

    doc: Fix a configure option name.
    
    --

diff --git a/AUTHORS b/AUTHORS
index 860dea2..f72a421 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -137,7 +137,7 @@ Authors with a DCO
 ==================
 
 Andrei Scherer <andsch at inbox.com>
-2014-0822:BF7CEF794F9.000003F0andsch at inbox.com:
+2014-08-22:BF7CEF794F9.000003F0andsch at inbox.com:
 
 Christian Aistleitner <christian at quelltextlich.at>
 2013-02-26:20130226110144.GA12678 at quelltextlich.at:
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index 58671df..63edf06 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -325,7 +325,7 @@ you are cross-compiling, it is useful to set the environment variable
 then first look for the helper program in the @file{bin} directory
 below that top directory.  An absolute directory name must be used for
 @code{SYSROOT}.  Finally, if the configure command line option
- at code{--libgcrypt-prefix} is used, only its value is used for the top
+ at code{--with-libgcrypt-prefix} is used, only its value is used for the top
 directory below which the helper script is expected.
 
 @end defmac

commit 5c906e2cdb14e93fb4915fdc69c7353a5fa35709
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Oct 8 14:41:21 2014 +0200

    Fix prime test for 2 and lower and add check command to mpicalc.
    
    * cipher/primegen.c (check_prime): Return true for the small primes.
    (_gcry_prime_check): Return correct values for 2 and lower numbers.
    
    * src/mpicalc.c (do_primecheck): New.
    (main): Add command 'P'.
    (main): Allow for larger input data.

diff --git a/cipher/primegen.c b/cipher/primegen.c
index 14a5ccf..ce6db8d 100644
--- a/cipher/primegen.c
+++ b/cipher/primegen.c
@@ -868,7 +868,7 @@ check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
   for (i=0; (x = small_prime_numbers[i]); i++ )
     {
       if ( mpi_divisible_ui( prime, x ) )
-        return 0;
+        return !mpi_cmp_ui (prime, x);
     }
 
   /* A quick Fermat test. */
@@ -1169,19 +1169,20 @@ _gcry_prime_generate (gcry_mpi_t *prime, unsigned int prime_bits,
 gcry_err_code_t
 _gcry_prime_check (gcry_mpi_t x, unsigned int flags)
 {
-  gcry_err_code_t rc = 0;
-  gcry_mpi_t val_2 = mpi_alloc_set_ui (2); /* Used by the Fermat test. */
-
   (void)flags;
 
+  switch (mpi_cmp_ui (x, 2))
+    {
+    case 0:  return 0;                /* 2 is a prime */
+    case -1: return GPG_ERR_NO_PRIME; /* Only numbers > 1 are primes.  */
+    }
+
   /* We use 64 rounds because the prime we are going to test is not
      guaranteed to be a random one. */
-  if (! check_prime (x, val_2, 64, NULL, NULL))
-    rc = GPG_ERR_NO_PRIME;
-
-  mpi_free (val_2);
+  if (check_prime (x, mpi_const (MPI_C_TWO), 64, NULL, NULL))
+    return 0;
 
-  return rc;
+  return GPG_ERR_NO_PRIME;
 }
 
 /* Find a generator for PRIME where the factorization of (prime-1) is
diff --git a/src/mpicalc.c b/src/mpicalc.c
index b2b4335..f1fbbef 100644
--- a/src/mpicalc.c
+++ b/src/mpicalc.c
@@ -254,6 +254,23 @@ do_nbits (void)
 }
 
 
+static void
+do_primecheck (void)
+{
+  gpg_error_t err;
+
+  if (stackidx < 1)
+    {
+      fputs ("stack underflow\n", stderr);
+      return;
+    }
+  err = gcry_prime_check (stack[stackidx - 1], 0);
+  mpi_set_ui (stack[stackidx - 1], !err);
+  if (err && gpg_err_code (err) != GPG_ERR_NO_PRIME)
+    fprintf (stderr, "checking prime failed: %s\n", gpg_strerror (err));
+}
+
+
 static int
 my_getc (void)
 {
@@ -295,6 +312,7 @@ print_help (void)
          "d   dup item      [-1] := [0]               {+1}\n"
          "r   reverse       [0] := [1], [1] := [0]    {0}\n"
          "b   # of bits     [0] := nbits([0])         {0}\n"
+         "P   prime check   [0] := is_prime([0])?1:0  {0}\n"
          "c   clear stack\n"
          "p   print top item\n"
          "f   print the stack\n"
@@ -313,7 +331,7 @@ main (int argc, char **argv)
   int print_config = 0;
   int i, c;
   int state = 0;
-  char strbuf[1000];
+  char strbuf[4096];
   int stridx = 0;
 
   if (argc)
@@ -508,6 +526,9 @@ main (int argc, char **argv)
                 case 'b':
                   do_nbits ();
                   break;
+                case 'P':
+                  do_primecheck ();
+                  break;
 		case 'c':
 		  for (i = 0; i < stackidx; i++)
                     {

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

Summary of changes:
 AUTHORS           |    2 +-
 cipher/primegen.c |   19 ++++++++++---------
 doc/gcrypt.texi   |    2 +-
 src/mpicalc.c     |   23 ++++++++++++++++++++++-
 4 files changed, 34 insertions(+), 12 deletions(-)


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


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list