annotate vendor/pear/crypt_gpg/Crypt/GPG/ProcessHandler.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
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 * Crypt_GPG is a package to use GPG from PHP
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 * This file contains handler for status and error pipes of GPG process.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 * PHP version 5
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 * LICENSE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 * 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
15 * 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
16 * 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
17 * License, or (at your option) any later version.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 * 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
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * Lesser General Public License for more details.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 * 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
25 * License along with this library; if not, see
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 * <http://www.gnu.org/licenses/>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * @author Nathan Fredrickson <nathan@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 * @author Aleksander Machniak <alec@alec.pl>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 * @copyright 2005-2013 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 * @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
35 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 * @link http://www.gnupg.org/
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 * GPG exception classes.
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 require_once 'Crypt/GPG/Exceptions.php';
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 * Signature object class definition
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47 require_once 'Crypt/GPG/Signature.php';
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 // {{{ class Crypt_GPG_ProcessHandler
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 * Status/Error handler for GPG process pipes.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 * This class is used internally by Crypt_GPG_Engine and does not need to be used
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 * directly. See the {@link Crypt_GPG} class for end-user API.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 * @author Nathan Fredrickson <nathan@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 * @author Aleksander Machniak <alec@alec.pl>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62 * @copyright 2005-2013 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 * @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
64 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 * @link http://www.gnupg.org/
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67 class Crypt_GPG_ProcessHandler
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 // {{{ protected class properties
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72 * Engine used to control the GPG subprocess
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 * @var Crypt_GPG_Engine
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 protected $engine;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77
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 * The error code of the current operation
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81 * @var integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 protected $errorCode = Crypt_GPG::ERROR_NONE;
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 * The number of currently needed passphrases
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 * If this is not zero when the GPG command is completed, the error code is
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 * set to {@link Crypt_GPG::ERROR_MISSING_PASSPHRASE}.
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 * @var integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 protected $needPassphrase = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 * Some data collected while processing the operation
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 * or set for the operation
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 * @var array
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100 * @see self::setData()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 * @see self::getData()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 protected $data = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106 * The name of the current operation
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 * @var string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 * @see self::setOperation()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 protected $operation = null;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 * The value of the argument of current operation
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 * @var string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 * @see self::setOperation()
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 protected $operationArg = null;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 // {{{ __construct()
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 * Creates a new instance
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 * @param Crypt_GPG_Engine $engine Engine object
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 public function __construct($engine)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 $this->engine = $engine;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135 // {{{ setOperation()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136
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 * Sets the operation that is being performed by the engine.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 * @param string $operation The GPG operation to perform.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142 * @return void
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 public function setOperation($operation)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 $op = null;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 $opArg = null;
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 // Regexp matching all GPG "operational" arguments
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 $regexp = '/--('
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 . 'version|import|list-public-keys|list-secret-keys'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 . '|list-keys|delete-key|delete-secret-key|encrypt|sign|clearsign'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 . '|detach-sign|decrypt|verify|export-secret-keys|export|gen-key'
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 if (strpos($operation, ' ') === false) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 $op = trim($operation, '- ');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 } else if (preg_match($regexp, $operation, $matches, PREG_OFFSET_CAPTURE)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 $op = trim($matches[0][0], '-');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 $op_len = $matches[0][1] + mb_strlen($op, '8bit') + 3;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 $command = mb_substr($operation, $op_len, null, '8bit');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 // we really need the argument if it is a key ID/fingerprint or email
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 // address se we can use simplified regexp to "revert escapeshellarg()"
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 if (preg_match('/^[\'"]([a-zA-Z0-9:@._-]+)[\'"]/', $command, $matches)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 $opArg = $matches[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 $this->operation = $op;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 $this->operationArg = $opArg;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 // {{{ handleStatus()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178 * Handles error values in the status output from GPG
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 * This method is responsible for setting the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 * {@link self::$errorCode}. See <b>doc/DETAILS</b> in the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 * {@link http://www.gnupg.org/download/ GPG distribution} for detailed
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 * information on GPG's status output.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 * @param string $line the status line to handle.
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 * @return void
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 public function handleStatus($line)
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 $tokens = explode(' ', $line);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 switch ($tokens[0]) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 case 'NODATA':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 $this->errorCode = Crypt_GPG::ERROR_NO_DATA;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 break;
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 case 'DECRYPTION_OKAY':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 // If the message is encrypted, this is the all-clear signal.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 $this->data['DecryptionOkay'] = true;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 $this->errorCode = Crypt_GPG::ERROR_NONE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 case 'DELETE_PROBLEM':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 if ($tokens[1] == '1') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 $this->errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 } elseif ($tokens[1] == '2') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 $this->errorCode = Crypt_GPG::ERROR_DELETE_PRIVATE_KEY;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 case 'IMPORT_OK':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 $this->data['Import']['fingerprint'] = $tokens[2];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 if (empty($this->data['Import']['fingerprints'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 $this->data['Import']['fingerprints'] = array($tokens[2]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 } else if (!in_array($tokens[2], $this->data['Import']['fingerprints'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 $this->data['Import']['fingerprints'][] = $tokens[2];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 }
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 break;
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 case 'IMPORT_RES':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 $this->data['Import']['public_imported'] = intval($tokens[3]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 $this->data['Import']['public_unchanged'] = intval($tokens[5]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227 $this->data['Import']['private_imported'] = intval($tokens[11]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228 $this->data['Import']['private_unchanged'] = intval($tokens[12]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 break;
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 case 'NO_PUBKEY':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232 case 'NO_SECKEY':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 $this->data['ErrorKeyId'] = $tokens[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 if ($this->errorCode != Crypt_GPG::ERROR_MISSING_PASSPHRASE
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 && $this->errorCode != Crypt_GPG::ERROR_BAD_PASSPHRASE
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 $this->errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 // note: this message is also received if there are multiple
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 // recipients and a previous key had a correct passphrase.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 $this->data['MissingKeys'][$tokens[1]] = $tokens[1];
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 // @FIXME: remove missing passphrase registered in ENC_TO handler
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246 // This is for GnuPG 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 unset($this->data['MissingPassphrases'][$tokens[1]]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 case 'KEY_CONSIDERED':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 // In GnuPG 2.1.x exporting/importing a secret key requires passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 // However, no NEED_PASSPRASE is returned, https://bugs.gnupg.org/gnupg/issue2667
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 // So, handling KEY_CONSIDERED and GET_HIDDEN is needed.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254 if (!array_key_exists('KeyConsidered', $this->data)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 $this->data['KeyConsidered'] = $tokens[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 case 'USERID_HINT':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 // remember the user id for pretty exception messages
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 // GnuPG 2.1.15 gives me: "USERID_HINT 0000000000000000 [?]"
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 $keyId = $tokens[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 if (strcspn($keyId, '0')) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264 $username = implode(' ', array_splice($tokens, 2));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 $this->data['BadPassphrases'][$keyId] = $username;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 case 'ENC_TO':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270 // Now we know the message is encrypted. Set flag to check if
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 // decryption succeeded.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 $this->data['DecryptionOkay'] = false;
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 // this is the new key message
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 $this->data['CurrentSubKeyId'] = $keyId = $tokens[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 // For some reason in GnuPG 2.1.11 I get only ENC_TO and no
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 // NEED_PASSPHRASE/MISSING_PASSPHRASE/USERID_HINT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 // This is not needed for GnuPG 2.1.15
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 if (!empty($_ENV['PINENTRY_USER_DATA'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 $passphrases = json_decode($_ENV['PINENTRY_USER_DATA'], true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283 $passphrases = array();
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 // @TODO: Get user name/email
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 $this->data['BadPassphrases'][$keyId] = $keyId;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 if (empty($passphrases) || empty($passphrases[$keyId])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 $this->data['MissingPassphrases'][$keyId] = $keyId;
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 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293 case 'GOOD_PASSPHRASE':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 // if we got a good passphrase, remove the key from the list of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295 // bad passphrases.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 if (isset($this->data['CurrentSubKeyId'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 unset($this->data['BadPassphrases'][$this->data['CurrentSubKeyId']]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 unset($this->data['MissingPassphrases'][$this->data['CurrentSubKeyId']]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 $this->needPassphrase--;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 case 'BAD_PASSPHRASE':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 $this->errorCode = Crypt_GPG::ERROR_BAD_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308 case 'MISSING_PASSPHRASE':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 if (isset($this->data['CurrentSubKeyId'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 $this->data['MissingPassphrases'][$this->data['CurrentSubKeyId']]
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311 = $this->data['CurrentSubKeyId'];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 }
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 $this->errorCode = Crypt_GPG::ERROR_MISSING_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317 case 'GET_HIDDEN':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 if ($tokens[1] == 'passphrase.enter' && isset($this->data['KeyConsidered'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 $tokens[1] = $this->data['KeyConsidered'];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 break;
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 // no break
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325 case 'NEED_PASSPHRASE':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 $passphrase = $this->getPin($tokens[1]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 $this->engine->sendCommand($passphrase);
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 if ($passphrase === '') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 $this->needPassphrase++;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 case 'SIG_CREATED':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336 $this->data['SigCreated'] = $line;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339 case 'SIG_ID':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 // note: signature id comes before new signature line and may not
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 // exist for some signature types
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 $this->data['SignatureId'] = $tokens[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 case 'EXPSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 case 'EXPKEYSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 case 'REVKEYSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 case 'BADSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 case 'ERRSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 $this->errorCode = Crypt_GPG::ERROR_BAD_SIGNATURE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 // no break
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 case 'GOODSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 $signature = new Crypt_GPG_Signature();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 // if there was a signature id, set it on the new signature
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 if (!empty($this->data['SignatureId'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 $signature->setId($this->data['SignatureId']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 $this->data['SignatureId'] = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 }
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 // Detect whether fingerprint or key id was returned and set
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 // signature values appropriately. Key ids are strings of either
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363 // 16 or 8 hexadecimal characters. Fingerprints are strings of 40
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364 // hexadecimal characters. The key id is the last 16 characters of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365 // the key fingerprint.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 if (mb_strlen($tokens[1], '8bit') > 16) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 $signature->setKeyFingerprint($tokens[1]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 $signature->setKeyId(mb_substr($tokens[1], -16, null, '8bit'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 $signature->setKeyId($tokens[1]);
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 // get user id string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 if ($tokens[0] != 'ERRSIG') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 $string = implode(' ', array_splice($tokens, 2));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376 $string = rawurldecode($string);
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 $signature->setUserId(Crypt_GPG_UserId::parse($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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 $this->data['Signatures'][] = $signature;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 case 'VALIDSIG':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385 if (empty($this->data['Signatures'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387 }
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 $signature = end($this->data['Signatures']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 $signature->setValid(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 $signature->setKeyFingerprint($tokens[1]);
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 if (strpos($tokens[3], 'T') === false) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395 $signature->setCreationDate($tokens[3]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 $signature->setCreationDate(strtotime($tokens[3]));
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 if (array_key_exists(4, $tokens)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 if (strpos($tokens[4], 'T') === false) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402 $signature->setExpirationDate($tokens[4]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 $signature->setExpirationDate(strtotime($tokens[4]));
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 }
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 break;
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 case 'KEY_CREATED':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 if (isset($this->data['Handle']) && $tokens[3] == $this->data['Handle']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 $this->data['KeyCreated'] = $tokens[2];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
413 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
414 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416 case 'KEY_NOT_CREATED':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 if (isset($this->data['Handle']) && $tokens[1] == $this->data['Handle']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418 $this->errorCode = Crypt_GPG::ERROR_KEY_NOT_CREATED;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
421
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422 case 'PROGRESS':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 // todo: at some point, support reporting status async
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 // GnuPG 2.1 uses FAILURE and ERROR responses
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427 case 'FAILURE':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428 case 'ERROR':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 $errnum = (int) $tokens[2];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 $source = $errnum >> 24;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431 $errcode = $errnum & 0xFFFFFF;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
432
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433 switch ($errcode) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434 case 11: // bad passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 case 87: // bad PIN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 $this->errorCode = Crypt_GPG::ERROR_BAD_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 case 177: // no passphrase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 case 178: // no PIN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 $this->errorCode = Crypt_GPG::ERROR_MISSING_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 break;
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 case 58:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 $this->errorCode = Crypt_GPG::ERROR_NO_DATA;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 }
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 break;
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 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454 // {{{ handleError()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457 * Handles error values in the error output from GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459 * This method is responsible for setting the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 * {@link Crypt_GPG_Engine::$_errorCode}.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 * @param string $line the error line to handle.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464 * @return void
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 public function handleError($line)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 $pattern = '/no valid OpenPGP data found/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 if (preg_match($pattern, $line) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 $this->errorCode = Crypt_GPG::ERROR_NO_DATA;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 $pattern = '/No secret key|secret key not available/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477 if (preg_match($pattern, $line) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478 $this->errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480 }
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 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 $pattern = '/No public key|public key not found/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 if (preg_match($pattern, $line) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485 $this->errorCode = Crypt_GPG::ERROR_KEY_NOT_FOUND;
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 }
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 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 $matches = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 $pattern = '/can\'t (?:access|open) `(.*?)\'/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 if (preg_match($pattern, $line, $matches) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493 $this->data['ErrorFilename'] = $matches[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 $this->errorCode = Crypt_GPG::ERROR_FILE_PERMISSIONS;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 }
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 // GnuPG 2.1: It should return MISSING_PASSPHRASE, but it does not
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 // we have to detect it this way. This happens e.g. on private key import
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 $matches = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 $pattern = '/key ([0-9A-F]+).* (Bad|No) passphrase/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503 if (preg_match($pattern, $line, $matches) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504 $keyId = $matches[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 // @TODO: Get user name/email
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506 if (empty($this->data['BadPassphrases'][$keyId])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 $this->data['BadPassphrases'][$keyId] = $keyId;
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 if ($matches[2] == 'Bad') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 $this->errorCode = Crypt_GPG::ERROR_BAD_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 $this->errorCode = Crypt_GPG::ERROR_MISSING_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513 if (empty($this->data['MissingPassphrases'][$keyId])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 $this->data['MissingPassphrases'][$keyId] = $keyId;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520 if ($this->errorCode === Crypt_GPG::ERROR_NONE && $this->operation == 'gen-key') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 $pattern = '/:([0-9]+): invalid algorithm$/';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 if (preg_match($pattern, $line, $matches) === 1) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 $this->errorCode = Crypt_GPG::ERROR_BAD_KEY_PARAMS;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 $this->data['LineNumber'] = intval($matches[1]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 // {{{ throwException()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533 * On error throws exception
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 * @param int $exitcode GPG process exit code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 * @return void
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 * @throws Crypt_GPG_Exception
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 public function throwException($exitcode = 0)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 if ($exitcode > 0 && $this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543 $this->errorCode = $this->setErrorCode($exitcode);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 if ($this->errorCode === Crypt_GPG::ERROR_NONE) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 }
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 $code = $this->errorCode;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 $note = "Please use the 'debug' option when creating the Crypt_GPG " .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 "object, and file a bug report at " . Crypt_GPG::BUG_URI;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554 switch ($this->operation) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 case 'version':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557 'Unknown error getting GnuPG version information. ' . $note,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558 $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
560
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
561 case 'list-secret-keys':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 case 'list-public-keys':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 case 'list-keys':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565 case Crypt_GPG::ERROR_KEY_NOT_FOUND:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566 // ignore not found key errors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567 break;
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 case Crypt_GPG::ERROR_FILE_PERMISSIONS:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570 if (!empty($this->data['ErrorFilename'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 throw new Crypt_GPG_FileException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 sprintf(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573 'Error reading GnuPG data file \'%s\'. Check to make ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 'sure it is readable by the current user.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 $this->data['ErrorFilename']
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
576 ),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
577 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578 $this->data['ErrorFilename']
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 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
581 throw new Crypt_GPG_FileException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582 'Error reading GnuPG data file. Check to make sure that ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 'GnuPG data files are readable by the current user.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584 $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
586
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
587 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 'Unknown error getting keys. ' . $note, $code
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 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
593
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
594 case 'delete-key':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595 case 'delete-secret-key':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 case Crypt_GPG::ERROR_KEY_NOT_FOUND:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598 throw new Crypt_GPG_KeyNotFoundException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 'Key not found: ' . $this->operationArg,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601 $this->operationArg
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602 );
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 case Crypt_GPG::ERROR_DELETE_PRIVATE_KEY:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605 throw new Crypt_GPG_DeletePrivateKeyException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 'Private key must be deleted before public key can be ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
607 'deleted.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
608 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
609 $this->operationArg
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
610 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
611
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
612 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
613 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
614 'Unknown error deleting key. ' . $note, $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
615 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
616 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
617 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
618
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
619 case 'import':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
620 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
621 case Crypt_GPG::ERROR_NO_DATA:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
622 throw new Crypt_GPG_NoDataException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
623 'No valid GPG key data found.', $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
624 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
625
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
626 case Crypt_GPG::ERROR_BAD_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
627 case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
628 throw $this->badPassException($code, 'Cannot import private key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
629
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
630 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
631 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
632 'Unknown error importing GPG key. ' . $note, $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
633 );
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 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
636
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
637 case 'export':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
638 case 'export-secret-keys':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
639 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
640 case Crypt_GPG::ERROR_BAD_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
641 case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
642 throw $this->badPassException($code, 'Cannot export private key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
643
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
644 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
645 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
646 'Unknown error exporting a key. ' . $note, $code
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 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
649 break;
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 case 'encrypt':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
652 case 'sign':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
653 case 'clearsign':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
654 case 'detach-sign':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
655 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
656 case Crypt_GPG::ERROR_KEY_NOT_FOUND:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
657 throw new Crypt_GPG_KeyNotFoundException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
658 'Cannot sign data. Private key not found. Import the '.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
659 'private key before trying to sign data.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
660 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
661 !empty($this->data['ErrorKeyId']) ? $this->data['ErrorKeyId'] : null
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
662 );
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 case Crypt_GPG::ERROR_BAD_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
665 throw new Crypt_GPG_BadPassphraseException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
666 'Cannot sign data. Incorrect passphrase provided.', $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
667 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
668
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
669 case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
670 throw new Crypt_GPG_BadPassphraseException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
671 'Cannot sign data. No passphrase provided.', $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
672 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
673
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
674 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
675 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
676 "Unknown error {$this->operation}ing data. $note", $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
677 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
678 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
679 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
680
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
681 case 'verify':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
682 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
683 case Crypt_GPG::ERROR_BAD_SIGNATURE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
684 // ignore bad signature errors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
685 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
686
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
687 case Crypt_GPG::ERROR_NO_DATA:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
688 throw new Crypt_GPG_NoDataException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
689 'No valid signature data found.', $code
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
692 case Crypt_GPG::ERROR_KEY_NOT_FOUND:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
693 throw new Crypt_GPG_KeyNotFoundException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
694 'Public key required for data verification not in keyring.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
695 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
696 !empty($this->data['ErrorKeyId']) ? $this->data['ErrorKeyId'] : null
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
697 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
698
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
699 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
700 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
701 'Unknown error validating signature details. ' . $note,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
702 $code
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 break;
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 case 'decrypt':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
708 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
709 case Crypt_GPG::ERROR_BAD_SIGNATURE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
710 // ignore bad signature errors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
711 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
712
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
713 case Crypt_GPG::ERROR_KEY_NOT_FOUND:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
714 if (!empty($this->data['MissingKeys'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
715 $keyId = reset($this->data['MissingKeys']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
716 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
717 $keyId = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
718 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
719
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
720 throw new Crypt_GPG_KeyNotFoundException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
721 'Cannot decrypt data. No suitable private key is in the ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
722 'keyring. Import a suitable private key before trying to ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
723 'decrypt this data.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
724 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
725 $keyId
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
726 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
727
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
728 case Crypt_GPG::ERROR_BAD_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
729 case Crypt_GPG::ERROR_MISSING_PASSPHRASE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
730 throw $this->badPassException($code, 'Cannot decrypt data.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
731
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
732 case Crypt_GPG::ERROR_NO_DATA:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
733 throw new Crypt_GPG_NoDataException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
734 'Cannot decrypt data. No PGP encrypted data was found in '.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
735 'the provided data.',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
736 $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
737 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
738
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
739 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
740 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
741 'Unknown error decrypting data.', $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
742 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
743 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
744 break;
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 case 'gen-key':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
747 switch ($code) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
748 case Crypt_GPG::ERROR_BAD_KEY_PARAMS:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
749 throw new Crypt_GPG_InvalidKeyParamsException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
750 'Invalid key algorithm specified.', $code
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
753 default:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
754 throw new Crypt_GPG_Exception(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
755 'Unknown error generating key-pair. ' . $note, $code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
756 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
757 }
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 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
760
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
761 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
762 // {{{ throwException()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
763
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
764 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
765 * Check exit code of the GPG operation.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
766 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
767 * @param int $exitcode GPG process exit code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
768 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
769 * @return int Internal error code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
770 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
771 protected function setErrorCode($exitcode)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
772 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
773 if ($this->needPassphrase > 0) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
774 return Crypt_GPG::ERROR_MISSING_PASSPHRASE;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
775 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
776
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
777 if ($this->operation == 'import') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
778 return Crypt_GPG::ERROR_NONE;
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 if ($this->operation == 'decrypt' && !empty($this->data['DecryptionOkay'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
782 if (!empty($this->data['IgnoreVerifyErrors'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
783 return Crypt_GPG::ERROR_NONE;
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 if (!empty($this->data['MissingKeys'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
786 return Crypt_GPG::ERROR_KEY_NOT_FOUND;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
787 }
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 return Crypt_GPG::ERROR_UNKNOWN;
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
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 // {{{ getData()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
795
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
796 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
797 * Get data from the last process execution.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
798 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
799 * @param string $name Data element name:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
800 * - SigCreated: The last SIG_CREATED status.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
801 * - KeyConsidered: The last KEY_CONSIDERED status identifier.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
802 * - KeyCreated: The KEY_CREATED status (for specified Handle).
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
803 * - Signatures: Signatures data from verification process.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
804 * - LineNumber: Number of the gen-key error line.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
805 * - Import: Result of IMPORT_OK/IMPORT_RES
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
806 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
807 * @return mixed
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
808 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
809 public function getData($name)
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 return isset($this->data[$name]) ? $this->data[$name] : null;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
812 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
813
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
814 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
815 // {{{ setData()
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
818 * Set data for the process execution.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
819 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
820 * @param string $name Data element name:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
821 * - Handle: The unique key handle used by this handler
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
822 * The key handle is used to track GPG status output
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
823 * for a particular key on --gen-key command before
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
824 * the key has its own identifier.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
825 * - IgnoreVerifyErrors: Do not throw exceptions
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
826 * when signature verification failes because
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
827 * of a missing public key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
828 * @param mixed $value Data element value
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
829 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
830 * @return void
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 public function setData($name, $value)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
833 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
834 switch ($name) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
835 case 'Handle':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
836 $this->data[$name] = strval($value);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
837 break;
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 case 'IgnoreVerifyErrors':
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
840 $this->data[$name] = (bool) $value;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
841 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
842 }
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
845 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
846 // {{{ setData()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
847
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
848 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
849 * Create Crypt_GPG_BadPassphraseException from operation data.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
850 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
851 * @param int $code Error code
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
852 * @param string $message Error message
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
853 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
854 * @return Crypt_GPG_BadPassphraseException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
855 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
856 protected function badPassException($code, $message)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
857 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
858 $badPassphrases = array_diff_key(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
859 isset($this->data['BadPassphrases']) ? $this->data['BadPassphrases'] : array(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
860 isset($this->data['MissingPassphrases']) ? $this->data['MissingPassphrases'] : array()
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
863 $missingPassphrases = array_intersect_key(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
864 isset($this->data['BadPassphrases']) ? $this->data['BadPassphrases'] : array(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
865 isset($this->data['MissingPassphrases']) ? $this->data['MissingPassphrases'] : array()
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
868 if (count($badPassphrases) > 0) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
869 $message .= ' Incorrect passphrase provided for keys: "' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
870 implode('", "', $badPassphrases) . '".';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
871 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
872 if (count($missingPassphrases) > 0) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
873 $message .= ' No passphrase provided for keys: "' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
874 implode('", "', $missingPassphrases) . '".';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
875 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
876
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
877 return new Crypt_GPG_BadPassphraseException(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
878 $message,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
879 $code,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
880 $badPassphrases,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
881 $missingPassphrases
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
882 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
883 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
884
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
885 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
886 // {{{ getPin()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
887
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 * Get registered passphrase for specified key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
890 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
891 * @param string $key Key identifier
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
892 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
893 * @return string Passphrase
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 protected function getPin($key)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
896 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
897 $passphrase = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
898 $keyIdLength = mb_strlen($key, '8bit');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
899
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
900 if ($keyIdLength && !empty($_ENV['PINENTRY_USER_DATA'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
901 $passphrases = json_decode($_ENV['PINENTRY_USER_DATA'], true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
902 foreach ($passphrases as $_keyId => $pass) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
903 $keyId = $key;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
904 $_keyIdLength = mb_strlen($_keyId, '8bit');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
905
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
906 // Get last X characters of key identifier to compare
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
907 if ($keyIdLength < $_keyIdLength) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
908 $_keyId = mb_substr($_keyId, -$keyIdLength, null, '8bit');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
909 } else if ($keyIdLength > $_keyIdLength) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
910 $keyId = mb_substr($keyId, -$_keyIdLength, null, '8bit');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
911 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
912
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
913 if ($_keyId === $keyId) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
914 $passphrase = $pass;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
915 break;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
916 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
917 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
918 }
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 return $passphrase;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
921 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
922
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
923 // }}}
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 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
927
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
928 ?>