I am trying to use a X509 certificate with the private keys on a OpenPGP V2.0
smartcard, but I cannot decrypt messages: gpgsm aborts with the error "Invalid
session key".
If I manually decrypt the RSA-encrypted session key by talking to scdaemon
directly, I can successfully decode the AES-encrypted message block to the
cleartext I put in at the beginning.
What is going wrong here?
Here is a complete transcript:
lorenz@host:~/gpgsm_problem> gpgsm -K mail@example.com
/home/lorenz/.gnupg/pubring.kbx
ID: 0xA2D76777 S/N: 52DF665BB71FAF4F Issuer: /CN=mail@example.com Subject: /CN=mail@example.com aka: mail@example.com validity: 2016-01-27 15:35:46 through 2063-04-05 17:00:00 key type: 4096 bit RSA key usage: digitalSignature nonRepudiation keyEncipherment dataEncipherment
chain length: unlimited
fingerprint: A2:A0:4A:AA:7A:16:32:B5:82:FD:20:54:F7:5F:DE:AB:A2:D7:67:77 card s/n: D27600012401020000050000280D0000
lorenz@host:~/gpgsm_problem> cat cleartext
0123456789abcdef0123
lorenz@host:~/gpgsm_problem> gpgsm --no-encrypt-to -e -r mail@example.com >
gpgsm_encrypted < cleartext
gpgsm: CRLs not checked due to --disable-crl-checks option
gpgsm: encrypted data created
lorenz@host:~/gpgsm_problem> gpgsm -d gpgsm_encrypted
gpgsm: Note: non-critical certificate policy not allowed
gpgsm: Note: non-critical certificate policy not allowed
gpgsm: Note: non-critical certificate policy not allowed
gpgsm: CRLs not checked due to --disable-crl-checks option
gpgsm: DBG: recp 0 - issuer: 'CN=mail@example.com'
gpgsm: DBG: recp 0 - serial: 52DF665BB71FAF4F
gpgsm: decrypting session key failed: Invalid session key
gpgsm: message decryption failed: No secret key <GpgSM>
lorenz@host:~/gpgsm_problem>
I cobbled together a small script to manually decrypt the message using
openssl asn1parse, gpg-agent-connect and pycrypto, which works:
lorenz@host:~/gpgsm_problem> ./decode
Files cleartext and - are identical
I attach a tar-ball with all the files used as well as the scripts for the
manual decryption. Also, the decrypted session key for my message. Is there
anything more I could do to help?
Regards,
Lorenz