Page MenuHome GnuPG

Can't unregister a non-existent private key
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. insert someone's smartcard into your computer and use that to decrypt a file
  2. remove the smartcard
  3. gpg2 --list-secret-keys lists the (absent) private key on the smartcard
  4. gpg2 --delete-secret-keys NAME refuses to unregister the private key

Impact: if you receive a file that is encrypted both for you and the smartcard owner, there is a chance that gpg2 will try to decrypt the file with the wrong private key. Because you don't have that key, you can't decrypt the file.

Workaround: list the keygrips with --list-keys --with-keygrip and delete the corresponding files in private-keys-v1.d/

Details

Version
gpg (GnuPG) 2.2.6

Event Timeline

I note that this problem could also affect a user with multiple identities, one of which has their decryption keys on a smartcard. If a message arrives encrypted to both identities, but the user does not have their smartcard available, they will hit the same issue.

Workaround is to click cancel so that the next key is tried; right?

Workaround is to click cancel so that the next key is tried; right?

I guess that depends on the pinentry you use. Cancelling within the Emacs pinentry does not ask for the next key.

werner lowered the priority of this task from High to Normal.Jun 8 2018, 8:59 AM

I tried this with the current 2.2 branch and master and was not able to replicate it. The stubs are all deleted as expected. I also checked the commit log since 2.2.6 and didn't found anything which indicated that such a bug was fixed.

Are you sure that you are using 2.2.6? I ask because you installed it under the name gpg2 which is not the default.
If you still have this problem, can you please provide a transcript of what you did? It would alsobe good to use the option "--debug ipc" so that we can see wheat gpg-agent had to say. It is fine to redact keygrips, fingerprints etc.

In the meantime, I upgraded my Fedora installation so I won't be able to reproduce in the same circumstances. I suggest we close the issue for now. I will reopen if I manage to reproduce.

werner claimed this task.

Okay. Thanks for looking into this.