Page MenuHome GnuPG

handle python interact() check like c check
Open, NormalPublic

Description

Reported by meep on gnupg-devel:

https://lists.gnupg.org/pipermail/gnupg-devel/2024-May/035544.html

  • Weitergeleitete Nachricht ----------

Betreff: Possible bug in GPGME Python
Datum: Samstag 04 Mai 2024, 15:55:40
Von: "meep via Gnupg-devel" <gnupg-devel@gnupg.org>
[..]

I would like to report what I believe to be an oversight in the Python
wrapper of GPGME.

I am reporting it here as it is a minor thing, and account creation is
disabled on the bug tracker at dev.gnupg.org. I would also prefer not
to make an account if possible.

In the interact(...) function of the Context class on line 1089 in
core.py it is checked whether a key is actually passed in to the
function:

if key is None:

raise ValueError("First argument cannot be None")

Which is fine when editing a key, but when interacting with a smart
card (setting the flag INTERACT_CARD) - for example to generate a key
on it - there is not necessarily a key to be edited.

In interact_start(...) on line 131 of edit.c the presence of the key is
only checked if card_edit isn't set:

if ((card_edit == 0 && !key) || !fnc || !out)

return gpg_error (GPG_ERR_INV_VALUE);

This functions is called by gpgme_op_interact(...) in the same file
which is called from Python in the aforementioned interact(...)
function.

Thus I believe that the intended behavior in Python would be to mirror
the C code and only check whether the key is None if INTERACT_CARD is
not set.

Please correct me if I am wrong and point me in the right direction.

Event Timeline

werner added a project: Python.