GPGME: Invalid value when trying to encrypt with certain keys

Jan Girlich vollkorn at cryptobitch.de
Tue Aug 29 17:50:34 CEST 2017


Hi,

I encountered something I believe to be a bug in libgpgme 1.8.0, but I'm
not sure, so I thought to write here to discuss my problem before
submitting a bug report.

One specific key (available on the key servers as 0xDC3E9C95) causes an
"Invalid value" error, but this key is in use since 1996 and works fine
when used directly with gpg or enigmail.

Something notable: This key does not have any email addresses associated
with it.

I used the Python bindings as in the following bit of minimal sample code:

#!/usr/bin/env python

import gpg

with gpg.Context(armor=True) as c:
    c.set_keylist_mode(gpg.constants.keylist.mode.EXTERN)
    recipient_key = c.get_key('0xDC3E9C95')
    c.op_import_keys([recipient_key])
    encrypted_body, _, _ = c.encrypt(
        'T€st'.encode(),
        recipients=[recipient_key],
        always_trust=True)
    print(encrypted_body.decode('utf-8'))


encrypt() throws an Exception which IMHO only shows that the error
originates from behind the function wrapper of the Python bindings:

Traceback (most recent call last):
  File "/usr/share/pycharm/helpers/pydev/pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/usr/share/pycharm/helpers/pydev/pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File
"/usr/share/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line
18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/jan/Projekte/AA/gpg_test.py", line 13, in <module>
    always_trust=True)
  File
"/home/jan/Projekte/AA/env/lib/python3.5/site-packages/gpg/core.py",
line 269, in encrypt
    self.op_encrypt_sign(recipients, flags, plaintext, ciphertext)
  File
"/home/jan/Projekte/AA/env/lib/python3.5/site-packages/gpg/core.py",
line 151, in wrapper
    return _funcwrap(self, *args)
  File
"/home/jan/Projekte/AA/env/lib/python3.5/site-packages/gpg/core.py",
line 135, in _funcwrap
    return errorcheck(result, "Invocation of " + name)
  File
"/home/jan/Projekte/AA/env/lib/python3.5/site-packages/gpg/errors.py",
line 62, in errorcheck
    raise GPGMEError(retval, extradata)
gpg.errors.GPGMEError: Invocation of gpgme_op_encrypt_sign: GPGME:
Invalid value

Well, does this look like a bug to you?

Cheers
vollkorn




More information about the Gnupg-devel mailing list