[svn] gcry - r1433 - in trunk: cipher doc tests
svn author wk
cvs at cvs.gnupg.org
Thu Jun 10 11:05:43 CEST 2010
Author: wk
Date: 2010-06-10 11:05:42 +0200 (Thu, 10 Jun 2010)
New Revision: 1433
Modified:
trunk/cipher/ChangeLog
trunk/cipher/ecc.c
trunk/doc/gcrypt.texi
trunk/tests/ChangeLog
trunk/tests/t-mpi-bit.c
Log:
Allow transient-key for ecdsa.
Fix a bug in a test.
Modified: trunk/cipher/ChangeLog
===================================================================
--- trunk/cipher/ChangeLog 2010-04-27 03:04:56 UTC (rev 1432)
+++ trunk/cipher/ChangeLog 2010-06-10 09:05:42 UTC (rev 1433)
@@ -1,3 +1,9 @@
+2010-06-10 Jeff Johnson <n3npq at mac.com> (wk)
+
+ * ecc.c (ecc_generate_ext): Parse transient-key flag.
+ (generate_key): Add arg TRANSIENT_KEY and use it to set the random
+ level.
+
2010-04-12 Brad Hards <bradh at frogmouth.net> (wk)
Spelling fixes.
Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog 2010-04-27 03:04:56 UTC (rev 1432)
+++ trunk/tests/ChangeLog 2010-06-10 09:05:42 UTC (rev 1433)
@@ -1,3 +1,7 @@
+2010-06-10 Werner Koch <wk at g10code.com>
+
+ * t-mpi-bit.c (mpi2bitstr_nlz): Handle case for LENGTH==0.
+
2010-04-12 Brad Hards <bradh at frogmouth.net> (wk)
* basic.c (check_cbc_mac_cipher): Print more info.
Modified: trunk/cipher/ecc.c
===================================================================
--- trunk/cipher/ecc.c 2010-04-27 03:04:56 UTC (rev 1432)
+++ trunk/cipher/ecc.c 2010-06-10 09:05:42 UTC (rev 1433)
@@ -1,5 +1,5 @@
/* ecc.c - Elliptic Curve Cryptography
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc.
This file is part of Libgcrypt.
@@ -504,6 +504,7 @@
*/
static gpg_err_code_t
generate_key (ECC_secret_key *sk, unsigned int nbits, const char *name,
+ int transient_key,
gcry_mpi_t g_x, gcry_mpi_t g_y,
gcry_mpi_t q_x, gcry_mpi_t q_y)
{
@@ -512,6 +513,7 @@
gcry_mpi_t d;
mpi_point_t Q;
mpi_ec_t ctx;
+ gcry_random_level_t random_level;
err = generate_curve (nbits, name, &E, &nbits);
if (err)
@@ -528,9 +530,11 @@
log_mpidump ("ecc generation Gz", E.G.z);
}
+ random_level = transient_key ? GCRY_STRONG_RANDOM : GCRY_VERY_STRONG_RANDOM;
if (DBG_CIPHER)
- log_debug ("choosing a random x of size %u\n", nbits);
- d = gen_k (E.n, GCRY_VERY_STRONG_RANDOM);
+ log_debug ("choosing a random x of size %u%s\n", nbits,
+ transient_key? " (transient-key)":"");
+ d = gen_k (E.n, random_level);
/* Compute Q. */
point_init (&Q);
@@ -962,6 +966,7 @@
gcry_mpi_t g_x, g_y, q_x, q_y;
char *curve_name = NULL;
gcry_sexp_t l1;
+ int transient_key = 0;
(void)algo;
(void)evalue;
@@ -978,6 +983,14 @@
if (!curve_name)
return GPG_ERR_INV_OBJ; /* No curve name or value too large. */
}
+
+ /* Parse the optional transient-key flag. */
+ l1 = gcry_sexp_find_token (genparms, "transient-key", 0);
+ if (l1)
+ {
+ transient_key = 1;
+ gcry_sexp_release (l1);
+ }
}
/* NBITS is required if no curve name has been given. */
@@ -988,7 +1001,7 @@
g_y = mpi_new (0);
q_x = mpi_new (0);
q_y = mpi_new (0);
- ec = generate_key (&sk, nbits, curve_name, g_x, g_y, q_x, q_y);
+ ec = generate_key (&sk, nbits, curve_name, transient_key, g_x, g_y, q_x, q_y);
gcry_free (curve_name);
if (ec)
return ec;
Modified: trunk/doc/gcrypt.texi
===================================================================
--- trunk/doc/gcrypt.texi 2010-04-27 03:04:56 UTC (rev 1432)
+++ trunk/doc/gcrypt.texi 2010-06-10 09:05:42 UTC (rev 1433)
@@ -2736,10 +2736,10 @@
15680 are valid as long as they are multiples of 8.
@item transient-key
-This is only meaningful for RSA and DSA keys. This is a flag with no
-value. If given the RSA or DSA key is created using a faster and a
-somewhat less secure random number generator. This flag may be used
-for keys which are only used for a short time and do not require full
+This is only meaningful for RSA, DSA and ECDSA keys. This is a flag
+with no value. If given the key is created using a faster and a
+somewhat less secure random number generator. This flag may be used for
+keys which are only used for a short time and do not require full
cryptographic strength.
@item domain
Modified: trunk/tests/t-mpi-bit.c
===================================================================
--- trunk/tests/t-mpi-bit.c 2010-04-27 03:04:56 UTC (rev 1432)
+++ trunk/tests/t-mpi-bit.c 2010-06-10 09:05:42 UTC (rev 1433)
@@ -108,13 +108,20 @@
{
char *p, *buf;
size_t length = gcry_mpi_get_nbits (a);
-
- buf = p = xmalloc (length + 1);
- while (length-- > 1)
- *p++ = gcry_mpi_test_bit (a, length) ? '1':'0';
- *p++ = gcry_mpi_test_bit (a, 0) ? '1':'0';
+
+ if (!length)
+ {
+ buf = p = xmalloc (2);
+ *p++ = '0';
+ }
+ else
+ {
+ buf = p = xmalloc (length + 1);
+ while (length-- > 1)
+ *p++ = gcry_mpi_test_bit (a, length) ? '1':'0';
+ *p++ = gcry_mpi_test_bit (a, 0) ? '1':'0';
+ }
*p = 0;
-
return buf;
}
@@ -190,7 +197,7 @@
gcry_mpi_release (a);
}
-/* Check that the shifting actually works for an amount larger than
+/* Check that right shifting actually works for an amount larger than
the number of bits per limb. */
static void
test_rshift (int pass)
@@ -249,7 +256,7 @@
gcry_mpi_release (a);
}
-/* Check that the left shifting. */
+/* Check that left shifting works correctly. */
static void
test_lshift (int pass)
{
More information about the Gnupg-commits
mailing list