diff options
author | Werner Koch <wk@gnupg.org> | 2013-10-08 17:59:50 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-10-08 17:59:50 +0200 |
commit | 3816e46ce211e63adf46dbc775510aa137572248 (patch) | |
tree | 7a4e51d84d2e0f83803f5865b58c8135f4a1ca5e /cipher/elgamal.c | |
parent | f79d3e13d3229115c47cbe5007647cb44105fe3f (diff) | |
download | libgcrypt-3816e46ce211e63adf46dbc775510aa137572248.tar.gz |
pubkey: Move sexp parsing for gcry_pk_getkey to the modules.
* cipher/pubkey-util.c: New.
(_gcry_pk_util_get_nbits): New. Based on code from gcry_pk_genkey.
(_gcry_pk_util_get_rsa_use_e): Ditto.
* cipher/pubkey.c (gcry_pk_genkey): Strip most code and pass.
* cipher/rsa.c (rsa_generate): Remove args ALGO, NBITS and EVALUE.
Call new fucntions to get these values.
* cipher/dsa.c (dsa_generate): Remove args ALGO, NBITS and EVALUE.
Call _gcry_pk_util_get_nbits to get nbits. Always parse genparms.
* cipher/elgamal.c (elg_generate): Ditto.
* cipher/ecc.c (ecc_generate): Ditto.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/elgamal.c')
-rw-r--r-- | cipher/elgamal.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/cipher/elgamal.c b/cipher/elgamal.c index f51f9079..3c8741a0 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -616,32 +616,30 @@ verify(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey ) *********************************************/ static gpg_err_code_t -elg_generate (int algo, unsigned int nbits, unsigned long evalue, - const gcry_sexp_t genparms, gcry_sexp_t *r_skey) +elg_generate (const gcry_sexp_t genparms, gcry_sexp_t *r_skey) { gpg_err_code_t rc; + unsigned int nbits; ELG_secret_key sk; gcry_mpi_t xvalue = NULL; gcry_sexp_t l1; gcry_mpi_t *factors = NULL; gcry_sexp_t misc_info = NULL; - (void)algo; - (void)evalue; - memset (&sk, 0, sizeof sk); - if (genparms) + rc = _gcry_pk_util_get_nbits (genparms, &nbits); + if (rc) + return rc; + + /* Parse the optional xvalue element. */ + l1 = gcry_sexp_find_token (genparms, "xvalue", 0); + if (l1) { - /* Parse the optional xvalue element. */ - l1 = gcry_sexp_find_token (genparms, "xvalue", 0); - if (l1) - { - xvalue = gcry_sexp_nth_mpi (l1, 1, 0); - gcry_sexp_release (l1); - if (!xvalue) - return GPG_ERR_BAD_MPI; - } + xvalue = gcry_sexp_nth_mpi (l1, 1, 0); + gcry_sexp_release (l1); + if (!xvalue) + return GPG_ERR_BAD_MPI; } if (xvalue) |