annotate vendor/pear/crypt_gpg/tests/DecryptAndVerifyTest.php @ 43:771f6803cc4b default tip

somehow lost the correctly updated metadata so e.g. 'mail' package wasn't being imported
author Charlie Root
date Sun, 26 Jan 2025 13:13:49 -0500
parents 1e000243b222
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 * Decrypt verify tests for the Crypt_GPG package.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 * These tests require the PHPUnit 3.6 or greater package to be installed.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 * PHPUnit is installable using PEAR. See the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 * {@link http://www.phpunit.de/manual/3.6/en/installation.html manual}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 * for detailed installation instructions.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 * To run these tests, use:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 * <code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 * $ phpunit DecryptAndVefifyTestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 * </code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 * LICENSE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 * This library is free software; you can redistribute it and/or modify
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 * it under the terms of the GNU Lesser General Public License as
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * published by the Free Software Foundation; either version 2.1 of the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 * License, or (at your option) any later version.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 * This library is distributed in the hope that it will be useful,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * Lesser General Public License for more details.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * You should have received a copy of the GNU Lesser General Public
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * License along with this library; if not, see
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 * <http://www.gnu.org/licenses/>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 * @copyright 2005-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 * @version $Id$
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 * Base test case.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 require_once 'TestCase.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 * Tests decrypt verify abilities of Crypt_GPG.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 * @copyright 2005-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 class DecryptAndVerifyTestCase extends Crypt_GPG_TestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 // string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 // {{{ testDecryptVerify()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 public function testDecryptVerify()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 $signature->setId('5dGf4//0CqBmlexYjyS7agt4Zn4');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 $signature->setCreationDate(1258956392);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
79 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
86 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
90
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91 // encrypted with first-keypair@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 // first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 // {{{ encrypted data no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 hQIOA5+T+RFnKO8SEAf+M1KnzLUvmJMtRTMpy3G2C8iJN1oQPznWDlL6NqxNeS6N
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 8ie5dXmaG9csQUx1Ys8QRaPDg6ElVIrJOXQ0CIW3mqxZS7+5X5akH5DQ0Ye4Rggx
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100 yqADpE2z99tlYiNlpEqtG4oAUXzJjWiw8Y6MFg/xAHQUYMhEhZRB4OaSQGVPpxYs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 s6YBfRGmWdNrGgPgcwoEmoHvmVKtVOfBNzO9cpl7k2pV12p6eG6jZ1qcCQkSJZlY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 z2WsnDYZ9wbXuLM4XanGiJiBau0f+nJqDozmOVvc5Avz1qrQD3Dd5C5cy/e+XPdn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 wzTgg3myMrwudAeJZzwMrpcrGwvdzAKE8/7TbNO+3Qf+NqfrApMVUrsFQBdzlLp9
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 7cV8nD0uF8ioQjPg0lzJajJdqjEkKB7h9i9fQgL/SBZ29HupsUqDoqmpCVU/B6M0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 YzphMp1qWDRkk5dmpcTppTBsVx1KXCqLQFBIy+Fhc31NZRs1ccaVF3uxaOyMzFhb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106 FaWlUq03SjU9SlkYiFwyfyDysK3uoGeLfFh5yhH6ly5kthwLo2ov/GANF3pL0cxv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 mGUcnZbkhk+MWjmz83loedhh2XpTLqRGuhzWPTQlOUQzf6xbj5zCkzWdnbqFQu19
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 Et5O3whgv+ufNvD5LGc/lGQeV8wV7EXcde0ISUa8LKyU+eseS+W6IHsQLPupkCQG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 u9KoAQUL3Q3vX1C7WmzS2sudcAulSR8bRYfr6lJ5udRvek7M7tYdLbE1ZLua23T8
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 NId1euFhWftuaFjGDRvY37ab+M+zTnMtogSZDkCVyFrM2n4/hFfX9eKX6ljPxPmk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 lEmn966i8e4K0jL0Ydvf7qWEVc5uov7xorYnkwvIbaW8SyUPowenfN3qODv7C0Yj
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112 0kOgiJnRxZq+MYOR1b1L6fS0y7jDPI+er8ft
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 =pycC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
124 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
125 // {{{ testDecryptVerifyNoPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 public function testDecryptVerifyNoPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 $signature->setId('0YWPoUQhN5G4uTi45QLy3GG3RWg');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 $signature->setCreationDate(1258956262);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 // encrypted with no-passphrase@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 // first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 // {{{ encrypted data no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 hQIOAyS/OAcAwUtPEAf+KCytTYgKglBxxU9jAr2i0WVXhBcfyVyFq0N4or4HGMSz
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 zBw3eXw/JI77PY4pBxtBDCzPgSox8T8abh6OU3LDu3Zy9kvKcbQxYCSOeJkPBDpK
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 OtJ2Sw7CJ7QIvoSyqmRmCjrji9OU3k9ulQQ/5GauAP4QnUnt6lNkz+FOWVl5wzqc
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 yjXkRgfmKNBzYVscgdH+YDEUTM+edN+NflzqLk8HLU98TmINbbVJwnPvpCCvRGh4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 SDDaF7WmiIjSqI15Bn7F/l+8ScxvC8EH6wxR9gqS+B9DlqVpjIoYa57SPXLcshvQ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 r02OjC8d8u2oyW9TLqnTirsf347Dzo7rRwm3GbdSrgf9FoQjymAzSx6izx9BsMg+
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 6XJV0jSHW+jDjiJRoMAYXKc/s/y8MWRo/irCTPjReLEHWvKmISXynXqxHy1Dw5SN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169 1VQAPIH1ftqEVZvGtA11vLPjPYenCRCkkwz8AHqLmqZt6V2A49zPen4+H+Tp/5xr
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 s7TQhygo9vmTTzniBqV4lYbOyshcUTVlUErba+ffivKQPNnM+oCZXyUbJTsMlGv+
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 elZqUKlNEBXivHnmIbwP/vpZ1WMMewCeij1/Z6OGbbT51dh9qeqPRj96dF351Lbk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 GPxLw5uP2bIzGQjGIBeKHrl2kkRxKk/MX6QPrMHR4KlUpPRfKcQLC0TGPTEPu6ya
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173 5tKoAdoBuKYNoFk2txsseRQTI/3v5pudNsdh5R/s+PMs+HpxyaFemI3eJb05E4Jx
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 zGJX5UiMIb/Yr0zCvlOaDx0NjPwIoUDqtZw6YqA59/BKmaRyqGoXk0UJMK2hAJKN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 yTrj0nUDWFgoKzLHu3EQtYffLUrrjVc6BB8pUmrZKBisGnXFBQvShkzdWmzUT655
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176 JQfVfeZmgq+UAsfqIlrWBfDcqfyvWeAAZ7qH
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 =1oh0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 // {{{ testDecryptVerifyKeyNotFoundException_decrypt()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 * @expectedException Crypt_GPG_KeyNotFoundException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 public function testDecryptVerifyKeyNotFoundException_decrypt()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 // was encrypted with missing-key@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 // first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 hQIOA82wFXJyxZnNEAgAwSoWLKDj/dyotGwYCT60IHC7vPGKbcbd9LMEQ8hOobKS
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 21aHeUBft9vlAnZabzPSqeQGYoD0BugONncV45HWlA3QD0KGcVuE6FaWIkexRNsK
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 S8MwVpcCgTuVkmSBgZbAS9jl7ODGGNdfGCb20fpgWFx8rv6q14aPUrD1bw5VVWeS
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 vLGuRGA+pcBwFlDTRvYtM0UnggfPMn6uH0CKI8uZsKkyHCu2zSCBLYsuo87sY6zJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 2UwEDyuYvr38HmcNZkb8vk7gpLCeJvFLeLYwpRrQcQy0Q+iElNPFXl5HzlwTNDq5
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 5IIiQNlaCV6vUKeX5VhU4i6h4yUWegVoIro4h7KwYQf8CxTrKUnI6WfDuvttU5Z7
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210 q+7WCTDEnmOT7C2AvOKyfNXlERQnDtY1LHjJe6AEyP2RHnTrHR6Nbi4zQfl4BSZX
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 hH+ojM/001ir5/m8cOaMpQzHnMyUIi1HenpjJFo5fsMYg+K7j88X4KWlu3YFeB+O
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 xAp/mf7qUiiTKeDdGJE0u3NkFmXz/G/QDp8zwpqG+/UpiEjMm4OdFMwP68l9FWRX
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 d1ql5Rfeb50HPIjcmoa1iHq0IJCbT2xXxCm7QyGRy5PwSTMsQnrDUvj6zIBhqusZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 CTHqBXBH3jsDKTBJGQNwOGA418kcEpRsHY+C53rPhoUDnjzBY7dzIstQFsCy1bPZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 qNKoAfFsNjinvrwexRqkDypYLxEKs/nrMM4q+yz8n6Q2BqPT6YvOciHAkE0k4I46
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 STZqsFTwWxgWmhLlEFvYul3BWEp5Ow5J6+6TZrHCDIFhoQIHesxmsWVxxlgTG+0M
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 TS1210ua1nkP+DdWQUBzdDHFxAWWG2pUxzApIPBD2wyeLd1HMVpOjQGpFxMuO8Pd
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 ZcGqhMpjECMzc4DOAPFbdKwgWKXi95v4zeUf
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 =Ze0h
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 // {{{ testDecryptVerifyKeyNotFoundException_verify()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232 * @expectedException Crypt_GPG_KeyNotFoundException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 public function testDecryptVerifyKeyNotFoundException_verify()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
237 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238 // was encrypted with first-keypair@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 // missing-key@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 Version: GnuPG v1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245 hQIOA5+T+RFnKO8SEAgAnQrKNrq6O4F0tlex+I5aklo7ElBbSPfa0k4SvX80m+n3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246 raM84mpnUzpoXrRa6zSM2IxzF7oWLHHAkBkWaTYdFFWegPbQk4G5rlURZDsLtamb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 y3tXcOMuSMhj3b9XrR2YzfREj0AnuEvYOsd++KpjcEYgcVZOb5tCn+9UKfjop/pZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248 i9sAJMYbdavxoa8DUuIMT6v0C/zNiuSFlQ23kRWB+LUR0tTIoHpb+0U0ITFLSMIr
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249 jc9K6Zz805Tbu6xX8UXRMIdfJTJkmVWTOD8u8OUPGBxhBuZmbVfH4x+fKybcSVJJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 akqX28LjaqI+WvD/zh9l78V7foMEWd7porUzBC7z+wgAzh3LBHb2naFg4CZSVlYa
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 uuQ64G1ct0uxwVr0p0/4jA5nEK+WgFABPu1YPnIO3md8dBnkfs92g+0msKgB3FOn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 T5+FlgkR+p2Y4knNggSmJGErCMYAq17lCu3bAlHFKwaowCBFoXrFCGBH2qgXD+CM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 Rgq5gWXPLrcqnGPefdV56i+8X+t7oHCzIxX836IQICWMpOdhWMzDz44ctC5IBTJp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254 bDgx2pmkU+i51Q+PfK7k8eBIvlrvBGCQcUiNjCoPKAM3OjGNAQF0JraWPG2q0OSM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 aZXKg9aCrQRHceCjwTf8dYRDm6yqGNeVzOnkDibPT3ySYmXKaVDbB8AquS72wE1n
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 ktLAxwGOjaM4MSQOGT+8eggngFidGak7957SWZRaqsXdeh6HtxKWni+XTBmWAg2m
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 6MnCIiVxD5A75m75ncdbRgtx2Sl9B/kCTC6Ak6hQ3iFpJKuQSZcD2gyGRSE8Ly7u
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258 cX4jPXcYQaWLi+wVpLaYr3hSsjx2WgVk4oz+X2Kt0qQw+yWIkRw7ErmMl0ML0L7j
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 YePAE6UbBSR131nDKmXDUlLsV4GavAclENL5Kp6Yd8ia3h1Jdtl0waH5cCLswhf3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 oi0u0bIalnZwDkFSDGiWgDQyJ8XgPFcUx8fp3dC8FVxXbd3quMxZU6/5K/dQ0LIh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 +Ldlz797sLtl1lHmlaLEzTzJZriLiEiOCZeOrhbgqcGMLurzfsCWYH+BZFzH8iFJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 yDoUVsWLlvY+6gelAE9Dlzdq9m8rIALwf0Udlsdn/NBaFxarT0nl68u5fSJo8UA2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 MuZd2EB/BKXWvAo5Ea9CQ3DrrDkbwlE3PKrWlMos6dFb/SWxtmKfEeNYhYJsbwsv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264 x5MBl/I2kBCHeH4=
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 =hojs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
273 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
274
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276 // {{{ testDecryptVerifyKeyNotFoundException_both()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 * @expectedException Crypt_GPG_KeyNotFoundException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283 public function testDecryptVerifyKeyNotFoundException_both()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 // was encrypted and signed with missing-key@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
290
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
291 hQIOA82wFXJyxZnNEAgA0oz13vLInSM0GlhLyIQ5fRXlttY6jOO6xgUH3MhCqExN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292 KWLBp9VE+iAzdsnF8hjP+u48qNjYj7Jvyiu8vf1SD9ScYoEiKar0EhZVLfCxX7PC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293 4ZWCSEWD5h5nBSabdL00f3vL//GrQtMAwcKP4p+pEyxTEoSg7xp10+F0JqnhlIqh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 vsOeP4vAeYi1v7x0UyoNxzHbfGb3gjwNaWEixBPMekoEnZ8SOORL5yrOctOjcFxz
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295 hKQFIcJv5vG/Ozs6Wm5q+uvzkZDc2X2dOnb1SpCP5cxNC0g37CiwPIL8ArBcu+yP
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 5HSC8YhyyVcQTuIdb0a9t/IK0HNfEOF5gCBCQ462Xwf/X3PQgKvvK76DQ8xvukB8
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 6yKwaHv2K8NWFyTuPppiiRztVI13zPt/Jjw/YPNE/qUzONiggqWM0tGtVkbNRzic
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 dMEaAfwmZSix0alMPnDuVNyq9AnCUEjkXKTByWDL4pejvB541dA+rtU1D8pV1/8X
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 P+oQ+j1EnJitYSTdsnD4YC88/q2RnQTmibmyMclVVk3el6OvZN0Gj0Y2bd9c4LC+
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300 1reFYZHrX0FcsGIVuHEK/VikTqoWhFOTYUFXFGSE/AGvotfHj2QG3sd297IaSbVi
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 C1LwWGvpdZ2yw4RV4Zgrqvg8WOL9maj/mX8aE9/gzs9XH2vuucDBOC0RrQPsM6wb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 ANKoAdExlp+92b69YSNjP2bRQFjN3gFKaGfBm4ULUhRTFnlfBGIIa+2KHUNB7dYk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 obUon363/o/8wdmlXewIwPLK8nQsYXhAyxJcf9o90tqv1L83ZMMLU7FqBkUCmT4a
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 9EPXbxnaeO3sa8ZuGm0ilGuIFsK24pBOXtYESZ4ix6y7PZOXCJDun4+dFKcfMG+0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 t8TnSlDaIKEuve9kUGwmO8Z3LsYJEsRCsHyN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 =YNhC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
314
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 // {{{ testDecryptVerifyKeyNotFoundVerifyIgnoreErrors()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 public function testDecryptVerifyKeyNotFoundIgnoreVerifyErrors()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 $signature->setKeyId('8E3D36B1EA5AC75E');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
329 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 // was encrypted with first-keypair@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 // missing-key@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336 Version: GnuPG v1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 hQIOA5+T+RFnKO8SEAgAnQrKNrq6O4F0tlex+I5aklo7ElBbSPfa0k4SvX80m+n3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339 raM84mpnUzpoXrRa6zSM2IxzF7oWLHHAkBkWaTYdFFWegPbQk4G5rlURZDsLtamb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 y3tXcOMuSMhj3b9XrR2YzfREj0AnuEvYOsd++KpjcEYgcVZOb5tCn+9UKfjop/pZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 i9sAJMYbdavxoa8DUuIMT6v0C/zNiuSFlQ23kRWB+LUR0tTIoHpb+0U0ITFLSMIr
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 jc9K6Zz805Tbu6xX8UXRMIdfJTJkmVWTOD8u8OUPGBxhBuZmbVfH4x+fKybcSVJJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 akqX28LjaqI+WvD/zh9l78V7foMEWd7porUzBC7z+wgAzh3LBHb2naFg4CZSVlYa
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344 uuQ64G1ct0uxwVr0p0/4jA5nEK+WgFABPu1YPnIO3md8dBnkfs92g+0msKgB3FOn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 T5+FlgkR+p2Y4knNggSmJGErCMYAq17lCu3bAlHFKwaowCBFoXrFCGBH2qgXD+CM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 Rgq5gWXPLrcqnGPefdV56i+8X+t7oHCzIxX836IQICWMpOdhWMzDz44ctC5IBTJp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 bDgx2pmkU+i51Q+PfK7k8eBIvlrvBGCQcUiNjCoPKAM3OjGNAQF0JraWPG2q0OSM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 aZXKg9aCrQRHceCjwTf8dYRDm6yqGNeVzOnkDibPT3ySYmXKaVDbB8AquS72wE1n
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 ktLAxwGOjaM4MSQOGT+8eggngFidGak7957SWZRaqsXdeh6HtxKWni+XTBmWAg2m
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 6MnCIiVxD5A75m75ncdbRgtx2Sl9B/kCTC6Ak6hQ3iFpJKuQSZcD2gyGRSE8Ly7u
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 cX4jPXcYQaWLi+wVpLaYr3hSsjx2WgVk4oz+X2Kt0qQw+yWIkRw7ErmMl0ML0L7j
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 YePAE6UbBSR131nDKmXDUlLsV4GavAclENL5Kp6Yd8ia3h1Jdtl0waH5cCLswhf3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 oi0u0bIalnZwDkFSDGiWgDQyJ8XgPFcUx8fp3dC8FVxXbd3quMxZU6/5K/dQ0LIh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 +Ldlz797sLtl1lHmlaLEzTzJZriLiEiOCZeOrhbgqcGMLurzfsCWYH+BZFzH8iFJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 yDoUVsWLlvY+6gelAE9Dlzdq9m8rIALwf0Udlsdn/NBaFxarT0nl68u5fSJo8UA2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 MuZd2EB/BKXWvAo5Ea9CQ3DrrDkbwlE3PKrWlMos6dFb/SWxtmKfEeNYhYJsbwsv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 x5MBl/I2kBCHeH4=
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 =hojs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
360
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364 $this->gpg = new Crypt_GPG(array_merge(array('ignoreVerifyKeyErrors' => true) + $this->getOptions()));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 $results = $this->gpg->decryptAndVerify($encryptedData, true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 // {{{ testDecryptVerifyNoDataException_invalid()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376 * @expectedException Crypt_GPG_NoDataException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
377 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
378 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
379 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
380 public function testDecryptVerifyNoDataException_invalid()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 $encryptedData = 'Invalid OpenPGP data.';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387 // {{{ testDecryptVerifyNoDataException_empty()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
388
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390 * @expectedException Crypt_GPG_NoDataException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
393 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
394 public function testDecryptVerifyNoDataException_empty()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 $encryptedData = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
398 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
399
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
400 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 // {{{ testDecryptVerifyBadPassphraseException_missing()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 * @expectedException Crypt_GPG_BadPassphraseException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
405 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
406 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
407 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
408 public function testDecryptVerifyBadPassphraseException_missing()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 // encrypted with first-keypair@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 // first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 // {{{ encrypted data no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
413 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
414 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 hQIOA5+T+RFnKO8SEAf+M1KnzLUvmJMtRTMpy3G2C8iJN1oQPznWDlL6NqxNeS6N
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418 8ie5dXmaG9csQUx1Ys8QRaPDg6ElVIrJOXQ0CIW3mqxZS7+5X5akH5DQ0Ye4Rggx
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 yqADpE2z99tlYiNlpEqtG4oAUXzJjWiw8Y6MFg/xAHQUYMhEhZRB4OaSQGVPpxYs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420 s6YBfRGmWdNrGgPgcwoEmoHvmVKtVOfBNzO9cpl7k2pV12p6eG6jZ1qcCQkSJZlY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
421 z2WsnDYZ9wbXuLM4XanGiJiBau0f+nJqDozmOVvc5Avz1qrQD3Dd5C5cy/e+XPdn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422 wzTgg3myMrwudAeJZzwMrpcrGwvdzAKE8/7TbNO+3Qf+NqfrApMVUrsFQBdzlLp9
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 7cV8nD0uF8ioQjPg0lzJajJdqjEkKB7h9i9fQgL/SBZ29HupsUqDoqmpCVU/B6M0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 YzphMp1qWDRkk5dmpcTppTBsVx1KXCqLQFBIy+Fhc31NZRs1ccaVF3uxaOyMzFhb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 FaWlUq03SjU9SlkYiFwyfyDysK3uoGeLfFh5yhH6ly5kthwLo2ov/GANF3pL0cxv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 mGUcnZbkhk+MWjmz83loedhh2XpTLqRGuhzWPTQlOUQzf6xbj5zCkzWdnbqFQu19
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427 Et5O3whgv+ufNvD5LGc/lGQeV8wV7EXcde0ISUa8LKyU+eseS+W6IHsQLPupkCQG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428 u9KoAQUL3Q3vX1C7WmzS2sudcAulSR8bRYfr6lJ5udRvek7M7tYdLbE1ZLua23T8
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 NId1euFhWftuaFjGDRvY37ab+M+zTnMtogSZDkCVyFrM2n4/hFfX9eKX6ljPxPmk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 lEmn966i8e4K0jL0Ydvf7qWEVc5uov7xorYnkwvIbaW8SyUPowenfN3qODv7C0Yj
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431 0kOgiJnRxZq+MYOR1b1L6fS0y7jDPI+er8ft
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
432 =pycC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 // {{{ testDecryptVerifyBadPassphraseException_bad()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
443
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
444 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 * @expectedException Crypt_GPG_BadPassphraseException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
448 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
449 public function testDecryptVerifyBadPassphraseException_bad()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
450 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
451 // encrypted with first-keypair@example.com, signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452 // first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 // {{{ encrypted data no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 hQIOA5+T+RFnKO8SEAf+M1KnzLUvmJMtRTMpy3G2C8iJN1oQPznWDlL6NqxNeS6N
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459 8ie5dXmaG9csQUx1Ys8QRaPDg6ElVIrJOXQ0CIW3mqxZS7+5X5akH5DQ0Ye4Rggx
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 yqADpE2z99tlYiNlpEqtG4oAUXzJjWiw8Y6MFg/xAHQUYMhEhZRB4OaSQGVPpxYs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 s6YBfRGmWdNrGgPgcwoEmoHvmVKtVOfBNzO9cpl7k2pV12p6eG6jZ1qcCQkSJZlY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 z2WsnDYZ9wbXuLM4XanGiJiBau0f+nJqDozmOVvc5Avz1qrQD3Dd5C5cy/e+XPdn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 wzTgg3myMrwudAeJZzwMrpcrGwvdzAKE8/7TbNO+3Qf+NqfrApMVUrsFQBdzlLp9
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464 7cV8nD0uF8ioQjPg0lzJajJdqjEkKB7h9i9fQgL/SBZ29HupsUqDoqmpCVU/B6M0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 YzphMp1qWDRkk5dmpcTppTBsVx1KXCqLQFBIy+Fhc31NZRs1ccaVF3uxaOyMzFhb
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 FaWlUq03SjU9SlkYiFwyfyDysK3uoGeLfFh5yhH6ly5kthwLo2ov/GANF3pL0cxv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 mGUcnZbkhk+MWjmz83loedhh2XpTLqRGuhzWPTQlOUQzf6xbj5zCkzWdnbqFQu19
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468 Et5O3whgv+ufNvD5LGc/lGQeV8wV7EXcde0ISUa8LKyU+eseS+W6IHsQLPupkCQG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 u9KoAQUL3Q3vX1C7WmzS2sudcAulSR8bRYfr6lJ5udRvek7M7tYdLbE1ZLua23T8
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 NId1euFhWftuaFjGDRvY37ab+M+zTnMtogSZDkCVyFrM2n4/hFfX9eKX6ljPxPmk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 lEmn966i8e4K0jL0Ydvf7qWEVc5uov7xorYnkwvIbaW8SyUPowenfN3qODv7C0Yj
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 0kOgiJnRxZq+MYOR1b1L6fS0y7jDPI+er8ft
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473 =pycC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479 $this->gpg->addDecryptKey('first-keypair@example.com', 'incorrect');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
481 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 // {{{ testDecryptVerifyDual()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
487 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
488 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
489 public function testDecryptVerifyDual()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493 $signature->setId('TAsI7RYUgZAud0wMZu3Iab3bZXo');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 $signature->setCreationDate(1258955651);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
508
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
509 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 // encrypted with both first-keypair@example.com and
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515 // second-keypair@example.com, signed with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 // {{{ dual encrypted, signed data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 hQIOA5+T+RFnKO8SEAgA2lVokiF7FeQvT0EjgH/X2mXNbz8ukKM7WdIAsIFumg1a
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 Skfsqn1plAHs3f3OhY16tBb1WW4J8WXEt6g3yHls92XpRUgRTUjVCr4HIvMwSB3A
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 V/ZQdGs3NK3wh0rMu6q/Ski10dEwP7SUE+w19AmiCQfmKYLUJmCgPLmVm4IapAad
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 lIpNalUHzXhHuuIzKut9H0n6+p0jUPW2JehFFGud66MS5PaGbDPZS2lKiPjytSzl
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 pYipuglregaaMR5KsBYxP4A6MnMaRaZriTeItROJ0PTBMaq93+IyrnwulqEsWk6t
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 8ahRM4FmC+U/Z9tgWxTEKU28zthjxKXW5JOceGxeBQgAoxRAhd75Ok406YG4VucC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 rxLSLIKIt0TAlbTWncJq9qhLA86+RL4oqUYfDjq9o9lrfkPQO3xfHam/43j2yaF3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528 HeJwSDwU0V4YZ6R9ZVdHMYw7w7yynn2HmNesDUWRfI7IRwMFtgKGvv6qpdUOYmWN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529 MhQ+HxnwMgvHNaz6TRYpQzVvtpB6q9J3/xCM3+uKxDaJLbJux50s6FpnCRnLpGWs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 1Tj8l9BSMlAGtP6dMR3MysZS/UnXwdTmDFR9ARS+HxsP89I95UAKLWaouShoo9dX
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531 QIs0pLkQs+CWpjPVAp8TT0Vj1juThk4bJarti/BaZOyzUAOrleDWOO8VVsuM1Bw2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 xIUCDgOy9U5HV+IkUBAIANU8DKkvHNzkx68XvxXXVsBsWTGNznrNGUjqSfhyS9pW
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533 lRnq7qB2c2UgMvMTnMWyogQ/gKEotdeqKCXdMLBkataB1xkMbCvUZzdj2A/OPtDD
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 xT7ogqn82YaEjlfEqEbqBi1lvq2tuC/YsGti0c6zDUFoZax6QWL+NU3eCY6ZxBSx
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 NuZ4hiBJqPeHVP92SCnsC2BwqUy7W0rUuKnXo3VM1syd98TZjdM6SqBVQ61YX3u2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 rS1YiphYd2WeNU/bSZ79bHMMPt3joQ+nCGKvGSIlCVxAy4EPWDb2KFw0yUmXUub1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 tLnrKAOdufWC780LuhgINLb1PSmzogRmvk4ih687h9wH/0hx4olXvkUHZAcpnMHT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 zGK8NQeoxfSmcJrYNa1TpQ8FjLad7eycnoIASC4qS7IsJ0xzedWd2eqLdc+9qIiv
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 68gW2MjZOqQ5PvcZk1eqOVUNH8Ua8Wfv82ljk1VE0L9zzrS8nGLq5prjaK400Vwh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 MVh129jyjkpgGZhIHC4cNGBQl1zKDw9WWd1Rk92rpmsvb7JZVNDg0DjW3hrwc7v2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 WbGqEXG5Sown6J1gX4wKIpn9roOE9ZSu1hvugPc28IZIne4rL05Pd4qVnp87SiUh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 wHs82nXGhqcscZx2NiT2F///6j97+ccd+619iabKkpfwGunQZHfxit+7bfHuX+5O
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543 tFHSqQEsRi3gNrRlMRDnPjLHXjR+x80anNOwxBfZP1qjdTsFucqmZ57KUdIpUGmi
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 uRgBZhuVRz8ryTcw5/nACkeKLkxOJLHGgNDilJtNO8tv+BbQDRZzsNYTM7ZNcAo4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 JqkWrMb43BTbAbdgTyEkWhqw6cFQEePYqXcbeDh3c77U5joGZW+iPZQlJbBCMC6e
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 KBH+5iH8NzPpP6yZq5e5p1ZOkb2PY3EXtL8aemU=
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 =S/2J
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553 // decrypt with first key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559 // decrypt with second key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
560 $this->gpg->addDecryptKey('second-keypair@example.com', 'test2');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
561 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567 // {{{ testDecryptVerifyDualOnePassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
568
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
569 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 public function testDecryptVerifyDualOnePassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
576 $signature->setId('3OJnX+PqHI0YUCeFxICCxhPHY1Q');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
577 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
579
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
580 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
581 $signature->setCreationDate(1258955916);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
586 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
587 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
590 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
591
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
592 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
593 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
594 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 // encrypted with both first-keypair@example.com and
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598 // no-passhprase@example.com, signed with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 // {{{ dual encrypted, signed data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
603
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
604 hQIOA5+T+RFnKO8SEAgA7zHd9KH/C2GCM9H7pdMS76PXGfmhGPyQAtokBQgF8G1/
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605 orldCnTUnxmZejbOwYhYVEh5zlnYshlCpUSsGBw+sH7XiC8eorCD0YJj5NDBp8W6
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 VtvGkMqqG9tDJk6TfKornFl+H7xpiwXox5T/swnpJcJ6qaTXBtLb7HViiwTTu5Zk
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
607 QbWqSvIOigIkiuTnv898/eeEIh9gg6ScRVZOyZ7P2usDaOWqVVNJmkaLIaWxOYck
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
608 Go3hnYAhkfjpMcgAMkqtXPWIS8OrfY8wOXxXNA4EjvrHs+5/yHbZmj/5bBA9CuGJ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
609 UctQqF9ZtZsagSpK0WTJCt4RkX3jKqK9tJVQzBuKZgf/Up3Zi6Lfg6iINm4qsd1h
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
610 Dusuuxw0vgGoMc6P7QOMFmeSs3g/yYQKaHomWqEVg0LpC2FHOqceqZRZJd4XMcsz
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
611 uCF95lx7Tm1ozgEhBgQNSQVoAA5/MYXlKo3YQGEIyU9Gx4f2v/8XV3umYXjGfJY9
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
612 adBHLIvPFeeze1/f11ztZsgLr3DBP01/O6qLi91dwsqpzQXzjurVYIHJdCD+JviZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
613 2CjwkcpUTHx5vXNiobMcBjtogjP7d4W8DJ0La5+WVujV0nxHiE9mEXuct8TajCY6
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
614 /40UIdtHEPWc08ccXXjQaFKbJxYGDMOJzQ8LPdHqa3RubmMADqzH4W3/SSmRsibd
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
615 4YUCDgMkvzgHAMFLTxAH/R3ryj2BUP6C/aYfgGqi+FOVoHVR5kiz6Z2nBEKqntwZ
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
616 njdKD+pvuw9fxaNhNNZy3UlKnIdonNb/A3upEeR81opP+HWCgXUlcgucQ7VXiUPd
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
617 mnQAR+cTrFgTXf+B54VHwDED5RVDm4/e29casiNyULm6xWFYqfJMGBvEGrflq1BW
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
618 QSYlpc0ijqkER+VNy49Dy/qY1TRUBZ84+RmL2L/18zQbdekMoLUDxJOEoo0C65ER
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
619 5ReLlFN2nI0MC8O5ZU8PfjDXXQ7qnQhz/2kxorNiQl654V7ZsEWkVLF9yejZXSzU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
620 ynWANJdCnWLMjOnrQPm1+b2Yi8pcgtpIPsBdTIHn4fAH/iW0Uxltx9ZrV7kvrDDj
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
621 Izc4/ocn3Z0c/47Rv62MTYcxVYzFdP+WxisMI2LV88g1Zu9rOKR1k7UkNGNlfklS
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
622 5CSApTnm3MC9/w54dacPohZ7SrQlTSHJxfRINH7H3DOuaH9awf+ntwUks73mXjT5
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
623 ikSJ2D05Kbf8++jLhRRKLPZS8bOmSw2KTaCbtk7LX4pEIu9d6kig6g8Wj3h9dlQs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
624 QXCKL14/8cSGrxXXWHOuL9abnxZTwenbn5B5FqBPoiRKqSFToiLd/pBWjG/aieju
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
625 Rm+Uyyddl+ISJUnv0AAiOxfifJmTdUsT5LZLkYG4CUyX2T3JiZ2L4msF4S3U70wp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
626 PtbSqAG3xVRFlZY2jLeW8btez7XkzB9fhvVd1Hee6EXRnF5/BcLkqy8sYvx1MHkT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
627 eMzttOs1NRrjXy4+zUqo//59gQ46zwYd0NA/Ga6pl1kn8+xM76DCcI4LhdZN75rR
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
628 ZUcyEqBKX9RNefMD7cR6kYoljGfnT3Mjd+0eTdF/Glk0ElVjbMtQclG0o/7wlI7m
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
629 +b2E6/e0qZedOCq48+mIRv0tjRuoFiydM88aGg==
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
630 =IgJ0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
631 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
632
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
633 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
634 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
635
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
636 // decrypt with no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
637 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
638 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
639
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
640 // decrypt with first key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
641 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
642 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
643 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
644 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
645 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
646
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
647 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
648 // {{{ testDecryptAndVerifyDualNoPassphraseKeyMissing()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
649
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
650 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
651 * @expectedException Crypt_GPG_BadPassphraseException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
652 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
653 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
654 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
655 public function testDecryptAndVerifyDualNoPassphraseKeyMissing()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
656 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
657 // encrypted with both first-keypair@example.com and
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
658 // second-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
659 // {{{ dual encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
660 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
661 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
662 Version: GnuPG v1.4.6 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
663
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
664 hQIOA5+T+RFnKO8SEAf7BO/zLK6gDt5epMOEnHc9ESdSTy8yExdoSxHhvTFxWfwi
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
665 AwMtBEur8sotSVt+Q87xYzjzE77+FQYS9oYCivlK/Nedblj3MiRuUWhM+Q9tbP3b
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
666 KbwEwaQlrpNphQsKZOWkliZWmFJWnQ1s1Pm6lPlhwTNhcwkapm8EXuWFExJnY9yW
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
667 EZjUOhVmnkitKykKup8Brvfm2QpGXoFZtHFKXTi162Lue9N0tDm6s3JnCIhMFQgI
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
668 fyAikcsJKpbUgeGmzlWJO8QkH81QMuKpqfUb8R1dswhDp6RKXhoXS43zkhH8QSbM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
669 Cp9AWdv3qsWBUqzWavCxjtIsogYO+gFLl/Vuw5Y87Af/b7OQgLP1v6xKZcrTvFCF
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
670 hxGxn+5M8E2GyJaKpQ1GZ+Wv+IzPGetm7rWf6q71hchAkxFMczIPSK7aARm9CNVo
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
671 7tCdcUmUTgLhG1/0OfmkbwJUjdSpOtz8+TvIZa20Jj9a1G8WT3KTeivKMqBPhgk4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
672 sD7OJPDCYQNSQEw6pAn4oBrhJlDUkpCK6wIbUhzeq3MUwtM1e+qpCr/k4In4NVq6
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
673 cmoC7W//9J69ecuxmiUHRhZ4CALRxQMAsSxMRnNJ26JY4ko82Rfvbrz8QEmKcIyT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
674 bTdAMsZ18m9XXrnc2ACDDMQyUkneQDUZSt7V67ZiN4Upi295CynIbNEMmcH/13Aa
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
675 aoUCDgOy9U5HV+IkUBAIALGICOFzyfquWZ0ZhPGVdDWx1yNcApnzIgZx1JbBpMyc
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
676 2jb9aQHwGId26gv/ym/M/3FJ0lv+IAcktMjO4dwYLnUuBa6BOFFybZi3gYvXtSuy
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
677 iW4ygVjIsYixhvbsyaVCoB/MsNBFrQAHEShaxALBkI/dv+yyD8BifU4Yj9LFcAZO
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
678 mFDraOgYfHsur5eevYTXozf5wU7phu9v6zo5bk8zgZSqs8AgyscstZWCqCtR/cG0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
679 t9lAIovGPsIcA12qvkm/A0WiBMEWhGryzHTv9oRsFztOFtqH+MmLdlvWjElw8hKt
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
680 fFJB+bhHNO9BUIrwnuH79cA4aXOy1+xG+ECs7oJbcisIANqJKalQLgBYEjbucpDg
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
681 O8i/c4RmV9J7VczpZp7ZREMpTmv9nV849OFXT1strsb/+vXOXOyLToG1gOxRfJr2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
682 q9jFjpyMAtrr/aHhXMKK1OMhhcdkQMEKuHTvon5KleZOQoVmIqa3kUtWNW1vFBIP
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
683 UfJFH202EJLOLC25rXCtzRsJE0HWiYDyLqKMQcSQhTcngLBLmeDLH3DeGUIDwcZe
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
684 oWgUg8wB/oSoU4AchShzO+yM6bcmffcaHFqwll9gdu9walnJAAOb8+r6LGGlsGTV
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
685 qhnR0LM3Khp+HOFdaxcQT6BV1aw/D6Z5hIi+Am0VTi0HlFr/gwleyYaP+742Z6K0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
686 s8bSVgFT2Pjik+byARWzRwWjmi0jT7QsgITM73aBKPDXiArEPkv8YtC9HzUj0lCY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
687 gX7Eg2ZqISULFydBckMJ6drojMMQiqZBeEc09GupSBL1zldnKHfiXBTw
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
688 =QYjj
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
689 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
690
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
691 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
692 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
693
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
694 // #21148: Make sure that proper exception is thrown
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
695 // when decrypting without specyfying a passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
696
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
697 // in this case we remove one of private keys to make
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
698 // sure proper exception is thrown also in this case
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
699 $this->gpg->deletePrivateKey('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
700
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
701 $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
702 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
703
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
704 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
705 // {{{ testDecryptVerifyDualSignatories()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
706
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
707 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
708 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
709 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
710 public function testDecryptVerifyDualSignatories()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
711 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
712 // {{{ signature1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
713 $signature1 = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
714 $signature1->setId('7PujVkx4qk28IejcD6BirrwBmRE');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
715 $signature1->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
716 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
717
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
718 $signature1->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
719 $signature1->setCreationDate(1258956025);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
720 $signature1->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
721 $signature1->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
722
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
723 $userId1 = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
724 $userId1->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
725 $userId1->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
726 $userId1->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
727 $signature1->setUserId($userId1);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
728 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
729 // {{{ signature2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
730 $signature2 = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
731 $signature2->setId('AhrDdkdcBsEsOSQOYENhl5C7auc');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
732 $signature2->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
733 '880922DBEA733E906693E4A903CC890AFA1DAD4B');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
734
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
735 $signature2->setKeyId('03CC890AFA1DAD4B');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
736 $signature2->setCreationDate(1258956025);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
737 $signature2->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
738 $signature2->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
739
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
740 $userId2 = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
741 $userId2->setName('Second Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
742 $userId2->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
743 $userId2->setEmail('second-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
744 $signature2->setUserId($userId2);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
745 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
746
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
747 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
748 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
749 'signatures' => array($signature1, $signature2)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
750 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
751
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
752 // encrypted with first-keypair@example.com and signed with
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
753 // first-keypair@example.com and second-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
754 // {{{ encrypted, dual signed data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
755 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
756 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
757 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
758
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
759 hQIOA5+T+RFnKO8SEAgAzllqH/z2ThJcXteCxPJu97EmMpqdipbcSUAjGZJ5hQFe
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
760 YlKbrxL30W6VYgZIPqP5FubZkI8WHWqDZwbtphk5l+o8nfyNV4el/JHHEmf/mzIM
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
761 UmBXJFVa6g9CmS/SdhYhO/ovMeBsNVA1+Er+Cdyh9sTpX89I3zlehgwcXtv/di6W
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
762 fjzeg5Na/39KfYWEyXPB5EUkWG4hmnGo63GPUEsxfNXbKDafUtTwOFop+1+wMVyA
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
763 kJbOEaaiTSzvbpa+ruRisv34a6vX8u6QGqPSZ43vgmKeWfPEBS8p7bdRFGECLNvP
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
764 gK4tIwlBI0o13JJ/lnjL6dR2f7qls/0dxBGxhjFpjAf/bn5d8r7e2N1yJqh1C5T0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
765 /n/ngN1bHDsQhrAPMJfJre7qJxZEiHa8dfagdDU6I/EC4w1ouUYKWrzf9sPKTxs+
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
766 QosiqrGKYUO1V46EzRXc72PZBKf5CZBBvRZv3GzzcVtroViiIshyAp3TBPk2GC+N
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
767 ilmEm72CWgQHKqg4vX1hbTCbOEu/YDmjF9Vb9a/zT5RAKDjBrcc9tkPdVMfDfI2Y
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
768 Ly6CvL2DSvBUNbAShl2TXdTdylYbopyiFhOBvJoeidFVwIFX303nFUBMUfbCT6WK
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
769 MGZGzXrNZlRyKfH9UCj+5pxom2TMpu+URfvXtByUGfNst+ZRi+ADOnbc51canwWc
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
770 M9LAKgG6SF2OhrDTTe+KASz3dFbpD4xnczl+686GGT76W55YKQNDff72bhx8lBnP
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
771 XiM+CsWGPLZdoOCQU+SEWD7lJ1I6fB+l/oFWC2PVlDjrCS1Nn/L9i5p+EqNzcUVB
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
772 JR62EaLPsOFOfNeHhltuz2aYkvQT4sDPeKkpBKJDp2ejMy3V9ZXia1D2ZTCfMp+J
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
773 GEu2SS68qlZV12gpSwY8BpS/nirx5aUQ9VhjlSN3GHF/r6j91VsHJhmU+nmWPWaF
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
774 mHfMGHS5sw6+gz3SyW6b4TlUnnx412nhFinanxBlwkuAcukgL8k+OesoDX2a1Q==
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
775 =TW+z
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
776 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
777
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
778 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
779 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
780
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
781 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
782 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
783 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
784 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
785
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
786 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
787 // {{{ testDecryptVerifySignedOnly()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
788
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
789 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
790 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
791 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
792 public function testDecryptVerifySignedOnly()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
793 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
794 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
795 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
796 $signature->setId('LS9EdhGLaEUllGk3Snc0Bk+Cn3E');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
797 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
798 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
799
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
800 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
801 $signature->setCreationDate(1258956761);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
802 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
803 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
804
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
805 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
806 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
807 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
808 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
809 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
810 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
811
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
812 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
813 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
814 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
815 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
816
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
817 // signed with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
818 // {{{ signed data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
819 $signedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
820 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
821 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
822
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
823 owGbwMvMwCR4YPrNN1MOJCcznlZMYvDmUr/pkZqTk6+j4JiTmZyqqOCen5+SVJmq
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
824 o+CUn6TY4cbCIMjEwMbKBFLIwMUpANNttphhwWm3a/VsLcc+u0x4/Xtyuk/Xiqd3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
825 ZzMsuHZrvkPCHgUTgcXFLt6GVRlPYvT5AQ==
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
826 =ehgC
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
827 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
828
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
829 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
830 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
831
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
832 $results = $this->gpg->decryptAndVerify($signedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
833 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
834 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
835
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
836 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
837 // {{{ testDecryptVerifyFirstSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
838
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
839 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
840 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
841 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
842 public function testDecryptVerifyFirstSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
843 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
844 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
845 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
846 $signature->setId('YUeHL9fEAK4hMokvXsNgUP5vaJ8');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
847 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
848 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
849
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
850 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
851 $signature->setCreationDate(1267228319);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
852 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
853 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
854
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
855 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
856 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
857 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
858 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
859 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
860 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
861
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
862 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
863 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
864 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
865 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
866
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
867 // encrypted with first subkey (ELG-E) of multiple-subkeys@example.com,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
868 // signed with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
869 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
870 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
871 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
872 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
873
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
874 hQEMAykh4NP/Ww9KAQgAhB2Ww2jNhy9ISQ/+S52eROzbN8ij65GoL9tTHK5TZp82
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
875 mv+ieGwobe5PGYdBEvQdsSrKyF3x25oaEyjaOa+39DtmF82OZKZ3tIO3EJ1qvn8q
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
876 SHxwiKYa4MOgwER9pT7i/YZOZuIdII/NeuVuGxbsa5qdISltKkE7WS7yWStcDJi1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
877 goaPx3G1cZIVnTgSncK1YE4j2TZXBxI/zuuuH0pbZk7rK+K9zIeyYD1YZFagrjJh
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
878 REN5QbnT1v+1HXno1WRp4Obo072i3FjF505U1XLQ5p2/d55m73jfBJoqpb2NExdU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
879 KimXnQZ+8/8ddzL3ZP4+g982dmLFvl2/h7KGtPOMbdKoAeMQYVolMDoQp6+nyQHP
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
880 CgpeFJY5+VnxNq1wEgJgXTo79xohN59wwad1ltcUGAVC49RMHbX+xBjR/HPCG9yt
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
881 QTwMes514uPYbNL6cGoKm7dt/zQL8YsjvfswGE06bj/rU3JCTDnR+iOUDHzUMDEn
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
882 jH7Vbs+9D1E9t5bSJs/8e7rzhZKF1AhunUdDmc4vPPJMV8xKF+o3h3nKQ6wEoOMz
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
883 f6XGFW8cvNAl
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
884 =vSGT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
885 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
886
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
887 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
888 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
889
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
890 $this->gpg->addDecryptKey('multiple-subkeys@example.com', 'test');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
891 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
892 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
893 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
894
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
895 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
896 // {{{ testDecryptVerifySecondSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
897
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
898 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
899 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
900 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
901 public function testDecryptVerifySecondSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
902 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
903 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
904 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
905 $signature->setId('ZLZFDxxO+zdCEklUu6eppBCPCsA');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
906 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
907 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
908
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
909 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
910 $signature->setCreationDate(1267229043);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
911 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
912 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
913
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
914 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
915 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
916 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
917 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
918 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
919 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
920
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
921 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
922 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
923 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
924 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
925
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
926 // encrypted with second subkey (RSA) of multiple-subkeys@example.com,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
927 // signed with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
928 // {{{ encrypted data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
929 $encryptedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
930 -----BEGIN PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
931 Version: GnuPG v1.4.9 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
932
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
933 hQEMAykh4NP/Ww9KAQgAs1xviSlaTTGXWNzT43giUSf7SnYoeoyYqZt/eo7c9eHu
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
934 sLGdhhpQeUiU5vW6UsOvs3QLx3hR9wYunUOKmDJmrrtVglsZIjuHU7oYlveozYwG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
935 wlHNbesQlWyMNSQPDeGWAQAnOUU2jv/9nb93SLYlkDKr1qjn9qjZ4Kl2q1Yi4PSu
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
936 LaqI3r1LdJbFmEB6vQ8o6GiIpaFaZapK6vloPoq5xbaALAfAiSg58+IwV/Mn190L
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
937 T0tmFCUuTm/Px8fv5xe+mPW2pMUovhJhBrhBopEcWNHpxuNbxwac1T54COZxjC8W
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
938 L0XpYW7c3XVdO6VqS4pSnz+zo5EYcU2Sk6mfpN5ki9KoAdPZ4ICMe0OWIjMxgApI
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
939 AVHaKowZ6+xSW8vLRzWjJTZrlEoMjwJSOJwCsMcsu6MwJOFcVEl4Mc3TiAMsUHWf
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
940 6f/pHb7W2Am12CfJaaU0+nDQrlKOw5DfQG5YEG/LrpjXGugVWMQH/31MMKawSAP3
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
941 QgdXe417ZeMtsHVaz/W1Za5ZpRpcwoT5N31LfNV+SoIpajhmtr79aeg8d6OH8H+l
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
942 7kLEDVlh9DP0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
943 =I21n
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
944 -----END PGP MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
945
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
946 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
947 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
948
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
949 $this->gpg->addDecryptKey('multiple-subkeys@example.com', 'test');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
950 $results = $this->gpg->decryptAndVerify($encryptedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
951 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
952 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
953
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
954 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
955 // {{{ testDecryptVerifySignedOnlyBadSignature()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
956
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
957 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
958 * @group string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
959 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
960 public function testDecryptVerifySignedOnlyBadSignature()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
961 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
962 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
963 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
964 $signature->setValid(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
965 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
966 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
967 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
968 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
969 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
970 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
971 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
972
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
973 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
974 'data' => "Hello, Bob! Goodbye, Alice!\n",
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
975 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
976 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
977
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
978 // {{{ clearsigned data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
979 $clearsignedData = <<<TEXT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
980 -----BEGIN PGP SIGNED MESSAGE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
981 Hash: SHA1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
982
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
983 Hello, Bob! Goodbye, Alice!
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
984 -----BEGIN PGP SIGNATURE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
985 Version: GnuPG v1.4.6 (GNU/Linux)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
986
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
987 iD8DBQFI0vkCwJfZ7JTAY2MRAgzTAKCRecYZsCS+PE46Fa2QLTEP8XGLwwCfQEAL
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
988 qO+KlKcldtYdMZH9AA+KOLQ=
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
989 =EO2G
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
990 -----END PGP SIGNATURE-----
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
991
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
992 TEXT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
993 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
994
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
995 $results = $this->gpg->decryptAndVerify($clearsignedData);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
996 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
997 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
998
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
999 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1000 // {{{ testDecryptVerifyFile()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1001
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1002 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1003 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1004 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1005 public function testDecryptVerifyFile()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1006 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1007 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1008 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1009 $signature->setId('kVwy2yYB0TlXyGd9FUvVYp5jCoI');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1010 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1011 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1012
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1013 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1014 $signature->setCreationDate(1258220197);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1015 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1016 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1017
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1018 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1019 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1020 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1021 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1022 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1023 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1024
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1025 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1026 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1027 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1028 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1029 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1030
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1031 $inputFilename = $this->getDataFilename('testDecryptVerifyFile.asc');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1032 $outputFilename = $this->getTempFilename('testDecryptVerifyFile.plain');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1033
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1034 // file is encrypted with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1035 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1036 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1037 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1038 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1039 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1040
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1041 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1042
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1043 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1044 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1045 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1046
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1047 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1048 // {{{ testDecryptVerifyFileToString()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1049
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1050 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1051 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1052 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1053 public function testDecryptVerifyFileToString()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1054 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1055 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1056 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1057 $signature->setId('GTvYFmQ5yfMM/UOffkYCx21Se2M');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1058 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1059 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1060
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1061 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1062 $signature->setCreationDate(1258221035);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1063 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1064 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1065
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1066 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1067 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1068 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1069 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1070 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1071 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1072
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1073 $expectedSignatures = array($signature);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1074 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1075 'data' => 'Hello, Alice! Goodbye, Bob!',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1076 'signatures' => $expectedSignatures
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1077 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1078
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1079 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1080 'testDecryptVerifyFileToString.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1081 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1082
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1083 // file is encrypted with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1084 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1085 $results = $this->gpg->decryptAndVerifyFile($inputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1086
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1087 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1088 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1089
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1090 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1091 // {{{ testDecryptVerifyFileNoPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1092
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1093 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1094 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1095 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1096 public function testDecryptVerifyFileNoPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1097 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1098 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1099 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1100 $signature->setId('unMY9l/f9sFaMvMV0H1ZuNJRY6Q');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1101 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1102 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1103
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1104 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1105 $signature->setCreationDate(1258220226);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1106 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1107 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1108
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1109 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1110 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1111 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1112 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1113 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1114 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1115
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1116 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1117 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1118 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1119 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1120 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1121
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1122 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1123 'testDecryptVerifyFileNoPassphrase.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1124 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1125 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1126 'testDecryptVerifyFileNoPassphrase.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1127 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1128
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1129 // file is encrypted with no-passphrase@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1130 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1131 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1132 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1133 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1134
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1135 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1136
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1137 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1138 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1139 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1140
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1141 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1142 // {{{ testDecryptVerifyFileFileException_input()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1143
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1144 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1145 * @expectedException Crypt_GPG_FileException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1146 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1147 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1148 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1149 public function testDecryptVerifyFileFileException_input()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1150 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1151 // input file does not exist
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1152 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1153 'testDecryptVerifyFileFileException_input.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1154 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1155
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1156 $this->gpg->decryptAndVerifyFile($inputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1157 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1158
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1159 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1160 // {{{ testDecryptVerifyFileFileException_output()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1161
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1162 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1163 * @expectedException Crypt_GPG_FileException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1164 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1165 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1166 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1167 public function testDecryptVerifyFileFileException_output()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1168 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1169 // input file is encrypted with first-keypair@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1170 // output file does not exist
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1171 $inputFilename = $this->getDataFilename('testDecryptVerifyFile.asc');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1172 $outputFilename = './non-existent' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1173 '/testDecryptVerifyFileFileException_output.plain';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1174
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1175 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1176 $this->gpg->decryptAndVerifyFile($inputFilename, $outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1177 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1178
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1179 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1180 // {{{ testDecryptVerifyFileKeyNotFoundException_decrypt()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1181
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1182 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1183 * @expectedException Crypt_GPG_KeyNotFoundException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1184 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1185 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1186 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1187 public function testDecryptVerifyFileKeyNotFoundException_decrypt()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1188 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1189 // file is encrypted with missing-key@example.com, not signed
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1190 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1191 'testDecryptFileKeyNotFoundException.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1192 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1193
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1194 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1195 'testDecryptVerifyFileKeyNotFoundException.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1196 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1197
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1198 $this->gpg->decryptAndVerifyFile($inputFilename, $outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1199 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1200
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1201 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1202 // {{{ testDecryptVerifyFileDual()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1203
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1204 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1205 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1206 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1207 public function testDecryptVerifyFileDual()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1208 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1209 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1210 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1211 $signature->setId('7TYk0hpio90QZHHHb4UtgCWAEq4');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1212 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1213 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1214
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1215 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1216 $signature->setCreationDate(1258220362);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1217 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1218 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1219
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1220 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1221 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1222 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1223 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1224 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1225 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1226
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1227 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1228 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1229 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1230 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1231 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1232
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1233 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1234 'testDecryptVerifyFileDual.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1235 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1236 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1237 'testDecryptVerifyFileDual.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1238 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1239
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1240 // decrypt with first key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1241 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1242 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1243 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1244 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1245 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1246 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1247 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1248 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1249 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1250
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1251 // decrypt with second key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1252 $this->gpg->addDecryptKey('second-keypair@example.com', 'test2');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1253 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1254 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1255 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1256 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1257 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1258 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1259 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1260 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1261 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1262
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1263 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1264 // {{{ testDecryptVerifyFileDualSignatories()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1265
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1266 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1267 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1268 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1269 public function testDecryptVerifyFileDualSignatories()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1270 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1271 // {{{ signature1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1272 $signature1 = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1273 $signature1->setId('MF8xqL325bs7KiokMHTnHirF4go');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1274 $signature1->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1275 '880922DBEA733E906693E4A903CC890AFA1DAD4B');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1276
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1277 $signature1->setKeyId('03CC890AFA1DAD4B');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1278 $signature1->setCreationDate(1258220269);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1279 $signature1->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1280 $signature1->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1281
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1282 $userId1 = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1283 $userId1->setName('Second Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1284 $userId1->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1285 $userId1->setEmail('second-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1286 $signature1->setUserId($userId1);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1287 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1288 // {{{ signature2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1289 $signature2 = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1290 $signature2->setId('d0q7jibZpJSLpGAhNWhpSkZZeUg');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1291 $signature2->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1292 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1293
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1294 $signature2->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1295 $signature2->setCreationDate(1258220269);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1296 $signature2->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1297 $signature2->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1298
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1299 $userId2 = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1300 $userId2->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1301 $userId2->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1302 $userId2->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1303 $signature2->setUserId($userId2);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1304 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1305
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1306 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1307 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1308 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1309 'signatures' => array($signature1, $signature2)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1310 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1311
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1312 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1313 'testDecryptVerifyFileDualSignatories.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1314 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1315 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1316 'testDecryptVerifyFileDualSignatories.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1317 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1318
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1319 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1320 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1321 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1322 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1323 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1324 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1325 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1326 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1327 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1328
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1329 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1330 // {{{ testDecryptVerifyFileDualOnePassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1331
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1332 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1333 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1334 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1335 public function testDecryptVerifyFileDualOnePassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1336 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1337 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1338 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1339 $signature->setId('kgyLjfFigxOrliyc8XlS6NaLJuw');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1340 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1341 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1342
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1343 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1344 $signature->setCreationDate(1258220334);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1345 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1346 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1347
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1348 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1349 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1350 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1351 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1352 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1353 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1354
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1355 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1356 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1357 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1358 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1359 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1360
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1361 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1362 'testDecryptVerifyFileDualOnePassphrase.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1363 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1364 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1365 'testDecryptVerifyFileDualOnePassphrase.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1366 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1367
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1368 // decrypt with no-passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1369 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1370 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1371 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1372 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1373 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1374 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1375 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1376 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1377
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1378 // decrypt with second key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1379 $this->gpg->addDecryptKey('first-keypair@example.com', 'test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1380 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1381 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1382 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1383 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1384 $this->gpg->clearDecryptKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1385 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1386 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1387 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1388 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1389
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1390 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1391 // {{{ testDecryptVerifyFileNoDataException()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1392
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1393 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1394 * @expectedException Crypt_GPG_NoDataException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1395 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1396 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1397 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1398 public function testDecryptVerifyFileNoDataException()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1399 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1400 $filename = $this->getDataFilename('testFileEmpty.plain');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1401 $this->gpg->decryptAndVerifyFile($filename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1402 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1403
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1404 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1405 // {{{ testDecryptVerifyFileSignedOnly()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1406
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1407 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1408 * @group file
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1409 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1410 public function testDecryptVerifyFileSignedOnly()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1411 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1412 // {{{ signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1413 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1414 $signature->setId('vctnI/HnsRYmqcVwCJcJhS60lKU');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1415 $signature->setKeyFingerprint(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1416 '8D2299D9C5C211128B32BBB0C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1417
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1418 $signature->setKeyId('C097D9EC94C06363');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1419 $signature->setCreationDate(1221960707);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1420 $signature->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1421 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1422
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1423 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1424 $userId->setName('First Keypair Test Key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1425 $userId->setComment('do not encrypt important data with this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1426 $userId->setEmail('first-keypair@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1427 $signature->setUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1428 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1429
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1430 $expectedMd5Sum = 'f96267d87551ee09bfcac16921e351c1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1431 $expectedResults = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1432 'data' => null,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1433 'signatures' => array($signature)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1434 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1435
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1436 $inputFilename = $this->getDataFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1437 'testVerifyFileNormalSignedData.asc'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1438 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1439
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1440 $outputFilename = $this->getTempFilename(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1441 'testDecryptVerifyFileSignedData.plain'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1442 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1443
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1444 $results = $this->gpg->decryptAndVerifyFile(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1445 $inputFilename,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1446 $outputFilename
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1447 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1448
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1449 $this->assertDecryptAndVerifyResultsEquals($expectedResults, $results);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1450
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1451 $md5Sum = $this->getMd5Sum($outputFilename);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1452 $this->assertEquals($expectedMd5Sum, $md5Sum);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1453 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1454
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1455 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1456 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1457
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1458 ?>