Mailing List Archive

Cannot decrypt from smartcard using gnupg-2.2, can from 2.0
Working version:
Ubuntu-14.04
gpg (GnuPG) 2.0.22
libgcrypt 1.5.3

Not working version:
Ubuntu-18.04
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1

I put the same subkey on all 3 slots of a Nitrokey Pro maybe about a year
ago and have been encrypting/decrypting (sometimes signing, sometimes not)
for myself and for/from other people during that time. I've used the
smartcard on 3 different hosts (also 14.04) by using fetch and running
card-status. On gnupg-2.2, whether signed or not, attempting to decrypt a
file with me as the recipient fails with:

gpg: public key decryption failed: Invalid ID
gpg: decryption failed: No secret key

It shows that the file was encrypted with my subkey fingerprint. I can
encrypt and sign with gnupg-2.2, just not the reverse. It does not matter
if the file I am trying to decrypt was created from one of my 14.04 hosts
or with the 18.04 host. The 18.04 host simply cannot decrypt it.

To be complete about how I set up the card: I imported the subkey into a
fresh .gnupg, ran card-edit, toggle, key 1, keytocard, chose the slot,
saved, wiped .gnupg (and restarted the agent) and repeated the process for
the other 2 slots and finally wiping .gnupg and using card-edit, fetch, and
card-status to re-initialize.

Both 2.0 and 2.2 show sec#, uid, and ssb> when running -K.
show-unusable-uids,show-unusable-subkeys does not change the output. There
are no other UIDs or subkeys and both master and sub are set to never
expire.

If I import the master or the detached subkey by themselves into a clean
18.04 environment, it works. Only the smartcard does not work. Can anyone
help debug this?
Re: Cannot decrypt from smartcard using gnupg-2.2, can from 2.0 [ In reply to ]
alejandro Cortez wrote:
> gpg: public key decryption failed: Invalid ID

This means that something goes wrong in your private key file for
your token, I suppose.

> Can anyone help debug this?

You can see more information, by following command line:

$ gpg-connect-agent "KEYINFO --list" /bye

This doesn't reveal secret (but your serial number).

The example output (of mine) is like:

==========================
$ gpg-connect-agent "KEYINFO --list" /bye
S KEYINFO A97A7983102513844456E5B687E46B936B14155C D - - - P - - -
S KEYINFO 65F67E742101C7FE6D5B33FCEFCF4F65EAF0688C T D276000124010200F517000000010000 OPENPGP.2 - - - - -
S KEYINFO 101DE7B639FE29F4636BDEECF442A9273AFA6565 T D276000124010200F517000000010000 OPENPGP.1 - - - - -
S KEYINFO 5D6C89682D07CCFC034AF508420BF2276D8018ED T D276000124010200F517000000010000 OPENPGP.3 - - - - -
OK
$
==========================

The third column is a keygrip. The fifth column is an application ID
(vendor id + serial number) of the card. The sixth column is the key
identifier.

The key identifier "OpenPGP.2" is used for decription process.

I suspect you have some different string there, for some reason.
--

_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users
Re: Cannot decrypt from smartcard using gnupg-2.2, can from 2.0 [ In reply to ]
On Tue, Oct 15, 2019 at 10:52 PM NIIBE Yutaka <gniibe@fsij.org> wrote:

> Hello,
>
> I think that your configuration of smartcard is somehow broken.
>

The only thing I have been able to confirm is that gpg, at some point after
2.0.22, stopped allowing the use of the same subkey in multiple slots. As
soon as I created a new signing subkey and put that one into the signing
slot and the SEA subkey into the encryption slot, everything started
working.