Questions using GPGME

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Questions using GPGME

Andreas Heinlein-2
Hello,

I am currently taking first steps using GPGME with the Python interface.
I am facing two questions:

1.) I'm looking for a way to get the recipients of encrypted data which
I can not/do not want to decrypt. I.e. a message for which I do not have
the private key. Enigmail tells me "This message was encrypted for ..."
in such cases, and the gpg command line does the same. Is this possible
with GPGME? Calling 'decrypt' just raises a GPGMEError in this case and
does not return a result.

2.) Is there a way to safely distinguish "User clicked cancel when asked
for the passphrase" from other errors? I think an application should
abort silently in this case, but I'm getting another GPGMEError without
any clue to the reason.

I wonder if these are just problems with the python interface or if the
functionality is missing from libgpgme. I am currently using gpgme 1.8.0
because that's what is packaged with Debian 9, but if you tell me I need
to upgrade, I will ;-)

Thanks,
Andreas


_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

signature.asc (259 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Questions using GPGME

Justus Winter
Hi :)

Andreas Heinlein <[hidden email]> writes:

> I am currently taking first steps using GPGME with the Python interface.
> I am facing two questions:
>
> 1.) I'm looking for a way to get the recipients of encrypted data which
> I can not/do not want to decrypt. I.e. a message for which I do not have
> the private key. Enigmail tells me "This message was encrypted for ..."
> in such cases, and the gpg command line does the same. Is this possible
> with GPGME? Calling 'decrypt' just raises a GPGMEError in this case and
> does not return a result.

This is indeed a shortcoming of the Python bindings.  I will address this.

> 2.) Is there a way to safely distinguish "User clicked cancel when asked
> for the passphrase" from other errors? I think an application should
> abort silently in this case, but I'm getting another GPGMEError without
> any clue to the reason.

Maybe.  GPGMEError is a very general error, this is a bit of pyme
legacy.  You can inspect the error code using .getcode().  For a quick
check, try to str() the error.


Justus

_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Questions using GPGME

Andreas Heinlein-2
Am 06.07.2017 um 14:01 schrieb Justus Winter:
2.) Is there a way to safely distinguish "User clicked cancel when asked
for the passphrase" from other errors? I think an application should
abort silently in this case, but I'm getting another GPGMEError without
any clue to the reason.
Maybe.  GPGMEError is a very general error, this is a bit of pyme
legacy.  You can inspect the error code using .getcode().  For a quick
check, try to str() the error.
Thank you for the quick answer. I gave it a try with 3 tests, one decrypt with cancel'ing the pinentry, one with missing private key and one with a truncated input file. All three gave

print str(e): Invocation of gpgme_op_decrypt_verify: GPGME: Decryption failed
print e.getcode(): 152

So this doesn't help. But good to know someone is working on this; I'd be happy to help where I can. I am not a C developer, though, but I could test if neccessary.

Bye,
Andreas

_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

signature.asc (259 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Questions using GPGME

Justus Winter
Andreas Heinlein <[hidden email]> writes:

> Am 06.07.2017 um 14:01 schrieb Justus Winter:
>>> 2.) Is there a way to safely distinguish "User clicked cancel when asked
>>> for the passphrase" from other errors? I think an application should
>>> abort silently in this case, but I'm getting another GPGMEError without
>>> any clue to the reason.
>> Maybe.  GPGMEError is a very general error, this is a bit of pyme
>> legacy.  You can inspect the error code using .getcode().  For a quick
>> check, try to str() the error.
> Thank you for the quick answer. I gave it a try with 3 tests, one
> decrypt with cancel'ing the pinentry, one with missing private key and
> one with a truncated input file. All three gave
>
> print str(e): Invocation of gpgme_op_decrypt_verify: GPGME: Decryption
> failed
> print e.getcode(): 152
>
> So this doesn't help.
Well, then it is not python-gpg's fault, but the underlying library or
components do not differentiate that.

> But good to know someone is working on this

I'm not.  If you feel that this is important, please file a bug.


Cheers,
Justus

_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Questions using GPGME

Werner Koch
In reply to this post by Andreas Heinlein-2
On Thu,  6 Jul 2017 14:48, [hidden email] said:

> decrypt with cancel'ing the pinentry, one with missing private key and
> one with a truncated input file. All three gave
>
> print str(e): Invocation of gpgme_op_decrypt_verify: GPGME: Decryption
> failed

This has been fixed yesterday in GPGME.  You will now get back a
dedicated error code for "No secret keys", "Bad passphrase", and
"Canceled".  You need to wait for the releale of 1.9.1, though.


Shalom-Salam,

   Werner

--
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

attachment0 (233 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Questions using GPGME

Andreas Heinlein-2
Am 13.07.2017 um 09:27 schrieb Werner Koch:

> On Thu,  6 Jul 2017 14:48, [hidden email] said:
>
>> decrypt with cancel'ing the pinentry, one with missing private key and
>> one with a truncated input file. All three gave
>>
>> print str(e): Invocation of gpgme_op_decrypt_verify: GPGME: Decryption
>> failed
> This has been fixed yesterday in GPGME.  You will now get back a
> dedicated error code for "No secret keys", "Bad passphrase", and
> "Canceled".  You need to wait for the releale of 1.9.1, though.
>
>
>
I know, I filed the bug report ;-)

Thanks again.

Andreas


_______________________________________________
Gnupg-users mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

signature.asc (259 bytes) Download Attachment
Loading...