annotate vendor/pear/crypt_gpg/Crypt/GPG/SubKey.php @ 41:d2414df68d78

Updated by Alex S Grebenschikov (www.poralix.com) to make it compatible with RoundCube 1.3.0
author Charlie Root
date Fri, 24 Jan 2025 14:20:15 -0500
parents 1e000243b222
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 * Contains a class representing GPG sub-keys and constants for GPG algorithms
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 * PHP version 5
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 * LICENSE:
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 * 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
13 * 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
14 * 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
15 * License, or (at your option) any later version.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 * 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
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 * Lesser General Public License for more details.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * 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
23 * License along with this library; if not, see
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 * <http://www.gnu.org/licenses/>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 * @author Nathan Fredrickson <nathan@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * @copyright 2005-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * @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
32 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 // {{{ class Crypt_GPG_SubKey
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36
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 * A class for GPG sub-key information
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 * This class is used to store the results of the {@link Crypt_GPG::getKeys()}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 * method. Sub-key objects are members of a {@link Crypt_GPG_Key} object.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 * @author Nathan Fredrickson <nathan@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47 * @copyright 2005-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 * @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
49 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 * @see Crypt_GPG::getKeys()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 * @see Crypt_GPG_Key::getSubKeys()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 class Crypt_GPG_SubKey
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 // {{{ algorithm class constants
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 * RSA encryption algorithm.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 const ALGORITHM_RSA = 1;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 * Elgamal encryption algorithm (encryption only).
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 const ALGORITHM_ELGAMAL_ENC = 16;
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 * DSA encryption algorithm (sometimes called DH, sign only).
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 const ALGORITHM_DSA = 17;
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 * Elgamal encryption algorithm (signage and encryption - should not be
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 * used).
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 const ALGORITHM_ELGAMAL_ENC_SGN = 20;
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 // {{{ usage class constants
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 * Key can be used to encrypt
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 const USAGE_ENCRYPT = 1;
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 * Key can be used to sign
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 const USAGE_SIGN = 2;
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 * Key can be used to certify other keys
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 const USAGE_CERTIFY = 4;
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 * Key can be used for authentication
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 const USAGE_AUTHENTICATION = 8;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 // {{{ class properties
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103
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 * The id of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 * @var string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 private $_id = '';
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112 * The algorithm used to create this sub-key
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 is one of the Crypt_GPG_SubKey::ALGORITHM_* constants.
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 integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118 private $_algorithm = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119
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 * The fingerprint of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123 * @var string
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 private $_fingerprint = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 * Length of this sub-key in bits
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 * @var integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 private $_length = 0;
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 * Date this sub-key was created
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 * This is a Unix timestamp.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 * @var integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 private $_creationDate = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 * Date this sub-key expires
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 * This is a Unix timestamp. If this sub-key does not expire, this will be
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 * zero.
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 * @var integer
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 private $_expirationDate = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 * Contains usage flags of this sub-key
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 * @var int
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 private $_usage = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 * Whether or not the private key for this sub-key exists in the keyring
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 * @var boolean
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 private $_hasPrivate = false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166
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 * Whether or not this sub-key is revoked
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 * @var boolean
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 private $_isRevoked = false;
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 // {{{ __construct()
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 * Creates a new sub-key object
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 * Sub-keys can be initialized from an array of named values. Available
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 * names are:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 * - <kbd>string id</kbd> - the key id of the sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 * - <kbd>integer algorithm</kbd> - the encryption algorithm of the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 * sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 * - <kbd>string fingerprint</kbd> - the fingerprint of the sub-key. The
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 * fingerprint should not contain
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 * formatting characters.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 * - <kbd>integer length</kbd> - the length of the sub-key in bits.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 * - <kbd>integer creation</kbd> - the date the sub-key was created.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 * This is a UNIX timestamp.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 * - <kbd>integer expiration</kbd> - the date the sub-key expires. This
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 * is a UNIX timestamp. If the sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 * does not expire, use 0.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 * - <kbd>boolean canSign</kbd> - whether or not the sub-key can be
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 * used to sign data.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 * - <kbd>boolean canEncrypt</kbd> - whether or not the sub-key can be
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 * used to encrypt data.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 * - <kbd>integer usage</kbd> - the sub-key usage flags
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 * - <kbd>boolean hasPrivate</kbd> - whether or not the private key for
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 * the sub-key exists in the keyring.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 * - <kbd>boolean isRevoked</kbd> - whether or not this sub-key is
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 * revoked.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 * @param Crypt_GPG_SubKey|string|array $key optional. Either an existing
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 * sub-key object, which is copied; a sub-key string, which is
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 * parsed; or an array of initial values.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 public function __construct($key = null)
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 // parse from string
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 if (is_string($key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 $key = self::parse($key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 }
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 // copy from object
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 if ($key instanceof Crypt_GPG_SubKey) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 $this->_id = $key->_id;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 $this->_algorithm = $key->_algorithm;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 $this->_fingerprint = $key->_fingerprint;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221 $this->_length = $key->_length;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222 $this->_creationDate = $key->_creationDate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223 $this->_expirationDate = $key->_expirationDate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224 $this->_usage = $key->_usage;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 $this->_hasPrivate = $key->_hasPrivate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 $this->_isRevoked = $key->_isRevoked;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 // initialize from array
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230 if (is_array($key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 if (array_key_exists('id', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232 $this->setId($key['id']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 if (array_key_exists('algorithm', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 $this->setAlgorithm($key['algorithm']);
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 if (array_key_exists('fingerprint', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 $this->setFingerprint($key['fingerprint']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 if (array_key_exists('length', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244 $this->setLength($key['length']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 if (array_key_exists('creation', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248 $this->setCreationDate($key['creation']);
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 if (array_key_exists('expiration', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 $this->setExpirationDate($key['expiration']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 if (array_key_exists('usage', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 $this->setUsage($key['usage']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 }
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 if (array_key_exists('canSign', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 $this->setCanSign($key['canSign']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 if (array_key_exists('canEncrypt', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264 $this->setCanEncrypt($key['canEncrypt']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 }
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 if (array_key_exists('hasPrivate', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268 $this->setHasPrivate($key['hasPrivate']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 if (array_key_exists('isRevoked', $key)) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 $this->setRevoked($key['isRevoked']);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
273 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
274 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 // {{{ getId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 * Gets the id of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283 * @return string the id of this sub-key.
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 public function getId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 return $this->_id;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289
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 // {{{ getAlgorithm()
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 * Gets the algorithm used by this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 * The algorithm should be one of the Crypt_GPG_SubKey::ALGORITHM_*
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 * constants.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 * @return integer the algorithm used by this sub-key.
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 public function getAlgorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 return $this->_algorithm;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 // {{{ getCreationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 * Gets the creation date of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 * This is a Unix timestamp.
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 * @return integer the creation date of this sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 public function getCreationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 return $this->_creationDate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 // {{{ getExpirationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323
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 * Gets the date this sub-key expires
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 * This is a Unix timestamp. If this sub-key does not expire, this will be
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 * zero.
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 * @return integer the date this sub-key expires.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 public function getExpirationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 return $this->_expirationDate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 // {{{ getFingerprint()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 * Gets the fingerprint of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 * @return string the fingerprint of this sub-key.
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 public function getFingerprint()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 return $this->_fingerprint;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 // {{{ getLength()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 * Gets the length of this sub-key in bits
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 * @return integer the length of this sub-key in bits.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 public function getLength()
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 return $this->_length;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364 // {{{ canSign()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 * Gets whether or not this sub-key can sign data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 * @return boolean true if this sub-key can sign data and false if this
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 * sub-key can not sign data.
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 public function canSign()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 return ($this->_usage & self::USAGE_SIGN) != 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376
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 // {{{ canEncrypt()
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 * Gets whether or not this sub-key can encrypt data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383 * @return boolean true if this sub-key can encrypt data and false if this
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 * sub-key can not encrypt data.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 public function canEncrypt()
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 return ($this->_usage & self::USAGE_ENCRYPT) != 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 // {{{ usage()
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395 * Gets usage flags of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 * @return int Sum of usage flags
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 public function usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
400 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 return $this->_usage;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
405 // {{{ hasPrivate()
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 * Gets whether or not the private key for this sub-key exists in the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409 * keyring
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 * @return boolean true the private key for this sub-key exists in the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 * keyring and false if it does not.
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 public function hasPrivate()
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 return $this->_hasPrivate;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418
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 // {{{ isRevoked()
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 * Gets whether or not this sub-key is revoked
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 * @return boolean true if this sub-key is revoked and false if it is not.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427 public function isRevoked()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 return $this->_isRevoked;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431
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 // {{{ setCreationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 * Sets the creation date of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438 * The creation date is a Unix timestamp.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 * @param integer $creationDate the creation date of this sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 * @return Crypt_GPG_SubKey the current object, for fluent interface.
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 public function setCreationDate($creationDate)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 $this->_creationDate = intval($creationDate);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 return $this;
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
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 // {{{ setExpirationDate()
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 * Sets the expiration date of this sub-key
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 * The expiration date is a Unix timestamp. Specify zero if this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457 * does not expire.
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 * @param integer $expirationDate the expiration date of this sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 public function setExpirationDate($expirationDate)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 $this->_expirationDate = intval($expirationDate);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 return $this;
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 // {{{ setId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471
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 * Sets the id of this sub-key
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 * @param string $id the id of this sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479 public function setId($id)
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 $this->_id = strval($id);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482 return $this;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486 // {{{ setAlgorithm()
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 * Sets the algorithm used by this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 * @param integer $algorithm the algorithm used by this sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 public function setAlgorithm($algorithm)
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 $this->_algorithm = intval($algorithm);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 return $this;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 // {{{ setFingerprint()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 * Sets the fingerprint of this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 * @param string $fingerprint the fingerprint of this sub-key.
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 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 public function setFingerprint($fingerprint)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513 $this->_fingerprint = strval($fingerprint);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 return $this;
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 // {{{ setLength()
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 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 * Sets the length of this sub-key in bits
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 * @param integer $length the length of this sub-key in bits.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 * @return Crypt_GPG_SubKey the current object, for fluent interface.
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 public function setLength($length)
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 $this->_length = intval($length);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 return $this;
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 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 // {{{ setCanSign()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535
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 * Sets whether or not this sub-key can sign data
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 * @param boolean $canSign true if this sub-key can sign data and false if
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 * it can not.
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 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 public function setCanSign($canSign)
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 ($canSign) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 $this->_usage |= self::USAGE_SIGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549 $this->_usage &= ~self::USAGE_SIGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 return $this;
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
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 // {{{ setCanEncrypt()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559 * Sets whether or not this sub-key can encrypt data
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 * @param boolean $canEncrypt true if this sub-key can encrypt data and
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 * false if it can not.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566 public function setCanEncrypt($canEncrypt)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
568 if ($canEncrypt) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
569 $this->_usage |= self::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 $this->_usage &= ~self::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 return $this;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 }
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 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578 // {{{ setUsage()
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 * Sets usage flags of the sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 * @param integer $usage Usage flags
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585 * @return Crypt_GPG_SubKey the current object, for fluent interface.
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 public function setUsage($usage)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 $this->_usage = (int) $usage;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
590 return $this;
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
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 // {{{ setHasPrivate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 * Sets whether of not the private key for this sub-key exists in the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598 * keyring
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 * @param boolean $hasPrivate true if the private key for this sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601 * exists in the keyring and false if it does
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602 * not.
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 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 public function setHasPrivate($hasPrivate)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
607 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
608 $this->_hasPrivate = ($hasPrivate) ? true : false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
609 return $this;
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 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
613 // {{{ setRevoked()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
614
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 * Sets whether or not this sub-key is revoked
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
617 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
618 * @param boolean $isRevoked whether or not this sub-key is revoked.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
619 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
620 * @return Crypt_GPG_SubKey the current object, for fluent interface.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
621 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
622 public function setRevoked($isRevoked)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
623 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
624 $this->_isRevoked = ($isRevoked) ? true : false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
625 return $this;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
626 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
627
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
628 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
629 // {{{ parse()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
630
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
631 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
632 * Parses a sub-key object from a sub-key string
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 * See <b>doc/DETAILS</b> in the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
635 * {@link http://www.gnupg.org/download/ GPG distribution} for information
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
636 * on how the sub-key string is parsed.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
637 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
638 * @param string $string the string containing the sub-key.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
639 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
640 * @return Crypt_GPG_SubKey the sub-key object parsed from the string.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
641 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
642 public static function parse($string)
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 $tokens = explode(':', $string);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
645
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
646 $subKey = new Crypt_GPG_SubKey();
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 $subKey->setId($tokens[4]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
649 $subKey->setLength($tokens[2]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
650 $subKey->setAlgorithm($tokens[3]);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
651 $subKey->setCreationDate(self::_parseDate($tokens[5]));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
652 $subKey->setExpirationDate(self::_parseDate($tokens[6]));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
653
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
654 if ($tokens[1] == 'r') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
655 $subKey->setRevoked(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
656 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
657
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
658 $usage = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
659 $usage_map = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
660 'a' => self::USAGE_AUTHENTICATION,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
661 'c' => self::USAGE_CERTIFY,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
662 'e' => self::USAGE_ENCRYPT,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
663 's' => self::USAGE_SIGN,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
664 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
665
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
666 foreach ($usage_map as $key => $flag) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
667 if (strpos($tokens[11], $key) !== false) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
668 $usage |= $flag;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
669 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
670 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
671
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
672 $subKey->setUsage($usage);
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 return $subKey;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
675 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
676
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 // {{{ _parseDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
679
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 * Parses a date string as provided by GPG into a UNIX timestamp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
682 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
683 * @param string $string the date string.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
684 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
685 * @return integer the UNIX timestamp corresponding to the provided date
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
686 * string.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
687 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
688 private static function _parseDate($string)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
689 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
690 if ($string == '') {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
691 $timestamp = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
692 } else {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
693 // all times are in UTC according to GPG documentation
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
694 $timeZone = new DateTimeZone('UTC');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
695
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
696 if (strpos($string, 'T') === false) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
697 // interpret as UNIX timestamp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
698 $string = '@' . $string;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
699 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
700
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
701 $date = new DateTime($string, $timeZone);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
702
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
703 // convert to UNIX timestamp
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
704 $timestamp = intval($date->format('U'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
705 }
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 return $timestamp;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
708 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
709
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
710 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
711 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
712
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
713 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
714
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
715 ?>