mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
bb5a1b7c73
commit
14af2be022
6 changed files with 133 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue