diff options
author | Ingo Klöcker <dev@ingo-kloecker.de> | 2020-12-07 15:10:25 +0100 |
---|---|---|
committer | Ingo Klöcker <dev@ingo-kloecker.de> | 2020-12-07 15:15:10 +0100 |
commit | 255d33d65126df00bc036580d0b32735d7178c8b (patch) | |
tree | 9acfb6120368aa2888798e318166fd58c75fb2c9 | |
parent | 1cd615afe3010d2c3919de489d7c9a78513c8694 (diff) | |
download | gnupg-255d33d65126df00bc036580d0b32735d7178c8b.tar.gz |
gpg: Make quick-gen-key with algo "card" work for keys without keytime
* g10/keygen.c (quick_generate_keypair): Set pCARDKEY flag if algostr
is "card" or "card/...".
--
For keys stored on NetKey cards or PIV cards we do not necessarily
know the creation time. Therefore set the cardkey flag if the generation
of a key from the keys available on the currently inserted smartcard
is requested with the special algo "card" or, in case of the extended
unattended mode, with an algo like "card/sign".
GnuPG-bug-id: 5141
Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
-rw-r--r-- | g10/keygen.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index b510525e3..01eec57ac 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -4548,7 +4548,6 @@ quick_generate_keypair (ctrl_t ctrl, const char *uid, const char *algostr, struct para_data_s *r; struct output_control_s outctrl; int use_tty; - u32 keytime = 0; memset (&outctrl, 0, sizeof outctrl); @@ -4631,7 +4630,7 @@ quick_generate_keypair (ctrl_t ctrl, const char *uid, const char *algostr, unsigned int keyuse, subkeyuse; const char *curve, *subcurve; char *keygrip, *subkeygrip; - u32 subkeytime; + u32 keytime, subkeytime; err = parse_key_parameter_string (ctrl, algostr, -1, 0, &algo, &size, &keyuse, &curve, &version, @@ -4681,6 +4680,7 @@ quick_generate_keypair (ctrl_t ctrl, const char *uid, const char *algostr, unsigned int nbits; const char *curve; char *keygrip; + u32 keytime; err = parse_algo_usage_expire (ctrl, 0, algostr, usagestr, expirestr, &algo, &use, &expire, &nbits, &curve, @@ -4717,10 +4717,8 @@ quick_generate_keypair (ctrl_t ctrl, const char *uid, const char *algostr, para = r; } - - /* If KEYTIME is set we know that the key has been taken from the - * card. Store that flag in the parameters. */ - if (keytime) + if (!ascii_strcasecmp (algostr, "card") + || !ascii_strncasecmp (algostr, "card/", 5)) { r = xmalloc_clear (sizeof *r); r->key = pCARDKEY; |