diff options
author | Werner Koch <[email protected]> | 2015-03-10 14:26:02 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-03-10 14:35:30 +0000 |
commit | 14af2be022ccaf826db048fc16959d0222ff1134 (patch) | |
tree | e2709ea773358d16deaeb238f55a087e12940929 /common/openpgp-oid.c | |
parent | scd: fix for 64-bit arch. (diff) | |
download | gnupg-14af2be022ccaf826db048fc16959d0222ff1134.tar.gz gnupg-14af2be022ccaf826db048fc16959d0222ff1134.zip |
gpg: Add --list-gcrypt-config and "curve" item for --list-config.
* common/openpgp-oid.c (curve_supported_p): New.
(openpgp_enum_curves): New.
* common/t-openpgp-oid.c (test_openpgp_enum_curves): New.
(main): Add option --verbose.
* g10/gpg.c (opts): Add --list-gcrypt-config.
(list_config): Add items "curve" and "curveoid". Remove unused code.
--
GnuPG-bug-id: 1917
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/openpgp-oid.c')
-rw-r--r-- | common/openpgp-oid.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c index a0e5566d8..ccb67bbaa 100644 --- a/common/openpgp-oid.c +++ b/common/openpgp-oid.c @@ -347,3 +347,41 @@ openpgp_oid_to_curve (const char *oidstr) return "?"; } + + +/* Return true if the curve with NAME is supported. */ +static int +curve_supported_p (const char *name) +{ + int result = 0; + gcry_sexp_t keyparms; + + if (!gcry_sexp_build (&keyparms, NULL, "(public-key(ecc(curve %s)))", name)) + { + result = !!gcry_pk_get_curve (keyparms, 0, NULL); + gcry_sexp_release (keyparms); + } + return result; +} + + +/* Enumerate available and supported OpenPGP curves. The caller needs + to set the integer variable at ITERP to zero and keep on calling + this fucntion until NULL is returned. */ +const char * +openpgp_enum_curves (int *iterp) +{ + int idx = *iterp; + + while (idx >= 0 && idx < DIM (oidtable) && oidtable[idx].name) + { + if (curve_supported_p (oidtable[idx].name)) + { + *iterp = idx + 1; + return oidtable[idx].alias? oidtable[idx].alias : oidtable[idx].name; + } + idx++; + } + *iterp = idx; + return NULL; +} |