Description:
------------
The reproduce code will show this better but essentially when I encrypt some data to 2 keys (2 calls to addenencryptkey) only the first key will be able to decrypt the data using the gnupg extension.
Reproduce code:
---------------
PHP style shell script available at:-
http://home.kennynet.co.uk/~kenny/gnupg.php.txt
Expected result:
----------------
The expected result would be successful decryption using the gnupg extension...
$ ./gnupg.php
KEY 1: (php-gpg)...string(4) "TEST"
KEY 2: (php-gpg)...string(4) "TEST"
KEY 2: (using gpg-shell)...string(4) "TEST"
Actual result:
--------------
The actual result shows that the 2nd key fails to decrypt the data using the gnupg extension (yet it works fine using the gpg binary):-
$ ./gnupg.php
KEY 1: (php-gpg)...string(4) "TEST"
KEY 2: (php-gpg)...bool(false)
KEY 2: (using gpg-shell)...string(4) "TEST"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

[2008-07-15 03:42 UTC] kmdm2 at kennynet dot co dot uk

I've now done the sensible thing of setting the errormode to warning, the actual output of the script is now thus:-
$ ./gpgbug.php
KEY 1: (php-gpg)...string(4) "TEST"
Warning: gnupg::decrypt(): no passphrase set in /tmp/gpgbug.php on line 38
Warning: gnupg::decrypt(): decrypt failed in /tmp/gpgbug.php on line 38
KEY 2: (php-gpg)...bool(false)
KEY 2: (using gpg-shell)...string(4) "TEST"
This now looks similar to a previous bug awaiting feedback:-
http://pecl.php.net/bugs/bug.php?id=9103
HTH

[2008-07-15 04:48 UTC] kmdm2 at kennynet dot co dot uk

Ok, last comment from me since I'm reaching the end of my limited C ability. ;-)
It looks like the uid_hint coming into the passphrase_decrypt_cb function is that of the first key used to encrypt the data, thus when the uid is used to search for a passphrase it's not looking for the uid of the 2nd key, only the first...

[2008-08-08 11:44 UTC] kmdm2 at kennynet dot co dot uk

I reproduced a simple testcase for this in C and ran it by the GPGME maintainer.
The problem is caused because if we don't find the uid_int in the passphrase_decrypt_cb function we return 1. This tells GPGME to abort attempting to decrypt the data so it will never ask for the passphrase for other uid's that the data has been encrypted to.
Correct behavior is to write \n to the fd and return 0 to continue processing.
The following patch fixes this:-
http://home.kennynet.co.uk/~kenny/gnupg_fix_14345.patch

[2013-02-06 07:55 UTC] peterp at pocos dot nl

This bug hasn't been fixed in 1.3.2. Could you please post your patch?