diff options
author | Werner Koch <wk@gnupg.org> | 2008-11-24 16:37:50 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2008-11-24 16:37:50 +0000 |
commit | 8cc2eb702eeed951907db225f25a1088db4e5c44 (patch) | |
tree | cb2d85993036d2a8c755a3729330a767f1e49c03 /cipher/dsa.c | |
parent | f73ff6ce957e65b40dd7a52e9d96744239eb4996 (diff) | |
download | libgcrypt-8cc2eb702eeed951907db225f25a1088db4e5c44.tar.gz |
Cleaned up the public key module calling conventions.
Add a way to derive RSA keys according to X9.31.
Diffstat (limited to 'cipher/dsa.c')
-rw-r--r-- | cipher/dsa.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/cipher/dsa.c b/cipher/dsa.c index fe210fa0..fb5654e8 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -459,20 +459,40 @@ verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) *********************************************/ static gcry_err_code_t -dsa_generate_ext (int algo, unsigned int nbits, unsigned int qbits, - unsigned long use_e, - const char *name, const gcry_sexp_t domain, - unsigned int keygen_flags, +dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, + const gcry_sexp_t genparms, gcry_mpi_t *skey, gcry_mpi_t **retfactors) { gpg_err_code_t ec; DSA_secret_key sk; + gcry_sexp_t l1; + unsigned int qbits = 0; - (void)algo; - (void)use_e; - (void)name; - (void)domain; - (void)keygen_flags; + (void)algo; /* No need to check it. */ + (void)evalue; /* Not required for DSA. */ + + /* Parse the optional qbits element. */ + if (genparms) + { + l1 = gcry_sexp_find_token (genparms, "qbits", 0); + if (l1) + { + char buf[50]; + const char *s; + size_t n; + + s = gcry_sexp_nth_data (l1, 1, &n); + if (!s || n >= DIM (buf) - 1 ) + { + gcry_sexp_release (l1); + return GPG_ERR_INV_OBJ; /* No value or value too large. */ + } + memcpy (buf, s, n); + buf[n] = 0; + qbits = (unsigned int)strtoul (buf, NULL, 0); + gcry_sexp_release (l1); + } + } ec = generate (&sk, nbits, qbits, retfactors); if (!ec) @@ -489,11 +509,11 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned int qbits, static gcry_err_code_t -dsa_generate (int algo, unsigned int nbits, unsigned long dummy, +dsa_generate (int algo, unsigned int nbits, unsigned long evalue, gcry_mpi_t *skey, gcry_mpi_t **retfactors) { - (void)dummy; - return dsa_generate_ext (algo, nbits, 0, 0, NULL, NULL, 0, skey, retfactors); + (void)evalue; + return dsa_generate_ext (algo, nbits, 0, NULL, skey, retfactors); } |