diff options
Diffstat (limited to 'scd/command.c')
-rw-r--r-- | scd/command.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/scd/command.c b/scd/command.c index ec6989a4d..e3a27ae28 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1083,10 +1083,10 @@ cmd_writekey (assuan_context_t ctx, char *line) static const char hlp_genkey[] = - "GENKEY [--force] [--timestamp=<isodate>] <no>\n" + "GENKEY [--force] [--timestamp=<isodate>] [--algo=ALGO] <keyref>\n" "\n" - "Generate a key on-card identified by NO, which is application\n" - "specific. Return values are application specific. For OpenPGP\n" + "Generate a key on-card identified by <keyref>, which is application\n" + "specific. Return values are also application specific. For OpenPGP\n" "cards 3 status lines are returned:\n" "\n" " S KEY-FPR <hexstring>\n" @@ -1105,16 +1105,21 @@ static const char hlp_genkey[] = "value. The value needs to be in ISO Format; e.g.\n" "\"--timestamp=20030316T120000\" and after 1970-01-01 00:00:00.\n" "\n" + "The option --algo can be used to request creation using a specific\n" + "algorithm. The possible algorithms are card dependent.\n" + "\n" "The public part of the key can also later be retrieved using the\n" "READKEY command."; static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); - int rc; - char *save_line; + gpg_error_t err; + char *keyref_buffer = NULL; + char *keyref; int force; const char *s; + char *opt_algo = NULL; time_t timestamp; force = has_option (line, "--force"); @@ -1130,39 +1135,41 @@ cmd_genkey (assuan_context_t ctx, char *line) else timestamp = 0; + err = get_option_value (line, "--algo", &opt_algo); + if (err) + goto leave; line = skip_options (line); if (!*line) - { - rc = set_error (GPG_ERR_ASS_PARAMETER, "no key number given"); - goto leave; - } - save_line = line; + return set_error (GPG_ERR_ASS_PARAMETER, "no key number given"); + keyref = line; while (*line && !spacep (line)) line++; *line = 0; - if ((rc = open_card (ctrl))) + if ((err = open_card (ctrl))) goto leave; if (!ctrl->app_ctx) { - rc = gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); + err = gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); goto leave; } - { - char *tmp = xtrystrdup (save_line); - if (!tmp) - return gpg_error_from_syserror (); - rc = app_genkey (ctrl->app_ctx, ctrl, tmp, NULL, - force? APP_GENKEY_FLAG_FORCE : 0, - timestamp, pin_cb, ctx); - xfree (tmp); - } + keyref = keyref_buffer = xtrystrdup (keyref); + if (!keyref) + { + err = gpg_error_from_syserror (); + goto leave; + } + err = app_genkey (ctrl->app_ctx, ctrl, keyref, opt_algo, + force? APP_GENKEY_FLAG_FORCE : 0, + timestamp, pin_cb, ctx); leave: - return rc; + xfree (keyref_buffer); + xfree (opt_algo); + return err; } |