* Constructor.
*
* @param array $params Configuration parameters:
- * - 'email_charset': (string) The default email
- * charset. DEFAULT: NONE
- * - 'temp': (string) [REQUIRED] Location of
- * temporary directory.
+ * <pre>
+ * email_charset - (string) The default email charset.
+ * DEFAULT: NONE
+ * temp - (string) [REQUIRED] Location of temporary directory.
+ * </pre>
*
* @throws InvalidArgumentException
*/
<email>slusarz@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-10-22</date>
- <time>19:03:01</time>
+ <date>2011-01-19</date>
+ <time>23:11:03</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
<file name="Smime.php" role="php" />
<file name="Translation.php" role="php">
<tasks:replace from="@data_dir@" to="data_dir" type="pear-config" />
+ <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" />
</file>
</dir> <!-- /lib/Horde/Crypt -->
<file name="Crypt.php" role="php" />
<file name="pgp_signed2.txt" role="test" />
<file name="smime_subjectAltName.pem" role="test" />
</dir> <!-- /test/Horde/Crypt/fixtures -->
- <file name="bug_6601.phpt" role="test" />
- <file name="pgp.inc" role="test" />
- <file name="pgp_decrypt.phpt" role="test" />
- <file name="pgp_decrypt_symmetric.phpt" role="test" />
- <file name="pgp_encrypt.phpt" role="test" />
- <file name="pgp_encryptedSymmetrically.phpt" role="test" />
- <file name="pgp_encrypt_symmetric.phpt" role="test" />
- <file name="pgp_generateRevocation.phpt" role="test" />
- <file name="pgp_getSignersKeyID.phpt" role="test" />
- <file name="pgp_parsePGPData.phpt" role="test" />
- <file name="pgp_pgpPacketInformation.phpt" role="test" />
- <file name="pgp_pgpPacketSignature.phpt" role="test" />
- <file name="pgp_pgpPacketSignatureByUidIndex.phpt" role="test" />
- <file name="pgp_pgpPrettyKey.phpt" role="test" />
- <file name="pgp_publicKeyMIMEPart.phpt" role="test" />
- <file name="pgp_sign.phpt" role="test" />
- <file name="pgp_skipif.inc" role="test" />
- <file name="pgp_verify.phpt" role="test" />
- <file name="pgp_verifyPassphrase.phpt" role="test" />
- <file name="smime.inc" role="test" />
- <file name="smime_skipif.inc" role="test" />
- <file name="smime_subjectAltName.phpt" role="test" />
+ <file name="AllTests.php" role="test" />
+ <file name="Autoload.php" role="test" />
+ <file name="PgpTest.php" role="test" />
+ <file name="SmimeTest.php" role="test" />
</dir> <!-- /test/Horde/Crypt -->
</dir> <!-- /test/Horde -->
</dir> <!-- /test -->
<install as="locale/zh_CN/LC_MESSAGES/Horde_Crypt.po" name="locale/zh_CN/LC_MESSAGES/Horde_Crypt.po" />
<install as="locale/zh_TW/LC_MESSAGES/Horde_Crypt.mo" name="locale/zh_TW/LC_MESSAGES/Horde_Crypt.mo" />
<install as="locale/zh_TW/LC_MESSAGES/Horde_Crypt.po" name="locale/zh_TW/LC_MESSAGES/Horde_Crypt.po" />
- <install as="Horde/Crypt/bug_6601.phpt" name="test/Horde/Crypt/bug_6601.phpt" />
- <install as="Horde/Crypt/pgp.inc" name="test/Horde/Crypt/pgp.inc" />
- <install as="Horde/Crypt/pgp_decrypt.phpt" name="test/Horde/Crypt/pgp_decrypt.phpt" />
- <install as="Horde/Crypt/pgp_decrypt_symmetric.phpt" name="test/Horde/Crypt/pgp_decrypt_symmetric.phpt" />
- <install as="Horde/Crypt/pgp_encrypt.phpt" name="test/Horde/Crypt/pgp_encrypt.phpt" />
- <install as="Horde/Crypt/pgp_encryptedSymmetrically.phpt" name="test/Horde/Crypt/pgp_encryptedSymmetrically.phpt" />
- <install as="Horde/Crypt/pgp_encrypt_symmetric.phpt" name="test/Horde/Crypt/pgp_encrypt_symmetric.phpt" />
- <install as="Horde/Crypt/pgp_generateRevocation.phpt" name="test/Horde/Crypt/pgp_generateRevocation.phpt" />
- <install as="Horde/Crypt/pgp_getSignersKeyID.phpt" name="test/Horde/Crypt/pgp_getSignersKeyID.phpt" />
- <install as="Horde/Crypt/pgp_parsePGPData.phpt" name="test/Horde/Crypt/pgp_parsePGPData.phpt" />
- <install as="Horde/Crypt/pgp_pgpPacketInformation.phpt" name="test/Horde/Crypt/pgp_pgpPacketInformation.phpt" />
- <install as="Horde/Crypt/pgp_pgpPacketSignature.phpt" name="test/Horde/Crypt/pgp_pgpPacketSignature.phpt" />
- <install as="Horde/Crypt/pgp_pgpPacketSignatureByUidIndex.phpt" name="test/Horde/Crypt/pgp_pgpPacketSignatureByUidIndex.phpt" />
- <install as="Horde/Crypt/pgp_pgpPrettyKey.phpt" name="test/Horde/Crypt/pgp_pgpPrettyKey.phpt" />
- <install as="Horde/Crypt/pgp_publicKeyMIMEPart.phpt" name="test/Horde/Crypt/pgp_publicKeyMIMEPart.phpt" />
- <install as="Horde/Crypt/pgp_sign.phpt" name="test/Horde/Crypt/pgp_sign.phpt" />
- <install as="Horde/Crypt/pgp_skipif.inc" name="test/Horde/Crypt/pgp_skipif.inc" />
- <install as="Horde/Crypt/pgp_verify.phpt" name="test/Horde/Crypt/pgp_verify.phpt" />
- <install as="Horde/Crypt/pgp_verifyPassphrase.phpt" name="test/Horde/Crypt/pgp_verifyPassphrase.phpt" />
- <install as="Horde/Crypt/smime.inc" name="test/Horde/Crypt/smime.inc" />
- <install as="Horde/Crypt/smime_skipif.inc" name="test/Horde/Crypt/smime_skipif.inc" />
- <install as="Horde/Crypt/smime_subjectAltName.phpt" name="test/Horde/Crypt/smime_subjectAltName.phpt" />
+ <install as="Horde/Crypt/AllTests.php" name="test/Horde/Crypt/AllTests.php" />
+ <install as="Horde/Crypt/Autoload.php" name="test/Horde/Crypt/Autoload.php" />
+ <install as="Horde/Crypt/PgpTest.php" name="test/Horde/Crypt/PgpTest.php" />
+ <install as="Horde/Crypt/SmimeTest.php" name="test/Horde/Crypt/SmimeTest.php" />
<install as="Horde/Crypt/fixtures/bug_6601.asc" name="test/Horde/Crypt/fixtures/bug_6601.asc" />
<install as="Horde/Crypt/fixtures/clear.txt" name="test/Horde/Crypt/fixtures/clear.txt" />
<install as="Horde/Crypt/fixtures/pgp_encrypted.txt" name="test/Horde/Crypt/fixtures/pgp_encrypted.txt" />
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-10-22</date>
+ <date>2011-01-19</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
* Add Horde_Crypt_Exception::.
--- /dev/null
+<?php
+/**
+ * Tests for the horde/Crypt package.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Crypt
+ * @package Crypt
+ * @subpackage UnitTests
+ */
+
+/**
+ * Define the main method
+ */
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'Horde_Crypt_AllTests::main');
+}
+
+/**
+ * Prepare the test setup.
+ */
+require_once 'Horde/Test/AllTests.php';
+
+/**
+ * @category Horde
+ * @package Crypt
+ * @subpackage UnitTests
+ */
+class Horde_Crypt_AllTests extends Horde_Test_AllTests
+{
+}
+
+Horde_Crypt_AllTests::init('Horde_Crypt', __FILE__);
+
+if (PHPUnit_MAIN_METHOD == 'Horde_Crypt_AllTests::main') {
+ Horde_Crypt_AllTests::main();
+}
--- /dev/null
+<?php
+/**
+ * Setup autoloading for the tests.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Crypt
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Crypt
+ */
+
+if (!spl_autoload_functions()) {
+ spl_autoload_register(
+ create_function(
+ '$class',
+ '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);'
+ . '$err_mask = E_ALL ^ E_WARNING;'
+ . '$oldErrorReporting = error_reporting($err_mask);'
+ . 'include "$filename.php";'
+ . 'error_reporting($oldErrorReporting);'
+ )
+ );
+}
+
+/** Catch strict standards */
+error_reporting(E_ALL | E_STRICT);
--- /dev/null
+<?php
+/**
+ * Horde_Crypt_Pgp tests.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Crypt
+ * @subpackage UnitTests
+ */
+
+class Horde_Crypt_PgpTest extends PHPUnit_Framework_TestCase
+{
+ protected $_pgp;
+ protected $_privkey;
+ protected $_pubkey;
+
+ protected function setUp()
+ {
+ if (!is_executable('/usr/bin/gpg')) {
+ $this->markTestSkipped('GPG binary not found at /usr/bin/gpg.');
+ }
+
+ $this->_pgp = Horde_Crypt::factory('Pgp', array(
+ 'program' => '/usr/bin/gpg',
+ 'temp' => Horde_Util::getTempDir()
+ ));
+
+ $this->_privkey = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_private.asc');
+ $this->_pubkey = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_public.asc');
+ }
+
+ public function testBug6601()
+ {
+ @date_default_timezone_set('GMT');
+
+ $data = file_get_contents(dirname(__FILE__) . '/fixtures/bug_6601.asc');
+
+ $this->assertEquals(
+'Name: Richard Selsky
+Key Type: Public Key
+Key Creation: 04/11/08
+Expiration Date: [Never]
+Key Length: 1024 Bytes
+Comment: [None]
+E-Mail: rselsky@bu.edu
+Hash-Algorithm: pgp-sha1
+Key ID: 0xF3C01D42
+Key Fingerprint: 5912 D91D 4C79 C670 1FFF 1486 04A6 7B37 F3C0 1D42
+
+',
+ $this->_pgp->pgpPrettyKey($data)
+ );
+ }
+
+ // decrypt() message
+ public function testPgpDecrypt()
+ {
+ // Encrypted data is in ISO-8859-1 format
+ $crypt = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted.txt');
+
+ $decrypt = $this->_pgp->decrypt($crypt, array(
+ 'passphrase' => 'Secret',
+ 'privkey' => $this->_privkey,
+ 'pubkey' => $this->_pubkey,
+ 'type' => 'message'
+ ));
+
+ $this->assertEquals(
+'0123456789012345678901234567890123456789
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+0123456789012345678901234567890123456789
+!"$§%&()=?^´°`+#-.,*\'_:;<>|~\{[]}
+
+',
+ Horde_String::convertCharset($decrypt->message, 'ISO-8859-1', 'UTF-8')
+ );
+ }
+
+ public function testPgpDecryptSymmetric()
+ {
+ // Encrypted data is in ISO-8859-1 format
+ $crypt = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted_symmetric.txt');
+
+ $decrypt = $this->_pgp->decrypt($crypt, array(
+ 'passphrase' => 'Secret',
+ 'type' => 'message'
+ ));
+
+ $this->assertEquals(
+'0123456789012345678901234567890123456789
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+0123456789012345678901234567890123456789
+!"$§%&()=?^´°`+#-.,*\'_:;<>|~\{[]}
+',
+ Horde_String::convertCharset($decrypt->message, 'ISO-8859-1', 'UTF-8')
+ );
+ }
+
+ public function testPgpEncrypt()
+ {
+ $clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
+
+ $out = $this->_pgp->encrypt($clear, array(
+ 'recips' => array('me@example.com' => $this->_pubkey),
+ 'type' => 'message'
+ ));
+
+ $this->assertStringMatchesFormat(
+'-----BEGIN PGP MESSAGE-----
+Version: GnuPG v%d.%d.%d (%s)
+
+%s
+%s
+%s
+%s
+%s
+%s
+%s
+%s
+%s
+%s
+=%s
+-----END PGP MESSAGE-----',
+ $out
+ );
+ }
+
+ public function testPgpEncryptSymmetric()
+ {
+ $clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
+
+ $out = $this->_pgp->encrypt($clear, array(
+ 'passphrase' => 'Secret',
+ 'symmetric' => true,
+ 'type' => 'message'
+ ));
+
+ $this->assertStringMatchesFormat(
+'-----BEGIN PGP MESSAGE-----
+Version: GnuPG v%d.%d.%d (%s)
+
+%s
+%s
+%s
+%s
+=%s
+-----END PGP MESSAGE-----',
+ $out
+ );
+ }
+
+ public function testPgpEncryptedSymmetrically()
+ {
+ $this->assertFalse(
+ $this->_pgp->encryptedSymmetrically(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted.txt'))
+ );
+ $this->assertTrue(
+ $this->_pgp->encryptedSymmetrically(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted_symmetric.txt'))
+ );
+ }
+
+ public function testGenerateRevocation()
+ {
+ $this->assertStringMatchesFormat(
+'-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v%d.%d.%d (%s)
+Comment: A revocation certificate should follow
+
+%s
+%s
+=%s
+-----END PGP PUBLIC KEY BLOCK-----',
+ $this->_pgp->generateRevocation(
+ $this->_privkey,
+ 'me@example.com',
+ 'Secret'
+ )
+ );
+ }
+
+ public function testGetSignersKeyID()
+ {
+ $this->assertEquals(
+ 'BADEABD7',
+ $this->_pgp->getSignersKeyID(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt'))
+ );
+ }
+
+ public function testParsePGPData()
+ {
+ $out = $this->_pgp->parsePGPData(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt'));
+
+ $this->assertEquals(
+ 2,
+ count($out)
+ );
+
+ $this->assertEquals(
+ Horde_Crypt_Pgp::ARMOR_SIGNED_MESSAGE,
+ $out[0]['type']
+ );
+ $this->assertEquals(
+ 17,
+ count($out[0]['data'])
+ );
+
+ $this->assertEquals(
+ Horde_Crypt_Pgp::ARMOR_SIGNATURE,
+ $out[1]['type']
+ );
+ $this->assertEquals(
+ 7,
+ count($out[1]['data'])
+ );
+ }
+
+
+ public function testPgpPacketInformation()
+ {
+ $out = $this->_pgp->pgpPacketInformation($this->_pubkey);
+
+ $this->assertArrayHasKey(
+ 'public_key',
+ $out
+ );
+ $this->assertArrayNotHasKey(
+ 'secret_key',
+ $out
+ );
+ $this->assertEquals(
+ '1155291888',
+ $out['public_key']['created']
+ );
+ $this->assertEquals(
+ 2,
+ count($out['signature'])
+ );
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+
+ $out = $this->_pgp->pgpPacketInformation($this->_privkey);
+
+ $this->assertArrayHasKey(
+ 'secret_key',
+ $out
+ );
+ $this->assertArrayNotHasKey(
+ 'public_key',
+ $out
+ );
+ $this->assertEquals(
+ '1155291888',
+ $out['secret_key']['created']
+ );
+ $this->assertEquals(
+ 2,
+ count($out['signature'])
+ );
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+ }
+
+ public function testPgpPacketSignature()
+ {
+ $out = $this->_pgp->pgpPacketSignature($this->_pubkey, 'me@example.com');
+
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+
+ $out = $this->_pgp->pgpPacketSignature($this->_privkey, 'me@example.com');
+
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+
+ $out = $this->_pgp->pgpPacketSignature($this->_privkey, 'foo@example.com');
+
+ $this->assertArrayNotHasKey(
+ 'keyid',
+ $out
+ );
+ }
+
+ public function testPgpPacketSignatureByUidIndex()
+ {
+ $out = $this->_pgp->pgpPacketSignatureByUidIndex($this->_pubkey, 'id1');
+
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+
+ $out = $this->_pgp->pgpPacketSignatureByUidIndex($this->_privkey, 'id1');
+
+ $this->assertEquals(
+ '7CA74426BADEABD7',
+ $out['keyid']
+ );
+
+ $out = $this->_pgp->pgpPacketSignatureByUidIndex($this->_privkey, 'id2');
+
+ $this->assertArrayNotHasKey(
+ 'keyid',
+ $out
+ );
+ }
+
+ public function testPgpPrettyKey()
+ {
+ $this->assertEquals(
+'Name: My Name
+Key Type: Public Key
+Key Creation: 08/11/06
+Expiration Date: [Never]
+Key Length: 1024 Bytes
+Comment: My Comment
+E-Mail: me@example.com
+Hash-Algorithm: pgp-sha1
+Key ID: 0xBADEABD7
+Key Fingerprint: 966F 4BA9 569D E6F6 5E82 5397 7CA7 4426 BADE ABD7
+
+',
+ $this->_pgp->pgpPrettyKey($this->_pubkey)
+ );
+
+ $this->assertEquals(
+'Name: My Name
+Key Type: Private Key
+Key Creation: 08/11/06
+Expiration Date: [Never]
+Key Length: 1024 Bytes
+Comment: My Comment
+E-Mail: me@example.com
+Hash-Algorithm: pgp-sha1
+Key ID: 0xBADEABD7
+Key Fingerprint: 966F 4BA9 569D E6F6 5E82 5397 7CA7 4426 BADE ABD7
+
+',
+ $this->_pgp->pgpPrettyKey($this->_privkey)
+ );
+ }
+
+ public function pgpPublicKeyMIMEPart()
+ {
+ $mime_part = $this->_pgp->publicKeyMIMEPart($this->_pubkey);
+
+ $this->assertEquals(
+ 'application/pgp-keys',
+ $mime_part->getType()
+ );
+
+ $this->assertEquals(
+'-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v%d.%d.%d (GNU/Linux)
+
+mQGiBETcWvARBADNitbvsWy5/hhV+WcU2ttmtXkAj2DqJVgJdGS2RH8msO0roG5j
+CQK/e0iMJki5lfdgxvxxWgStYMnfF5ftgWA7JV+BZUzJt12Lobm0zdENv2TqL2vc
+xlPTmEGsvfPDTbY+Gr3jvuODboXat7bUn2E723WXPdh2A7KNNnLou7JF2wCgiKs/
+RqNKM/Zm01PxLbQ+rs9ghd0D/jLUfJeYWySoDsvfO8e4UyDxDVTBLkkdw3XzLx1F
+4SS/Cc2Z9yJuXiepzSH/G/vhdN5ROv12kJwA4FbwsFv5C1uCQleWiPngFixca9Nw
+lAd2X2Cp0/4D2XRq1M9dEbcYdrgAuyzt2ZToj3aFaYNGwjfHoLqSngOu6/d3KD1d
+i0b2A/9wnXo41kPwS73gU1Un2KKMkKqnczCQHdpopO6NjKaLhNcouRauLrgbrS5y
+A1CW+nxjkKVvWrP/VFBmapUpjE1C51J9P0/ub8tRr7H0xHdTQyufv01lmfkjUpVF
+n3GVf95l4seBFzD7r580aTx+dJztoHEGWrsWZTNJwo6IIlFOIbQlTXkgTmFtZSAo
+TXkgQ29tbWVudCkgPG1lQGV4YW1wbGUuY29tPohgBBMRAgAgBQJE3FrwAhsjBgsJ
+CAcDAgQVAggDBBYCAwECHgECF4AACgkQfKdEJrreq9fivACeLBcWErSQU4ZGQsje
+dhwfdst9cLQAnRETpwmqt/XvcGFVsOE28MUrUzOGuQENBETcWvAQBADNgIJ4nDlf
+gBOI/iqyNy08C9+MjxrqMylrj4TPn3rRk8wySr2myX+j9CML5EHOtsxANYeI9u7h
+OF11n5Z8fDht/WGJrNR7EtRhNN6mkKsPaEuO3fhz6EgwJYReUVzDJbvnV2fRCvQo
+EGaSntZGQaQzIzIL+/gMEFpEVRK1P2I3VwADBQP+K2Rmmkm3DonXFlUUDWWdhEF4
+b7fy5/IPj41PSSOdo0IP4dprFoe15Vs9gWOYvzcnjy+BbOwhVwsjE3F36hf04od3
+uTSM0dLS/xmpSvgbBh181T5c3W5aKT/daVhyxXJ4csxE+JCVKbaBubne0DPEuyZj
+rYlL5Lm0z3VhNCcR0LyISQQYEQIACQUCRNxa8AIbDAAKCRB8p0Qmut6r16Y3AJ9h
+umO5uT5yDcir3zwqUAxzBAkE4ACcCtGfb6usaTKnNXo+ZuLoHiOwIE4=
+=GCjU
+-----END PGP PUBLIC KEY BLOCK-----',
+ $mime_part->getContents()
+ );
+ }
+
+ public function testPgpSign()
+ {
+ $clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
+
+ $out = $this->_pgp->encrypt($clear, array(
+ 'passphrase' => 'Secret',
+ 'privkey' => $this->_privkey,
+ 'pubkey' => $this->_pubkey,
+ 'type' => 'signature'
+ ));
+
+ $this->assertStringMatchesFormat(
+'-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v%d.%d.%d (%s)
+
+%s
+%s
+=%s
+-----END PGP SIGNATURE-----',
+ $out
+ );
+
+ $out = $this->_pgp->encrypt($clear, array(
+ 'passphrase' => 'Secret',
+ 'privkey' => $this->_privkey,
+ 'pubkey' => $this->_pubkey,
+ 'sigtype' => 'cleartext',
+ 'type' => 'signature'
+ ));
+
+ $this->assertStringMatchesFormat(
+'-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+0123456789012345678901234567890123456789
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+0123456789012345678901234567890123456789
+!"$§%&()=?^´°`+#-.,*\'_:;<>|~\{[]}
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v%d.%d.%d (%s)
+
+%s
+%s
+=%s
+-----END PGP SIGNATURE-----',
+ Horde_String::convertCharset($out, 'ISO-8859-1', 'UTF-8')
+ );
+ }
+
+ public function testDecryptSignature()
+ {
+ date_default_timezone_set('GMT');
+
+ $out = $this->_pgp->decrypt(
+ file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt'),
+ array(
+ 'pubkey' => $this->_pubkey,
+ 'signature' => file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signature.txt'),
+ 'type' => 'detached-signature'
+ )
+ );
+
+ $this->assertTrue($out->result);
+
+ $out = $this->_pgp->decrypt(
+ file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt'),
+ array(
+ 'pubkey' => $this->_pubkey,
+ 'type' => 'signature'
+ )
+ );
+
+ $this->assertTrue($out->result);
+
+ $out = $this->_pgp->decrypt(
+ file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed2.txt'),
+ array(
+ 'pubkey' => $this->_pubkey,
+ 'type' => 'signature'
+ )
+ );
+
+ $this->assertTrue($out->result);
+ }
+
+ public function testVerifyPassphrase()
+ {
+ $this->assertTrue(
+ $this->_pgp->verifyPassphrase($this->_pubkey, $this->_privkey, 'Secret')
+ );
+
+ $this->assertFalse(
+ $this->_pgp->verifyPassphrase($this->_pubkey, $this->_privkey, 'Wrong')
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Horde_Crypt_Smime tests.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Crypt
+ * @subpackage UnitTests
+ */
+
+class Horde_Crypt_SmimeTest extends PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ if (!extension_loaded('openssl')) {
+ $this->markTestSkipped('No openssl support in PHP.');
+ }
+ }
+
+ public function testSubjectAltName()
+ {
+ $smime = Horde_Crypt::factory('Smime', array(
+ 'temp' => Horde_Util::getTempDir()
+ ));
+
+ $key = file_get_contents(dirname(__FILE__) . '/fixtures/smime_subjectAltName.pem');
+
+ $this->assertEquals(
+ 'test1@example.com',
+ $smime->getEmailFromKey($key)
+ );
+ }
+
+}
+++ /dev/null
---TEST--
-Bug #6601
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-@date_default_timezone_set('GMT');
-
-require 'pgp.inc';
-
-echo $pgp->pgpPrettyKey(file_get_contents(dirname(__FILE__) . '/fixtures/bug_6601.asc'));
-?>
---EXPECT--
-Name: Richard Selsky
-Key Type: Public Key
-Key Creation: 04/11/08
-Expiration Date: [Never]
-Key Length: 1024 Bytes
-Comment: [None]
-E-Mail: rselsky@bu.edu
-Hash-Algorithm: pgp-sha1
-Key ID: 0xF3C01D42
-Key Fingerprint: 5912 D91D 4C79 C670 1FFF 1486 04A6 7B37 F3C0 1D42
-
+++ /dev/null
-<?php
-/**
- * @category Horde
- * @package Crypt
- */
-
-$filedir = dirname(__FILE__);
-
-require 'PEAR.php';
-require 'Horde/Util.php';
-require 'Horde/Browser.php';
-require $filedir . '/../../../lib/Horde/Crypt.php';
-
-$_SERVER['HTTPS'] = 'on';
-$browser = &Browser::singleton();
-
-$pgp = Horde_Crypt::factory('Pgp', array(
- 'program' => '/usr/bin/gpg',
- 'temp' => Horde_Util::getTempDir()
-));
-
-$pubkey = file_get_contents($filedir . '/fixtures/pgp_public.asc');
-$privkey = file_get_contents($filedir . '/fixtures/pgp_private.asc');
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::decrypt() message.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-$crypt = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted.txt');
-
-$decrypt = $pgp->decrypt($crypt,
- array('type' => 'message',
- 'pubkey' => $pubkey,
- 'privkey' => $privkey,
- 'passphrase' => 'Secret'));
-if (is_a($decrypt, 'PEAR_Error')) {
- var_dump($decrypt);
-} else {
- echo $decrypt->message;
-}
-
-?>
---EXPECT--
-0123456789012345678901234567890123456789
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-0123456789012345678901234567890123456789
-!"$§%&()=?^´°`+#-.,*'_:;<>|~\{[]}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::decrypt() message.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-$crypt = file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted_symmetric.txt');
-
-$decrypt = $pgp->decrypt($crypt,
- array('type' => 'message',
- 'passphrase' => 'Secret'));
-if (is_a($decrypt, 'PEAR_Error')) {
- var_dump($decrypt);
-} else {
- echo $decrypt->message;
-}
-
-?>
---EXPECT--
-0123456789012345678901234567890123456789
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-0123456789012345678901234567890123456789
-!"$§%&()=?^´°`+#-.,*'_:;<>|~\{[]}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::encrypt() message.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-$clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
-
-echo $pgp->encrypt($clear,
- array('type' => 'message',
- 'recips' => array('me@example.com' => $pubkey)));
-
-?>
---EXPECTF--
------BEGIN PGP MESSAGE-----
-Version: GnuPG v%d.%d.%d (%s)
-
-%s
-%s
-%s
-%s
-%s
-%s
-%s
-%s
-%s
-%s
-=%s
------END PGP MESSAGE-----
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::encrypt() message symmetric.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-$clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
-
-echo $pgp->encrypt($clear,
- array('type' => 'message',
- 'symmetric' => true,
- 'passphrase' => 'Secret'));
-
-?>
---EXPECTF--
------BEGIN PGP MESSAGE-----
-Version: GnuPG v%d.%d.%d (%s)
-
-%s
-%s
-%s
-%s
-=%s
------END PGP MESSAGE-----
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::encryptedSymmetrically()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-var_dump($pgp->encryptedSymmetrically(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted.txt')));
-var_dump($pgp->encryptedSymmetrically(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_encrypted_symmetric.txt')));
-
-?>
---EXPECT--
-bool(false)
-bool(true)
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::generateRevocation()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-echo $pgp->generateRevocation($privkey, 'me@example.com', 'Secret');
-
-?>
---EXPECTF--
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: GnuPG v%d.%d.%d (%s)
-Comment: A revocation certificate should follow
-
-%s
-%s
-=%s
------END PGP PUBLIC KEY BLOCK-----
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::getSignersKeyID()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-echo $pgp->getSignersKeyID(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt'));
-
-?>
---EXPECT--
-BADEABD7
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::parsePGPData().
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-
-var_dump($pgp->parsePGPData(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt')));
-
-?>
---EXPECT--
-array(3) {
- [0]=>
- array(2) {
- ["type"]=>
- int(2)
- ["data"]=>
- array(17) {
- [0]=>
- string(34) "-----BEGIN PGP SIGNED MESSAGE-----"
- [1]=>
- string(10) "Hash: SHA1"
- [2]=>
- string(0) ""
- [3]=>
- string(40) "0123456789012345678901234567890123456789"
- [4]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [5]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [6]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [7]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [8]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [9]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [10]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [11]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [12]=>
- string(89) "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
- [13]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [14]=>
- string(44) "The quick brown fox jumps over the lazy dog."
- [15]=>
- string(40) "0123456789012345678901234567890123456789"
- [16]=>
- string(33) "!"$§%&()=?^´°`+#-.,*'_:;<>|~\{[]}"
- }
- }
- [1]=>
- array(2) {
- ["type"]=>
- int(5)
- ["data"]=>
- array(7) {
- [0]=>
- string(29) "-----BEGIN PGP SIGNATURE-----"
- [1]=>
- string(33) "Version: GnuPG v1.4.5 (GNU/Linux)"
- [2]=>
- string(0) ""
- [3]=>
- string(64) "iD8DBQFE3JNgfKdEJrreq9cRAm4lAJ48IbiwbO4ToXa2BrJaAZAFt43AiACZATs+"
- [4]=>
- string(24) "gnfrwrK41BzMWmVRhtjB1Po="
- [5]=>
- string(5) "=5HXb"
- [6]=>
- string(27) "-----END PGP SIGNATURE-----"
- }
- }
- [2]=>
- array(2) {
- ["type"]=>
- int(6)
- ["data"]=>
- array(1) {
- [0]=>
- string(0) ""
- }
- }
-}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::pgpPacketInformation()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-var_dump($pgp->pgpPacketInformation($pubkey));
-var_dump($pgp->pgpPacketInformation($privkey));
-
-?>
---EXPECT--
-array(4) {
- ["public_key"]=>
- array(3) {
- ["created"]=>
- string(10) "1155291888"
- ["expires"]=>
- string(1) "0"
- ["size"]=>
- string(4) "1024"
- }
- ["signature"]=>
- array(2) {
- ["id1"]=>
- array(7) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["_SIGNATURE"]=>
- array(2) {
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- }
- }
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
-}
-array(4) {
- ["secret_key"]=>
- array(3) {
- ["created"]=>
- string(10) "1155291888"
- ["expires"]=>
- string(1) "0"
- ["size"]=>
- string(4) "1024"
- }
- ["signature"]=>
- array(2) {
- ["id1"]=>
- array(7) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["_SIGNATURE"]=>
- array(2) {
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- }
- }
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
-}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::pgpPacketSignature()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-var_dump($pgp->pgpPacketSignature($pubkey, 'me@example.com'));
-var_dump($pgp->pgpPacketSignature($privkey, 'me@example.com'));
-var_dump($pgp->pgpPacketSignature($privkey, 'foo@example.com'));
-
-?>
---EXPECT--
-array(11) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["key_type"]=>
- string(10) "public_key"
- ["key_created"]=>
- string(10) "1155291888"
- ["key_expires"]=>
- string(1) "0"
- ["key_size"]=>
- string(4) "1024"
-}
-array(11) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["key_type"]=>
- string(10) "secret_key"
- ["key_created"]=>
- string(10) "1155291888"
- ["key_expires"]=>
- string(1) "0"
- ["key_size"]=>
- string(4) "1024"
-}
-array(0) {
-}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::pgpPacketSignatureByUidIndex()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-var_dump($pgp->pgpPacketSignatureByUidIndex($pubkey, 'id1'));
-var_dump($pgp->pgpPacketSignatureByUidIndex($privkey, 'id1'));
-var_dump($pgp->pgpPacketSignatureByUidIndex($privkey, 'id2'));
-
-?>
---EXPECT--
-array(11) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["key_type"]=>
- string(10) "public_key"
- ["key_created"]=>
- string(10) "1155291888"
- ["key_expires"]=>
- string(1) "0"
- ["key_size"]=>
- string(4) "1024"
-}
-array(11) {
- ["name"]=>
- string(7) "My Name"
- ["comment"]=>
- string(10) "My Comment"
- ["email"]=>
- string(14) "me@example.com"
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["sig_7CA74426BADEABD7"]=>
- array(4) {
- ["keyid"]=>
- string(16) "7CA74426BADEABD7"
- ["fingerprint"]=>
- string(16) "7CA74426BADEABD7"
- ["created"]=>
- string(10) "1155291888"
- ["micalg"]=>
- string(8) "pgp-sha1"
- }
- ["micalg"]=>
- string(8) "pgp-sha1"
- ["key_type"]=>
- string(10) "secret_key"
- ["key_created"]=>
- string(10) "1155291888"
- ["key_expires"]=>
- string(1) "0"
- ["key_size"]=>
- string(4) "1024"
-}
-array(0) {
-}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::pgpPrettyKey()
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-echo $pgp->pgpPrettyKey($pubkey);
-echo $pgp->pgpPrettyKey($privkey);
-
-?>
---EXPECT--
-Name: My Name
-Key Type: Public Key
-Key Creation: 08/11/06
-Expiration Date: [Never]
-Key Length: 1024 Bytes
-Comment: My Comment
-E-Mail: me@example.com
-Hash-Algorithm: pgp-sha1
-Key ID: 0xBADEABD7
-Key Fingerprint: 966F 4BA9 569D E6F6 5E82 5397 7CA7 4426 BADE ABD7
-
-Name: My Name
-Key Type: Private Key
-Key Creation: 08/11/06
-Expiration Date: [Never]
-Key Length: 1024 Bytes
-Comment: My Comment
-E-Mail: me@example.com
-Hash-Algorithm: pgp-sha1
-Key ID: 0xBADEABD7
-Key Fingerprint: 966F 4BA9 569D E6F6 5E82 5397 7CA7 4426 BADE ABD7
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::publicKeyMIMEPart().
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-class PrefsStub {
- function getValue($pref)
- {
- if ($pref == 'sending_charset') {
- return 'iso-8859-1';
- }
- die('unknown preference');
- }
-}
-
-require_once 'Horde/Nls.php';
-require 'pgp.inc';
-
-$prefs = new PrefsStub;
-$mime_part = $pgp->publicKeyMIMEPart($pubkey);
-echo $mime_part->getType() . "\n\n";
-echo $mime_part->getContents();
-
-?>
---EXPECTF--
-application/pgp-keys
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: GnuPG v%d.%d.%d (GNU/Linux)
-
-mQGiBETcWvARBADNitbvsWy5/hhV+WcU2ttmtXkAj2DqJVgJdGS2RH8msO0roG5j
-CQK/e0iMJki5lfdgxvxxWgStYMnfF5ftgWA7JV+BZUzJt12Lobm0zdENv2TqL2vc
-xlPTmEGsvfPDTbY+Gr3jvuODboXat7bUn2E723WXPdh2A7KNNnLou7JF2wCgiKs/
-RqNKM/Zm01PxLbQ+rs9ghd0D/jLUfJeYWySoDsvfO8e4UyDxDVTBLkkdw3XzLx1F
-4SS/Cc2Z9yJuXiepzSH/G/vhdN5ROv12kJwA4FbwsFv5C1uCQleWiPngFixca9Nw
-lAd2X2Cp0/4D2XRq1M9dEbcYdrgAuyzt2ZToj3aFaYNGwjfHoLqSngOu6/d3KD1d
-i0b2A/9wnXo41kPwS73gU1Un2KKMkKqnczCQHdpopO6NjKaLhNcouRauLrgbrS5y
-A1CW+nxjkKVvWrP/VFBmapUpjE1C51J9P0/ub8tRr7H0xHdTQyufv01lmfkjUpVF
-n3GVf95l4seBFzD7r580aTx+dJztoHEGWrsWZTNJwo6IIlFOIbQlTXkgTmFtZSAo
-TXkgQ29tbWVudCkgPG1lQGV4YW1wbGUuY29tPohgBBMRAgAgBQJE3FrwAhsjBgsJ
-CAcDAgQVAggDBBYCAwECHgECF4AACgkQfKdEJrreq9fivACeLBcWErSQU4ZGQsje
-dhwfdst9cLQAnRETpwmqt/XvcGFVsOE28MUrUzOGuQENBETcWvAQBADNgIJ4nDlf
-gBOI/iqyNy08C9+MjxrqMylrj4TPn3rRk8wySr2myX+j9CML5EHOtsxANYeI9u7h
-OF11n5Z8fDht/WGJrNR7EtRhNN6mkKsPaEuO3fhz6EgwJYReUVzDJbvnV2fRCvQo
-EGaSntZGQaQzIzIL+/gMEFpEVRK1P2I3VwADBQP+K2Rmmkm3DonXFlUUDWWdhEF4
-b7fy5/IPj41PSSOdo0IP4dprFoe15Vs9gWOYvzcnjy+BbOwhVwsjE3F36hf04od3
-uTSM0dLS/xmpSvgbBh181T5c3W5aKT/daVhyxXJ4csxE+JCVKbaBubne0DPEuyZj
-rYlL5Lm0z3VhNCcR0LyISQQYEQIACQUCRNxa8AIbDAAKCRB8p0Qmut6r16Y3AJ9h
-umO5uT5yDcir3zwqUAxzBAkE4ACcCtGfb6usaTKnNXo+ZuLoHiOwIE4=
-=GCjU
------END PGP PUBLIC KEY BLOCK-----
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::encrypt() signature.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-$clear = file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt');
-
-echo $pgp->encrypt($clear,
- array('type' => 'signature',
- 'pubkey' => $pubkey,
- 'privkey' => $privkey,
- 'passphrase' => 'Secret'));
-echo $pgp->encrypt($clear,
- array('type' => 'signature',
- 'pubkey' => $pubkey,
- 'privkey' => $privkey,
- 'passphrase' => 'Secret',
- 'sigtype' => 'cleartext'));
-
-?>
---EXPECTF--
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v%d.%d.%d (%s)
-
-%s
-%s
-=%s
------END PGP SIGNATURE-----
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-0123456789012345678901234567890123456789
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-The quick brown fox jumps over the lazy dog.
-0123456789012345678901234567890123456789
-!"$§%&()=?^´°`+#-.,*'_:;<>|~\{[]}
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v%d.%d.%d (%s)
-
-%s
-%s
-=%s
------END PGP SIGNATURE-----
+++ /dev/null
-<?php
-/**
- * @category Horde
- * @package Crypt
- */
-
-if (!is_executable('/usr/bin/gpg')) {
- echo 'skip No GPG binary at /usr/bin/gpg';
-}
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::decrypt() signature.
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-date_default_timezone_set('GMT');
-
-require 'pgp.inc';
-
-echo $pgp->decrypt(file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt'),
- array('type' => 'detached-signature',
- 'pubkey' => $pubkey,
- 'signature' => file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signature.txt')));
-
-echo $pgp->decrypt(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed.txt'),
- array('type' => 'signature',
- 'pubkey' => $pubkey));
-
-echo $pgp->decrypt(file_get_contents(dirname(__FILE__) . '/fixtures/pgp_signed2.txt'),
- array('type' => 'signature',
- 'pubkey' => $pubkey));
-
-?>
---EXPECT--
-gpg: Signature made Fri Aug 11 14:42:54 2006 GMT using DSA key ID BADEABD7
-gpg: Good signature from "My Name (My Comment) <me@example.com>"
-gpg: Signature made Fri Aug 11 14:25:36 2006 GMT using DSA key ID BADEABD7
-gpg: Good signature from "My Name (My Comment) <me@example.com>"
-gpg: Signature made Fri Aug 11 14:28:48 2006 GMT using DSA key ID BADEABD7
-gpg: Good signature from "My Name (My Comment) <me@example.com>"
+++ /dev/null
---TEST--
-Horde_Crypt_pgp::verifyPassphrase().
---SKIPIF--
-<?php require 'pgp_skipif.inc'; ?>
---FILE--
-<?php
-
-require 'pgp.inc';
-
-var_dump($pgp->verifyPassphrase($pubkey, $privkey, 'Secret'));
-var_dump($pgp->verifyPassphrase($pubkey, $privkey, 'Wrong'));
-
-?>
---EXPECT--
-bool(true)
-bool(false)
+++ /dev/null
-<?php
-/**
- * @category Horde
- * @package Crypt
- */
-
-require 'PEAR.php';
-require 'Horde/String.php';
-require 'Horde/Util.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Crypt.php';
-
-$smime = Horde_Crypt::factory('Smime', array('temp' => Horde_Util::getTempDir()));
+++ /dev/null
-<?php
-/**
- * @category Horde
- * @package Crypt
- */
-
-if (!extension_loaded('openssl')) {
- echo 'skip No openssl support in PHP';
-}
+++ /dev/null
---TEST--
-Horde_Crypt_smime::getEmailFromKey() with subjectAltName
---SKIPIF--
-<?php
-echo "skip openssl_x509_parse() doesn't return subjectAltName of the example cert.";
-require 'smime_skipif.inc';
-?>
---FILE--
-<?php
-
-require 'smime.inc';
-$key = file_get_contents(dirname(__FILE__) . '/fixtures/smime_subjectAltName.pem');
-echo $smime->getEmailFromKey($key);
-
-?>
---EXPECT--
-test1@example.com