diff options
author | Werner Koch <wk@gnupg.org> | 2013-09-07 10:06:46 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-09-23 22:25:05 +0200 |
commit | d5f91466695c5736f441c9bf1998436184a4bf61 (patch) | |
tree | de889addb62c305ddbd1ba5d7cf077dda88ebd35 /cipher/ecc.c | |
parent | 4552437bb3c5ff96a889fd31e4bc504b2a12fac7 (diff) | |
download | libgcrypt-d5f91466695c5736f441c9bf1998436184a4bf61.tar.gz |
pk: Add algo id GCRY_PK_ECC and deprecate ECDSA and ECDH.
* src/gcrypt.h.in (GCRY_PK_ECC): New.
* cipher/pubkey.c (map_algo): New.
(spec_from_algo, gcry_pk_get_param, _gcry_pk_selftest): Use it.
* cipher/ecc.c (selftests_ecdsa): Report using GCRY_PK_ECC.
(run_selftests): Simplify.
(ecdh_names, ecdsa_names): Merge into a new ecc_names.
(_gcry_pubkey_spec_ecdh, _gcry_pubkey_spec_ecdsa): Merge into new
_gcry_pubkey_spec_ecc.
--
The algo ids are actually a relict from Libgcrypt's former life as
GnuPG's crypto code. They don't make much sense anymore and are often
not needed.
This patch requires some changes to the GnuPG 2.1 code (which has
still not been released). For example the secret key transfer between
gpg and gpg-agent (gpg --export and gpg --import). Fortunately this
will also require to add usage flags to the secret key storage of
gpg-agent which is is something we should have done a long time ago.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/ecc.c')
-rw-r--r-- | cipher/ecc.c | 62 |
1 files changed, 14 insertions, 48 deletions
diff --git a/cipher/ecc.c b/cipher/ecc.c index 2161b649..d31b4be0 100644 --- a/cipher/ecc.c +++ b/cipher/ecc.c @@ -1965,7 +1965,7 @@ selftests_ecdsa (selftest_report_func_t report) failed: if (report) - report ("pubkey", GCRY_PK_ECDSA, what, errtxt); + report ("pubkey", GCRY_PK_ECC, what, errtxt); return GPG_ERR_SELFTEST_FAILED; } @@ -1974,72 +1974,38 @@ selftests_ecdsa (selftest_report_func_t report) static gpg_err_code_t run_selftests (int algo, int extended, selftest_report_func_t report) { - gpg_err_code_t ec; - (void)extended; - switch (algo) - { - case GCRY_PK_ECDSA: - ec = selftests_ecdsa (report); - break; - default: - ec = GPG_ERR_PUBKEY_ALGO; - break; + if (algo != GCRY_PK_ECC) + return GPG_ERR_PUBKEY_ALGO; - } - return ec; + return selftests_ecdsa (report); } -static const char *ecdsa_names[] = +static const char *ecc_names[] = { - "ecdsa", - "eddsa", "ecc", - NULL, - }; -static const char *ecdh_names[] = - { + "ecdsa", "ecdh", - "ecc", - NULL, - }; - -gcry_pk_spec_t _gcry_pubkey_spec_ecdsa = - { - GCRY_PK_ECDSA, { 0, 0 }, - GCRY_PK_USAGE_SIGN, - "ECDSA", ecdsa_names, - "pabgnq", "pabgnqd", "", "rs", "pabgnq", - ecc_generate, - ecc_check_secret_key, - NULL, + "eddsa", NULL, - ecc_sign, - ecc_verify, - ecc_get_nbits, - run_selftests, - compute_keygrip, - _gcry_ecc_get_param, - _gcry_ecc_get_curve, - _gcry_ecc_get_param_sexp }; -gcry_pk_spec_t _gcry_pubkey_spec_ecdh = +gcry_pk_spec_t _gcry_pubkey_spec_ecc = { - GCRY_PK_ECDH, { 0, 0 }, - GCRY_PK_USAGE_ENCR, - "ECDH", ecdh_names, - "pabgnq", "pabgnqd", "se", "", "pabgnq", + GCRY_PK_ECC, { 0, 0 }, + (GCRY_PK_USAGE_SIGN | GCRY_PK_USAGE_ENCR), + "ECC", ecc_names, + "pabgnq", "pabgnqd", "sw", "rs", "pabgnq", ecc_generate, ecc_check_secret_key, ecc_encrypt_raw, ecc_decrypt_raw, - NULL, - NULL, + ecc_sign, + ecc_verify, ecc_get_nbits, run_selftests, compute_keygrip, |