summaryrefslogtreecommitdiffstats
path: root/tools/gpg-card.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-02-08 20:30:39 +0100
committerWerner Koch <wk@gnupg.org>2020-02-09 14:02:59 +0100
commit9df9996b415ee671a0f22b6936745f829884eda2 (patch)
tree57adde643ea8e235dcca00e6de0256dc63cf5154 /tools/gpg-card.c
parentsm: New option --issuer-der for the listkey commands. (diff)
downloadgnupg2-9df9996b415ee671a0f22b6936745f829884eda2.tar.xz
gnupg2-9df9996b415ee671a0f22b6936745f829884eda2.zip
card: Support brainpool curves in the generate command.
* tools/gpg-card.c (cmd_generate): Add brainpool curves and dummy name "help". Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tools/gpg-card.c')
-rw-r--r--tools/gpg-card.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index fd7b57e5b..5d5829aad 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -2157,8 +2157,9 @@ static gpg_error_t
cmd_generate (card_info_t info, char *argstr)
{
static char * const valid_algos[] =
- { "rsa2048", "rsa3072", "rsa4096",
- "nistp256", "nistp384", "nistp521",
+ { "rsa2048", "rsa3072", "rsa4096", "",
+ "nistp256", "nistp384", "nistp521", "",
+ "brainpoolP256r1", "brainpoolP384r1", "brainpoolP512r1", "",
"ed25519", "cv25519",
NULL
};
@@ -2172,8 +2173,9 @@ cmd_generate (card_info_t info, char *argstr)
if (!info)
return print_help
("GENERATE [--force] [--algo=ALGO] KEYREF\n\n"
- "Create a new key on a card. For OpenPGP cards are menu is used\n"
- "and KEYREF is ignored. Use --force to overwrite an existing key.",
+ "Create a new key on a card. For OpenPGP cards a menu is used\n"
+ "and KEYREF is ignored. Use --force to overwrite an existing key.\n"
+ "Using \"help\" for ALGO gives a list of known algorithms.\n",
APP_TYPE_OPENPGP, APP_TYPE_PIV, 0);
if (opt.interactive || opt.verbose)
@@ -2210,17 +2212,30 @@ cmd_generate (card_info_t info, char *argstr)
if (opt_algo)
{
for (i=0; valid_algos[i]; i++)
- if (!strcmp (valid_algos[i], opt_algo))
+ if (*valid_algos[i] && !strcmp (valid_algos[i], opt_algo))
break;
if (!valid_algos[i])
{
- err = gpg_error (GPG_ERR_PUBKEY_ALGO);
- log_info ("Invalid algorithm '%s' given. Use one:\n", opt_algo);
+ int lf = 1;
+ if (!ascii_strcasecmp (opt_algo, "help"))
+ log_info ("Known algorithms:\n");
+ else
+ {
+ log_info ("Invalid algorithm '%s' given. Use one:\n", opt_algo);
+ err = gpg_error (GPG_ERR_PUBKEY_ALGO);
+ }
for (i=0; valid_algos[i]; i++)
- if (!(i%5))
- log_info (" %s%s", valid_algos[i], valid_algos[i+1]?",":".");
- else
- log_printf (" %s%s", valid_algos[i], valid_algos[i+1]?",":".");
+ {
+ if (!*valid_algos[i])
+ lf = 1;
+ else if (lf)
+ {
+ lf = 0;
+ log_info (" %s%s", valid_algos[i], valid_algos[i+1]?",":".");
+ }
+ else
+ log_printf (" %s%s", valid_algos[i], valid_algos[i+1]?",":".");
+ }
log_info ("Note that the card may not support all of them.\n");
goto leave;
}