summaryrefslogtreecommitdiff
path: root/cipher/ecc.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-04-05 18:08:36 +0200
committerWerner Koch <wk@gnupg.org>2013-04-05 18:08:51 +0200
commitfe91a642c7c257aca095b96406fbcace88fa3df4 (patch)
tree962ace0df029de0035f8acaba0d63b33ddede654 /cipher/ecc.c
parentf23a068bcb6ec9788710698578d8be0a2a006dbc (diff)
downloadlibgcrypt-fe91a642c7c257aca095b96406fbcace88fa3df4.tar.gz
Make the Q parameter optional for ECC signing.
* cipher/ecc.c (ecc_sign): Remove the need for Q. * cipher/pubkey.c (sexp_elements_extract_ecc): Make Q optional for a private key. (sexp_to_key): Add optional arg R_IS_ECC. (gcry_pk_sign): Do not call gcry_pk_get_nbits for ECC keys. * tests/pubkey.c (die): Make sure to print a LF. (check_ecc_sample_key): New. (main): Call new test. -- Q is the actual public key which is not used for signing. Thus we can make it optional and even speed up the signing by parsing less stuff. Note: There seems to be a memory leak somewhere. Running tests/pubkey with just the new test enabled shows it. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/ecc.c')
-rw-r--r--cipher/ecc.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/cipher/ecc.c b/cipher/ecc.c
index 8fcd57db..fbd8c6a3 100644
--- a/cipher/ecc.c
+++ b/cipher/ecc.c
@@ -1309,7 +1309,7 @@ ecc_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
(void)algo;
if (!data || !skey[0] || !skey[1] || !skey[2] || !skey[3] || !skey[4]
- || !skey[5] || !skey[6] )
+ || !skey[6] )
return GPG_ERR_BAD_MPI;
sk.E.p = skey[0];
@@ -1323,14 +1323,7 @@ ecc_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
return err;
}
sk.E.n = skey[4];
- point_init (&sk.Q);
- err = os2ec (&sk.Q, skey[5]);
- if (err)
- {
- point_free (&sk.E.G);
- point_free (&sk.Q);
- return err;
- }
+ /* Note: We don't have any need for Q here. */
sk.d = skey[6];
resarr[0] = mpi_alloc (mpi_get_nlimbs (sk.E.p));
@@ -1343,7 +1336,6 @@ ecc_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey)
resarr[0] = NULL; /* Mark array as released. */
}
point_free (&sk.E.G);
- point_free (&sk.Q);
return err;
}