mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
02d7bb819f
commit
a1515b3bbc
3 changed files with 178 additions and 86 deletions
17
g10/keygen.c
17
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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue