Closed fabacab closed 8 years ago
Please provide some more information about the usd key like keylength, used encryption and so on. We already had the issue in the past but this was an issue with older specific GnuPG keys which was solved with the supplied key.
Please provide some more infrmation about the usd key like keyength, used encryption and so on.
I did:
I have tried several other keys without encountering this issue, including other keys of the same type (RSA) and length (2048 bits), as well as other keys that match this description with multiple subkeys and user IDs attached.
To clarify, the specific key that causes the issue is linked directly in the original issue report. To be even more specific, it is the key linked here: https://pgp.mit.edu/pks/lookup?search=0x4DB88B59&op=index
As is shown on that page and from my quote, the key length is 2,048 bits, and the encryption type is RSA.
Ah ok. I will test it with this key later. Should not read the issue right after waking up, oversaw the link, my fault.
No worries. Thank you for looking into it.
Not related to other issues.
The problem is in this line: else if ($len == 255) $len = (ord($sa[$i++]) << 24) + (ord($sa[$i++]) << 16) + (ord($sa[$i++]) << 8) + ord($sa[$i++]);
Can not reproduce it here, tested with PHP 7.0.1
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'libs/GPG.php';
$gpg = new GPG();
$public_key_ascii="-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFGxNi8BCADFNESLX1n1D/Xw3O36jNu/SkuH6oZaN8DmlWuicYOuFwwT/SGAtPkmdVtT
D+8CDhHfKw6WULMk6+uqU+KU0TsHLtiluUsjsdk+KUL1NpwhZSZhwV74qODi6lX5P0HSCx57
O+1S5cpzDe7NOSXNrnbZWWUJgFffJtrRwLDqJ/fErFHf4SmXFsfzGvNfKAcg4Wj47PSo+zEf
Omz1sJyeSEDh6DGHQuFq4blIXRE0NqyyiqcJx2SaFC0+uHiQvreLY14M1BOCGEQlXmu9XqDb
n7Q0dL2OGOgtijtmYfomyWbtyXLeD9AAwB8Z4eFail2gEAn2ZQ+ym5/dxKs7LocTVWmfABEB
AAG0Gm1heW1heSA8bWF5bWF5QHJpc2V1cC5uZXQ+iQE+BBMBAgAoBQJRsTYvAhsvBQkFpOwA
BgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAJAOTrTbiL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tLBYftGntvOu6wBpFbHVnpcbWeGl+iWmGeE1SFekfA
+q2Lt+2mof0Dc3uZnGzRcYlBrDOIcakmznn5ABEBAAGJAkQEGAECAA8FAlGxNi8CGy4FCQWk
7AABKQkQCQDk6024i1nAXSAEGQECAAYFAlGxNi8ACgkQuNJi2yipF6rDMwgAr8SE7wgd4ej8
khMnBxM5lCVZq0M+wbAeh2iamThAMzpCGIiLLDDj8cBLlqvqayGn4X4W6FUNHG9oYg8lOu5S
9fywEzBxdDK5gRZL2lWJHhXgQpw7lMsZnS1IkIqOvx1C49XT5mBWjJILOm5767vfY1Zg4swP
DRmX8G05gNcK2+VGUJPLfgh77Le2mVOCiRYvVYawhXaCvML9P/zxU2mc3zOJg1G8DfPcwb2M
MGfxNZ4hlitzQOTYu/EajiPykb+fOKZAnxoHMluAZGnkzaMJNpw1H8bSWFOgKevbtB89oEyg
x2sQlJnx7p4Eq+sWFYbNcAUp/dGkZYrobU3wrq1xxYEEB/920JHS9hva4nXiOJAY3MbRgUVc
lnGXIzwn/Xs8YqwvWwE7o7rcBvHy98yglvALM/6ocsOe9MGZJ8MQc6XQNZAuaWXBlQcfr9DE
m4kkEXwEKfj9/NKHAqglgorytvo+n+vnPrIwZUr7wpSkZYs+BbMeB/quGeoR4NEoTbGTHuT+
UhhmSthYJvJTHo9u1QiX6zyHf6cE6V6snYJgRi0rWmLzJSqz+tcW+YFuvlnnjlhX1ms5G3PY
rGxXsL2d+u5CtILQcCnaJYJTngELCscTWaO5hnQT/zpsOl34VLxf3llMOTGNjqeS65tS1GMu
ybyxMQRBD+ri7NKaeCoJ31cyrTd7
=5EGf
-----END PGP PUBLIC KEY BLOCK-----
";
// create an instance of a GPG public key object based on ASCII key
$pub_key = new GPG_Public_Key($public_key_ascii);
// using the key, encrypt your plain text using the public key
$encrypted = $gpg->encrypt($pub_key,"teststring");
Not sure if there has also to be some check for NULL
but the notice should be no problem.
Can you compare the keys using gpg --list-packets [file]
or pgpdump [file]
?
I am approaching the limit of my knowledge with PGP, and did not know about the --list-packets
option, thanks for showing me that.
You are right, the public key block you posted works without issue. However, it turns out that my local copy of the public key is not the same as the one uploaded to the keyserver that I linked you to. I'm sorry about that. I did not realize there were some differences.
Here is what I did:
gpg2 --armor --export [my_email_address] > /tmp/offendingkey.asc gpg2 --list-packets < /tmp/workingkey.asc > /tmp/workingkey.packets # "workingkey.asc" is a copy-and-paste of this key you posted gpg2 --list-packets < /tmp/offendingpubkey.asc > /tmp/offendingkey.packets diff /tmp/workingkey.packets /tmp/offendingkey.packets
And indeed there were differences. Here's the code I used to reproduce the issue, with the offending PGP public key block:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'libs/GPG.php';
$gpg = new GPG();
$public_key_ascii = "-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFGxNi8BCADFNESLX1n1D/Xw3O36jNu/SkuH6oZaN8DmlWuicYOuFwwT/SGA
tPkmdVtTD+8CDhHfKw6WULMk6+uqU+KU0TsHLtiluUsjsdk+KUL1NpwhZSZhwV74
qODi6lX5P0HSCx57O+1S5cpzDe7NOSXNrnbZWWUJgFffJtrRwLDqJ/fErFHf4SmX
FsfzGvNfKAcg4Wj47PSo+zEfOmz1sJyeSEDh6DGHQuFq4blIXRE0NqyyiqcJx2Sa
FC0+uHiQvreLY14M1BOCGEQlXmu9XqDbn7Q0dL2OGOgtijtmYfomyWbtyXLeD9AA
wB8Z4eFail2gEAn2ZQ+ym5/dxKs7LocTVWmfABEBAAG0TG1heW1heSAoUGxlYXNl
IHVzZSBSaXNlVXAgYWRkcmVzcyBpZiBwb3NzaWJsZS4pIDxiaXRldGhlYXBwbGVi
YWNrQGdtYWlsLmNvbT6JAT4EEwECACgFAlIOTKECGy8FCQWk7AAGCwkIBwMCBhUI
AgkKCwQWAgMBAh4BAheAAAoJEAkA5OtNuItZheAH/j9hLPwMVJxVRLlgvnuAxYr9
iNG00dLQueab5rcG1e6NbdMFBkua50tcWTQdxqthNU21c3muD/zw53LBfM7glvU8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iOJAY3MbRgUVc
lnGXIzwn/Xs8YqwvWwE7o7rcBvHy98yglvALM/6ocsOe9MGZJ8MQc6XQNZAuaWXB
lQcfr9DEm4kkEXwEKfj9/NKHAqglgorytvo+n+vnPrIwZUr7wpSkZYs+BbMeB/qu
GeoR4NEoTbGTHuT+UhhmSthYJvJTHo9u1QiX6zyHf6cE6V6snYJgRi0rWmLzJSqz
+tcW+YFuvlnnjlhX1ms5G3PYrGxXsL2d+u5CtILQcCnaJYJTngELCscTWaO5hnQT
/zpsOl34VLxf3llMOTGNjqeS65tS1GMuybyxMQRBD+ri7NKaeCoJ31cyrTd7
=9P88
-----END PGP PUBLIC KEY BLOCK-----
";
// create an instance of a GPG public key object based on ASCII key
$pub_key = new GPG_Public_Key($public_key_ascii);
// using the key, encrypt your plain text using the public key
$encrypted = $gpg->encrypt($pub_key,"teststring");
Running that code with php my_test.php
, I get the same E_NOTICE
errors as before:
Notice: Undefined offset: 5472 in […snipped…]/GPG/Public_Key.php on line 91
Notice: Undefined offset: 5473 in […snipped…]/GPG/Public_Key.php on line 91
Notice: Undefined offset: 5474 in […snipped…]/GPG/Public_Key.php on line 91
Apologies on not noticing the differences between my local key and the keyserver's copy I linked you to. Are you able to reproduce this with the above PGP public key block?
I do not see any :public key packet:
in the packets from the key which produces the notice. Also it seems some dates, digest and data values are different.
It seems this is an issue with the public subkey used for the encryption. Possibly the wrong key (or signature?) is used for this.
Seeking help here, the latest commit does not produce valid encrypted PGP data.
Did you also test with the current dev branch?
Also the key from the keyserver does not work, it does not produce any valid encrypted data.
With my own key it works without any issues. The keypair just consists of a public key and a sub public key.
I do not see any :public key packet: in the packets from the key which produces the notice.
That is strange, because I do. One :public key packet:
and one :public sub key packet:
, as per:
$ gpg2 --list-packets /tmp/offendingkey.asc | grep public.*key # "offendingkey.asc" is the key that produces the notice, above
:public key packet:
:public sub key packet:
Just in case it matters, this is what the above gpg2
binary reports about itself:
$ gpg2 --version
gpg (GnuPG/MacGPG2) 2.0.28
libgcrypt 1.6.3
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA, RSA, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
It seems this is an issue with the public subkey used for the encryption. Possibly the wrong key (or signature?) is used for this.
I'm sorry, I do not understand what you mean by this. The problematic key is "broken"? This is news to me, because I have been using this key for some time without issues with numerous OpenPGP clients; I am able to encrypt and decrypt using this keypair in all of them, so far, including php-gpg
.
Did you also test with the current dev branch?
Yes, but that was several days ago when I first reported the issue I encountered. Just now, I tested against the current HEAD of dev
(138aa80638ab4261d9fbc6d0c804f1edc44c02fd) but still see the notice:
Notice: Undefined offset: 5472 in …libs/GPG/Public_Key.php on line 141
Notice: Undefined offset: 5473 in …/libs/GPG/Public_Key.php on line 141
Notice: Undefined offset: 5474 in …/libs/GPG/Public_Key.php on line 141
Also the key from the keyserver does not work, it does not produce any valid encrypted data.
That is not the case on my copy. I can use the key from the keyserver with php-gpg's encrypt()
method and produce an encrypted message that the public key's private counterpart can decrypt. The same is true of the public key that produces the notice. :\
Maybe GPA just has a problem here, when the key is not imported. Trying tomorrow again.
What I meant it that maybe the structure of the whole key with the subkeys and signatures is problematic but I am not sure.
So encryption and decryption still work?
The same is true of the public key that produces the notice.
Did you try the commit which was an attempt to fix the issue? Because when the notice is thrown, the value should be 0 as it is not defined and can not be converted to an int with the normal code.
It seems my assumption is right.
https://m.reddit.com/r/GnuPG/comments/1ux9y3/clipboard_contained_no_valid_encrypted_data/
I was just doing some testing and realized that GPA has a serious user interface problem. If you are trying to decrypt a message that was encrypted with a public key for which you do not have the private key (message encrypted by the sender with the wrong public key, not yours) GPA will give that confusing error message "Clipboard contained no valid encrypted data". Try saving the message to a file and decrypting it with Kleopatra. Kleopatra will say "Decryption failed". But if you hit the "Show Details" button, it says "One unknown recipient".
Command line gpg gives the best error message:
Please check the version before the last reverted commit.
Please check the version before the last reverted commit.
I just tested again against ecf827f1025165b0788df2c1e1e811e5dda4a98a and this works; no notices are shown! Thank you so much for your work on this. :)
Thanks for the feedback, will make a new release with this patch.
Description
I encountered an
E_NOTICE
error I don't understand because it's only happening on one of my keys, and not on other keys. The specific error is:The offending code in my project is simple:
(The offending key happens to be my own key.)
Code to reproduce the issue
I wrote a unit test case that triggers a failure.
convertNoticesToExceptions="true"
in yourphpunit.xml
config.tests/gpg/KeyTest.php
:When I run this, I get this output:
Workarounds
I can use the error-suppression operator (
@new GPG_Public_Key($public_key_ascii)
) to avoid this error, but it seems weird to need to do this and I'd rather not have to.Other information
The perplexing part of this for me is that I can't figure out what's causing the
E_NOTICE
errors with only my key. I have tried several other keys without encountering this issue, including other keys of the same type (RSA) and length (2048 bits), as well as other keys that match this description with multiple subkeys and user IDs attached. The only key that produces this error is mine, and I can't figure out why. Halp?