Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horde_Crypt: Fix GnuPG 2 support #221

Merged
merged 2 commits into from Jun 12, 2017

Conversation

Projects
None yet
3 participants
@sathieu
Copy link
Contributor

commented May 18, 2017

No description provided.

sathieu added some commits May 18, 2017

Horde_Crypt: Fix getFingerprintsFromKey with gpg 2.1.18
Using --with-colons and --fixed-list-mode ensure stable formating.
@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented May 18, 2017

Before the fix

GnuPG 1.4.8:

# gpg --emit-version --no-tty --no-secmem-warning --no-options --no-default-keyring --yes --homedir /tmp/c6edyq0q --output /tmp/c6edyq0q/horde-pgp58hb3P --quiet --fingerprint --keyring /tmp/c6edyq0q/horde-pgp1xl0D2
/tmp/c6edyq0q/horde-pgp1xl0D2
-----------------------------
pub   1024D/F3C01D42 2008-04-11 [expired: 2013-04-10]
      Key fingerprint = 5912 D91D 4C79 C670 1FFF  1486 04A6 7B37 F3C0 1D42
uid                  Richard Selsky <rselsky@bu.edu>

GnuPG 2.1.18:

# gpg --emit-version --no-tty --no-secmem-warning --no-options --no-default-keyring --yes --homedir /tmp/31vjwypp --pinentry-mode loopback --output /tmp/31vjwypp/horde-pgpXaVQ7l --quiet --fingerprint --keyring /tmp/31vjwypp/horde-pgpLBGAax
/tmp/31vjwypp/horde-pgpLBGAax
-----------------------------
pub   dsa1024 2008-04-11 [SCA] [expired: 2013-04-10]
      5912 D91D 4C79 C670 1FFF  1486 04A6 7B37 F3C0 1D42
uid           [ expired] Richard Selsky <rselsky@bu.edu>

After the fix

GnuPG 1.4.8:

# gpg --emit-version --no-tty --no-secmem-warning --no-options --no-default-keyring --yes --homedir /tmp/c6edyq0q --output /tmp/c6edyq0q/horde-pgp58hb3P --quiet --fingerprint --keyring /tmp/c6edyq0q/horde-pgp1xl0D2 --with-colons  --fixed-list-mode
tru::1:1495138152:0:3:1:5
pub:e:1024:17:04A67B37F3C01D42:2008-04-11:2013-04-10::-:Richard Selsky <rselsky@bu.edu>::sca:
fpr:::::::::5912D91D4C79C6701FFF148604A67B37F3C01D42:
sub:e:2048:16:CED5B10AAF52BF66:2008-04-11:2013-04-10:::::e:

GnuPG 2.1.18:

# gpg --emit-version --no-tty --no-secmem-warning --no-options --no-default-keyring --yes --homedir /tmp/31vjwypp --pinentry-mode loopback --output /tmp/31vjwypp/horde-pgpXaVQ7l --quiet --fingerprint --keyring /tmp/31vjwypp/horde-pgpLBGAax --with-colons  --fixed-list-mode
tru::1:1495138039:0:3:1:5
pub:e:1024:17:04A67B37F3C01D42:1207935691:1365615691::-:::sca:::::::
fpr:::::::::5912D91D4C79C6701FFF148604A67B37F3C01D42:
uid:e::::1207935691::55FC574A25891AD822B15A545B96B216B25B4FFF::Richard Selsky <rselsky@bu.edu>:
sub:e:2048:16:CED5B10AAF52BF66:1207935691:1365615691:::::e::::::
fpr:::::::::057BCA92A635F950DE6D0D1DCED5B10AAF52BF66:
@yunosh

This comment has been minimized.

Copy link
Member

commented May 19, 2017

Great, thanks! Can you please provide a test case too?

@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented May 19, 2017

@yunosh the existing test cases were failing before this PR. I don't now which version @remicollet tested.

@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2017

Note that with this patch, the testsuite passes on Debian wheezy (GPG 1.4.12), jessie (1.4.18) and stretch (2.1.18).

Before the patch, it as failing on stretch.

@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2017

