[svn] gcry - r1237 - in trunk: cipher tests
svn author marcus
cvs at cvs.gnupg.org
Mon Apr 30 01:50:25 CEST 2007
Author: marcus
Date: 2007-04-30 01:49:56 +0200 (Mon, 30 Apr 2007)
New Revision: 1237
Modified:
trunk/cipher/ChangeLog
trunk/cipher/ecc.c
trunk/cipher/pubkey.c
trunk/tests/ChangeLog
trunk/tests/benchmark.c
Log:
cipher/
2007-04-30 Marcus Brinkmann <marcus at g10code.de>
* ecc.c (ec2os): Fix relocation of short numbers.
* ecc.c (generate_key): Do not allocate D, which will be allocated
by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
requested.
(_gcry_ecc_generate): Release unneeded members of SK.
* pubkey.c (sexp_to_key): Release NAME.
tests/
2007-04-30 Marcus Brinkmann <marcus at g10code.de>
* benchmark.c (ecc_bench): Release KEY_SPEC.
Modified: trunk/cipher/ChangeLog
===================================================================
--- trunk/cipher/ChangeLog 2007-04-29 01:32:10 UTC (rev 1236)
+++ trunk/cipher/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
@@ -1,3 +1,13 @@
+2007-04-30 Marcus Brinkmann <marcus at g10code.de>
+
+ * ecc.c (ec2os): Fix relocation of short numbers.
+
+ * ecc.c (generate_key): Do not allocate D, which will be allocated
+ by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
+ requested.
+ (_gcry_ecc_generate): Release unneeded members of SK.
+ * pubkey.c (sexp_to_key): Release NAME.
+
2007-04-28 Marcus Brinkmann <marcus at g10code.de>
* ac.c (gcry_ac_mpi): Remove member NAME_PROVIDED.
Modified: trunk/cipher/ecc.c
===================================================================
--- trunk/cipher/ecc.c 2007-04-29 01:32:10 UTC (rev 1236)
+++ trunk/cipher/ecc.c 2007-04-29 23:49:56 UTC (rev 1237)
@@ -503,7 +503,7 @@
gpg_err_code_t err;
elliptic_curve_t E;
gcry_mpi_t d;
- mpi_point_t Q, G;
+ mpi_point_t Q;
mpi_ec_t ctx;
err = generate_curve (nbits, name, &E, &nbits);
@@ -521,12 +521,9 @@
log_mpidump ("ecc generation Gz", E.G.z);
}
- d = mpi_snew (nbits);
if (DBG_CIPHER)
log_debug ("choosing a random x of size %u\n", nbits);
d = gen_k (E.n, GCRY_VERY_STRONG_RANDOM);
- point_init (&G);
- point_set (&G, &E.G);
/* Compute Q. */
point_init (&Q);
@@ -545,12 +542,12 @@
sk->d = mpi_copy (d);
/* We also return copies of G and Q in affine coordinates if
requested. */
- if (g_x && q_x)
+ if (g_x && g_y)
{
if (_gcry_mpi_ec_get_affine (g_x, g_y, &sk->E.G, ctx))
log_fatal ("ecc generate: Failed to get affine coordinates\n");
}
- if (q_x && q_x)
+ if (q_x && q_y)
{
if (_gcry_mpi_ec_get_affine (q_x, q_y, &sk->Q, ctx))
log_fatal ("ecc generate: Failed to get affine coordinates\n");
@@ -863,7 +860,7 @@
log_fatal ("mpi_print failed: %s\n", gpg_strerror (err));
if (n < pbytes)
{
- memmove (ptr+(pbytes-n), buf+1, n);
+ memmove (ptr+(pbytes-n), ptr, n);
memset (ptr, 0, (pbytes-n));
}
ptr += pbytes;
@@ -872,7 +869,7 @@
log_fatal ("mpi_print failed: %s\n", gpg_strerror (err));
if (n < pbytes)
{
- memmove (ptr+(pbytes-n), buf+1, n);
+ memmove (ptr+(pbytes-n), ptr, n);
memset (ptr, 0, (pbytes-n));
}
@@ -978,11 +975,16 @@
skey[0] = sk.E.p;
skey[1] = sk.E.a;
skey[2] = sk.E.b;
+ /* The function ec2os releases g_x and g_y. */
skey[3] = ec2os (g_x, g_y, sk.E.p);
skey[4] = sk.E.n;
+ /* The function ec2os releases g_x and g_y. */
skey[5] = ec2os (q_x, q_y, sk.E.p);
skey[6] = sk.d;
+ point_free (&sk.E.G);
+ point_free (&sk.Q);
+
return 0;
}
Modified: trunk/cipher/pubkey.c
===================================================================
--- trunk/cipher/pubkey.c 2007-04-29 01:32:10 UTC (rev 1236)
+++ trunk/cipher/pubkey.c 2007-04-29 23:49:56 UTC (rev 1237)
@@ -940,6 +940,7 @@
encryption). For RSA this is easy, but ECC is the first
algorithm which has many flavours. */
is_ecc = ( !strcmp (name, "ecdsa") || !strcmp (name, "ecc") );
+ gcry_free (name);
if (!module)
{
Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog 2007-04-29 01:32:10 UTC (rev 1236)
+++ trunk/tests/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
@@ -1,3 +1,7 @@
+2007-04-30 Marcus Brinkmann <marcus at g10code.de>
+
+ * benchmark.c (ecc_bench): Release KEY_SPEC.
+
2007-04-28 Marcus Brinkmann <marcus at g10code.de>
* ac-data.c (check_run): Don't give redundant GCRY_AC_FLAG_DEALLOC
Modified: trunk/tests/benchmark.c
===================================================================
--- trunk/tests/benchmark.c 2007-04-29 01:32:10 UTC (rev 1236)
+++ trunk/tests/benchmark.c 2007-04-29 23:49:56 UTC (rev 1237)
@@ -679,7 +679,6 @@
"(genkey (ECDSA (nbits %d)))", p_sizes[testno]);
if (err)
die ("creating S-expression failed: %s\n", gcry_strerror (err));
-
start_timer ();
err = gcry_pk_genkey (&key_pair, key_spec);
@@ -694,6 +693,7 @@
if (! sec_key)
die ("private part missing in key\n");
gcry_sexp_release (key_pair);
+ gcry_sexp_release (key_spec);
stop_timer ();
printf (" %s", elapsed_time ());
More information about the Gnupg-commits
mailing list