diff options
| author | NIIBE Yutaka <[email protected]> | 2018-03-29 02:56:02 +0000 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2018-03-29 02:56:02 +0000 |
| commit | a1515b3bbc10a210040dda3b482bcdb933fa8d7c (patch) | |
| tree | b985f1f5090ea4f1edaf0d5366be97a61c665fd9 /g10/keygen.c | |
| parent | g10: check_pin_for_key_operation should be just before genkey. (diff) | |
| download | gnupg-a1515b3bbc10a210040dda3b482bcdb933fa8d7c.tar.gz gnupg-a1515b3bbc10a210040dda3b482bcdb933fa8d7c.zip | |
g10: Support key attribute change at --card-edit/generate.
* g10/card-util.c (ask_card_rsa_keysize): Drop support for magic
number 25519 for ed25519/cv25519. Rename from ask_card_keyattr.
(ask_card_keyattr): Support ECC, as well as RSA.
(do_change_keyattr): Support ECC dropping magical number 25519.
* g10/keygen.c (ask_curve): Allow call from outside, adding last arg
of CURRENT.
(generate_keypair): Follow the change of ask_curve.
(generate_subkeypair): Likewise.
--
GnuPG-bug-id: 3781
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/keygen.c')
| -rw-r--r-- | g10/keygen.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index 109879854..a4949f486 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2235,8 +2235,8 @@ ask_keysize (int algo, unsigned int primary_keysize) /* Ask for the curve. ALGO is the selected algorithm which this function may adjust. Returns a const string of the name of the curve. */ -static const char * -ask_curve (int *algo, int *subkey_algo) +const char * +ask_curve (int *algo, int *subkey_algo, const char *current) { /* NB: We always use a complete algo list so that we have stable numbers in the menu regardless on how Gpg was configured. */ @@ -2327,7 +2327,12 @@ ask_curve (int *algo, int *subkey_algo) answer = cpr_get ("keygen.curve", _("Your selection? ")); cpr_kill_prompt (); idx = *answer? atoi (answer) : 1; - if (*answer && !idx) + if (!*answer && current) + { + xfree(answer); + return NULL; + } + else if (*answer && !idx) { /* See whether the user entered the name of the curve. */ for (idx=0; idx < DIM(curves); idx++) @@ -4263,7 +4268,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname, || algo == PUBKEY_ALGO_EDDSA || algo == PUBKEY_ALGO_ECDH) { - curve = ask_curve (&algo, &subkey_algo); + curve = ask_curve (&algo, &subkey_algo, NULL); r = xmalloc_clear( sizeof *r + 20 ); r->key = pKEYTYPE; sprintf( r->u.value, "%d", algo); @@ -4333,7 +4338,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname, || algo == PUBKEY_ALGO_EDDSA || algo == PUBKEY_ALGO_ECDH) { - curve = ask_curve (&algo, NULL); + curve = ask_curve (&algo, NULL, NULL); r = xmalloc_clear (sizeof *r + strlen (curve)); r->key = pKEYCURVE; strcpy (r->u.value, curve); @@ -5075,7 +5080,7 @@ generate_subkeypair (ctrl_t ctrl, kbnode_t keyblock, const char *algostr, else if (algo == PUBKEY_ALGO_ECDSA || algo == PUBKEY_ALGO_EDDSA || algo == PUBKEY_ALGO_ECDH) - curve = ask_curve (&algo, NULL); + curve = ask_curve (&algo, NULL, NULL); else nbits = ask_keysize (algo, 0); |
