Page MenuHome GnuPG

keytocard: invalid value
Closed, ResolvedPublic

Description

Start with a yubikey which already has OpenPGP keys on it. Either RSA or Brainpool.
Then try with keytocard to overwrite with the other type of key.
This results in

gpg: KEYTOCARD failed: Invalid value

Overwriting with the same key type is accepted.

Details

Version
3.1.26, 3.2.0.0

Event Timeline

werner triaged this task as Normal priority.Feb 17 2023, 7:53 AM
werner added projects: gnupg22, Bug Report.

Ooops. We do not have the automatic chnage of key type in the WRITEKEY command of scdaemon. This is only done when generating a key.

werner changed the task status from Open to Testing.Mar 14 2023, 4:18 PM
werner moved this task from WiP to QA on the gnupg22 board.
werner added a project: gnupg24.

Fixed in 2.2 need to check 2.4

werner moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Mar 14 2023, 4:18 PM
werner added a subscriber: werner.

Test with GnuPG 2.4.1-beta76 failed with "error getting current key info: invalid name":

gpg> keytocard
Den Hauptschlüssel wirklich verschieben? (j/N) y
gpg: Fehler beim Holen der aktuellen Schlüsselinfo: Ungültiger Name
ebo changed the task status from Testing to Open.Apr 12 2023, 2:37 PM
ebo moved this task from QA to Backlog on the gnupg24 board.

Unfortunately I can't replicate that with my Yubikey on 2.4.1. Tried several variant and with and without keyboxd. My Yubikey has PIV disabled but I doubt that this is the problem.

my Yubikey works, too, if I disable PIV. With enabled PIV:

4 - 2023-04-13 11:43:26 scdaemon[2604]: detected reader 'Yubico YubiKey OTP+FIDO+CCID 0'
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec -> S SERIALNO D2760001240100000006154932980000
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec -> OK
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec <- GETATTR SERIALNO
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: slot 0: have=piv want=piv keyref=[none]
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec -> S SERIALNO D2760001240100000006154932980000
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec -> OK
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec <- GETATTR KEY-FPR
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: slot 0: have=piv want=piv keyref=[none]
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: slot 0 app piv: calling getattr(KEY-FPR)
4 - 2023-04-13 11:43:26 scdaemon[2604]: DBG: chan_0x000002ec -> ERR 100663384 Ung�ltiger Name <SCD>

To replicate the problem it is best to use Windows. Should be solved with my commit. Note that the bug is specific to 2.4 dues to irts multi-card and app support. There was no problem on 2.2.

ebo changed the task status from Open to Testing.Apr 19 2023, 8:57 AM
ebo moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
ebo edited projects, added gnupg24 (gnupg-2.4.1); removed gnupg24.

works with Gpg4win-4.1.1-beta295