a0d76ad may be reverted once this one is merged (but I don't have access to version >= 2.1 and <= 2.1.11 to test).

@remicollet

This comment has been minimized.

Copy link
Contributor

commented May 23, 2017

I don't now which version @remicollet tested.

Versions available in Fedora (1.4.21) and RHEL (which don't have 1.x so 2.0 is used there)

@remicollet

This comment has been minimized.

Copy link
Contributor

commented May 23, 2017

Running some tests (with both /usr/bin/gpg and /usr/bin/gpg2)

Current version 2.7.8 (without this patch)

+ php /usr/bin/phpunit --verbose .
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.19
Configuration: /dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/phpunit.xml

.F...........F.......F.F.........E...                             37 / 37 (100%)

Time: 14.16 seconds, Memory: 4.00MB

There was 1 error:

1) Horde_Crypt_Pgp_BinaryTest::testGetPublicKeyFromPrivateKey with data set #1 (Horde_Crypt_Pgp Object (...))
reset() expects parameter 1 to be array, boolean given

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/lib/Horde/Crypt/Pgp/Backend/Binary.php:602
/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/lib/Horde/Crypt/Pgp.php:537
/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:602

--

There were 4 failures:

1) Horde_Crypt_Pgp_BinaryTest::testBug6601 with data set #1 (Horde_Crypt_Pgp Object (...))
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 Key ID:           0xF3C01D42
-Key Fingerprint:  5912D91D4C79C6701FFF148604A67B37F3C01D42
+Key Fingerprint:  [Unknown]
 
 '

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:64

2) Horde_Crypt_Pgp_BinaryTest::testGetSignersKeyID with data set #1 (Horde_Crypt_Pgp Object (...))
Failed asserting that null matches expected 'BADEABD7'.

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:222

3) Horde_Crypt_Pgp_BinaryTest::testPgpPrettyKey with data set #1 (Horde_Crypt_Pgp Object (...))
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 Key ID:           0xBADEABD7
-Key Fingerprint:  966F4BA9569DE6F65E8253977CA74426BADEABD7
+Key Fingerprint:  [Unknown]
 
 '

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:370

4) Horde_Crypt_Pgp_BinaryTest::testPgpGetFingerprintsFromKey with data set #1 (Horde_Crypt_Pgp Object (...), array('966F4BA9569DE6F65E8253977CA74...DEABD7'), '-----BEGIN PGP PUBLIC KEY BLO...-----\n', array('966F4BA9569DE6F65E8253977CA74...DEABD7'), '-----BEGIN PGP PRIVATE KEY BL...-----\n')
false does not match expected type "array".

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:397

ERRORS!
Tests: 37, Assertions: 79, Errors: 1, Failures: 4.

Version 2.7.8 with this patch applied:

  • RHEL-6, gnupg 2.0.14 => OK.
  • RHEL-7, gnupg 2.0.22 => OK
  • Fedora 26, gnupg 1.4.21 + 2.1.21 => OK
  • Fedora 23, 24, 25, gnupg 1.4.21 + 2.1.13 => KO
+ php /usr/bin/phpunit --verbose .
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.19
Configuration: /dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/phpunit.xml

.............F.......................                             37 / 37 (100%)

Time: 14.2 seconds, Memory: 4.00MB

There was 1 failure:

1) Horde_Crypt_Pgp_BinaryTest::testGetSignersKeyID with data set #1 (Horde_Crypt_Pgp Object (...))
Failed asserting that null matches expected 'BADEABD7'.

/dev/shm/BUILD/php-horde-Horde-Crypt-2.7.8/Horde_Crypt-2.7.8/test/Horde/Crypt/Pgp/TestBase.php:222

FAILURES!
Tests: 37, Assertions: 81, Failures: 1.

@yunosh yunosh merged commit e2bbd55 into horde:master Jun 12, 2017

1 of 2 checks passed

Scrutinizer Analysis: Errored – Tests: failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@yunosh

This comment has been minimized.

Copy link
Member

commented Jun 12, 2017

Thanks! a0d76ad is unfortunately not yet obsolete, at least with 2.1.11 the tests still fail.

@sathieu sathieu deleted the sathieu:gpg2 branch Jun 12, 2017

@remicollet

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2017

Now have a test failure (2.7.10) with GnuPG 2.2.0

There was 1 error:
1) Horde_Crypt_Pgp_BinaryTest::testGenerateKey with data set #1 (Horde_Crypt_Pgp Object (...))
Horde_Crypt_Exception: Public/Private keypair not generated successfully.
/builddir/build/BUILD/php-horde-Horde-Crypt-2.7.10/Horde_Crypt-2.7.10/lib/Horde/Crypt/Pgp.php:95
/builddir/build/BUILD/php-horde-Horde-Crypt-2.7.10/Horde_Crypt-2.7.10/test/Horde/Crypt/Pgp/TestBase.php:475
@yunosh

This comment has been minimized.

Copy link
Member

commented Sep 19, 2017

@remicollet

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2017

@yunosh would it make sense to skip this test ?

@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented Sep 19, 2017

We have all test passing in Debian (https://ci.debian.net/data/autopkgtest/unstable/amd64/p/php-horde-crypt/20170919_165521/log.gz), with gnupg 2.2.0 (and no gnupg 1 installed).

@yunosh

This comment has been minimized.

Copy link
Member

commented Sep 20, 2017

@sathieu

This comment has been minimized.

Copy link
Contributor Author

commented Sep 20, 2017

No, this is 2.7.9, without c7b3078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.