If the secret key is missing, this is not reported up to the user
nor the application with OpenPGP. It works with S/MIME.
How to reproduce:
echo Hi there. >hi.txt
a) encrypt towards a key where you do not have the secret key, e.g. with
gpg2 --no-options -e -r DA4A1116 hi.txt
gpgsm --no-options -e -r
9C:F8:E2:A0:0B:1E:E4:BF:02:66:2A:69:3B:85:F7:4F:46:C6:5E:78 hi.txt
hi.txt.smime
("--no-options" is to prevent also using your local key from gpg.conf or so.)
b) Try decrypting on the command line:
LANGUAGE=C gpg2 --decrypt hi.txt.gpg
gpg: encrypted with 2048-bit ELG key, ID [..]
gpg: decryption failed: No secret key
LANGUAGE=C gpgsm --no-options --decrypt hi.txt.smime
gpgsm: error decrypting session key: No such file or directory
gpgsm: decrypting session key failed: No such file or directory
gpgsm: message decryption failed: No secret key <GpgSM>
This is okay.
c) Now try via gpgme.
Using Package: python-pyme
Architecture: powerpc
Version: 0.8.1+clean-1
dpkg -l libgpgme11* gpgsm gnupg* gpg-agent
ii gnupg 1.4.9-3 GNU privacy guard - a free PGP replacement
ii gnupg-agent 2.0.11-1kk1 GNU privacy guard - password agent
ii gnupg2 2.0.11-1kk1 GNU privacy guard - a free PGP replacement
ii gpgsm 2.0.11-1kk1 GNU privacy guard - S/MIME version
ii libgpgme11 1.1.8-0kk1 GPGME - GnuPG Made Easy
ii libgpgme11-dev 1.1.8-0kk1 GPGME - GnuPG Made Easy
And the attached script.
python decryptdetails.py hi.txt.gpg
gpgme version: 1.1.8
engines:
/usr/bin/gpg2 2.0.11
/usr/bin/gpgsm 2.0.11
/usr/bin/gpgconf 2.0.11
OpenPGP True
CMS True
Trying to decrypt file 'hi.txt.gpg' using protocol 'OpenPGP' ...
Traceback (most recent call last):
File "decryptdetails.py", line 88, in <module> main() File "decryptdetails.py", line 85, in main decryptprintdetails(filename, proto) File "decryptdetails.py", line 50, in decryptprintdetails status = c.op_decrypt(cipherfile, plaintext) File "/usr/lib/python2.5/site-packages/pyme/util.py", line 64, in _funcwrap "Invocation of " + name) File "/usr/lib/python2.5/site-packages/pyme/errors.py", line 46, in
errorcheck
raise GPGMEError(retval, extradata)
pyme.errors.GPGMEError: Invocation of gpgme_op_decrypt: GPGME: Decryption
failed (7,152)
python decryptdetails.py --CMS hi.txt.smime
gpgme version: 1.1.8
engines:
/usr/bin/gpg2 2.0.11
/usr/bin/gpgsm 2.0.11
/usr/bin/gpgconf 2.0.11
OpenPGP True
CMS True
Trying to decrypt file 'hi.txt.smime' using protocol 'CMS' ...
Traceback (most recent call last):
File "decryptdetails.py", line 88, in <module> main() File "decryptdetails.py", line 85, in main decryptprintdetails(filename, proto) File "decryptdetails.py", line 50, in decryptprintdetails status = c.op_decrypt(cipherfile, plaintext) File "/usr/lib/python2.5/site-packages/pyme/util.py", line 64, in _funcwrap "Invocation of " + name) File "/usr/lib/python2.5/site-packages/pyme/errors.py", line 46, in
errorcheck
raise GPGMEError(retval, extradata)
pyme.errors.GPGMEError: Invocation of gpgme_op_decrypt: GpgSM: No secret key
(3,17)
Expectation: the OpenPGP should also end up with "No secret key".
Note there is some analysis at
https://www.intevation.de/roundup/kolab/issue3351 (Reason for decryption
problem "no secret key" not visible)
Please check it.