Page MenuHome GnuPG

Kleopatra: Generating OpenPGP keys on Yubikey (with PIV enabled) fails with "General error"
Closed, ResolvedPublic

Description

How to reproduce:

  • Insert Yubikey (with OpenPGP app and PIV app enabled)
  • Start Kleopatra and open Smartcard Management
  • Click on Generate new Keys button (on OpenPGP tab), acknowledge the warning that may be shown, insert the requested information and click OK.

-> Error message "Failed to generate new key: General error" is shown.

Details

Version
master

Event Timeline

ikloecker added a subscriber: aheinecke.

This is a regression of the multi-card, multi-app support in Kleopatra, i.e. T5066. Generating OpenPGP keys fails because the PIV app is active on the card and the code does not switch to the OpenPGP app. (It also does not switch to the correct card if multiple cards are inserted which could result in the destruction of keys on the wrong card.)

Fixed.

Note that Kleopatra verifies the currently active card before starting the generation of new keys. This prevents the destruction of keys on the wrong card.

Re-opening. Now trying to generate new keys fails with a "Wrong card" error.

This error is caused by the different serial numbers used for the same card (see T5100). We pass the canonical serial number to GpgME::GpgGenCardKeyInteractor, but gpg --card-edit reports the app specific serial number in the CARDCTRL status line. This breaks the confirmation of the serial number in GpgME::GpgGenCardKeyInteractor (which prevents the destruction of keys on the wrong card) and makes the interactor bail out.

This is blocked by T5100.

Alternatively, we could rewrite the generation of new keys on OpenPGP cards using the same approach as for PIV cards, i.e. by talking directly to scdaemon.

ikloecker lowered the priority of this task from High to Normal.Nov 18 2020, 4:31 PM

Resetting priority to normal for re-evaluation

Re-opening. Now trying to generate new keys fails with a "Wrong card" error.

This has been fixed with the recent changes made for T5100.