1 | <?php |
||
21 | class ValidatorState |
||
22 | { |
||
23 | /** |
||
24 | * Length of the certification path (n). |
||
25 | * |
||
26 | * @var int $_pathLength |
||
27 | */ |
||
28 | protected $_pathLength; |
||
29 | |||
30 | /** |
||
31 | * Current index in the certification path in the range of 1..n (i). |
||
32 | * |
||
33 | * @var int $_index |
||
34 | */ |
||
35 | protected $_index; |
||
36 | |||
37 | /** |
||
38 | * Valid policy tree (valid_policy_tree). |
||
39 | * |
||
40 | * A tree of certificate policies with their optional qualifiers. |
||
41 | * Each of the leaves of the tree represents a valid policy at this stage in |
||
42 | * the certification path validation. |
||
43 | * Once the tree is set to NULL, policy processing ceases. |
||
44 | * |
||
45 | * @var PolicyTree|null $_validPolicyTree |
||
46 | */ |
||
47 | protected $_validPolicyTree; |
||
48 | |||
49 | /** |
||
50 | * Permitted subtrees (permitted_subtrees). |
||
51 | * |
||
52 | * A set of root names for each name type defining a set of subtrees within |
||
53 | * which all subject names in subsequent certificates in the certification |
||
54 | * path must fall. |
||
55 | * |
||
56 | * @var mixed $_permittedSubtrees |
||
57 | */ |
||
58 | protected $_permittedSubtrees; |
||
59 | |||
60 | /** |
||
61 | * Excluded subtrees (excluded_subtrees). |
||
62 | * |
||
63 | * A set of root names for each name type defining a set of subtrees within |
||
64 | * which no subject name in subsequent certificates in the certification |
||
65 | * path may fall. |
||
66 | * |
||
67 | * @var mixed $_excludedSubtrees |
||
68 | */ |
||
69 | protected $_excludedSubtrees; |
||
70 | |||
71 | /** |
||
72 | * Explicit policy (explicit_policy). |
||
73 | * |
||
74 | * An integer that indicates if a non-NULL valid_policy_tree is required. |
||
75 | * |
||
76 | * @var int $_explicitPolicy |
||
77 | */ |
||
78 | protected $_explicitPolicy; |
||
79 | |||
80 | /** |
||
81 | * Inhibit anyPolicy (inhibit_anyPolicy). |
||
82 | * |
||
83 | * An integer that indicates whether the anyPolicy policy identifier is |
||
84 | * considered a match. |
||
85 | * |
||
86 | * @var int $_inhibitAnyPolicy |
||
87 | */ |
||
88 | protected $_inhibitAnyPolicy; |
||
89 | |||
90 | /** |
||
91 | * Policy mapping (policy_mapping). |
||
92 | * |
||
93 | * An integer that indicates if policy mapping is permitted. |
||
94 | * |
||
95 | * @var int $_policyMapping |
||
96 | */ |
||
97 | protected $_policyMapping; |
||
98 | |||
99 | /** |
||
100 | * Working public key algorithm (working_public_key_algorithm). |
||
101 | * |
||
102 | * The digital signature algorithm used to verify the signature of a |
||
103 | * certificate. |
||
104 | * |
||
105 | * @var AlgorithmIdentifierType $_workingPublicKeyAlgorithm |
||
106 | */ |
||
107 | protected $_workingPublicKeyAlgorithm; |
||
108 | |||
109 | /** |
||
110 | * Working public key (working_public_key). |
||
111 | * |
||
112 | * The public key used to verify the signature of a certificate. |
||
113 | * |
||
114 | * @var PublicKeyInfo $_workingPublicKey |
||
115 | */ |
||
116 | protected $_workingPublicKey; |
||
117 | |||
118 | /** |
||
119 | * Working public key parameters (working_public_key_parameters). |
||
120 | * |
||
121 | * Parameters associated with the current public key that may be required to |
||
122 | * verify a signature. |
||
123 | * |
||
124 | * @var Element|null $_workingPublicKeyParameters |
||
125 | */ |
||
126 | protected $_workingPublicKeyParameters; |
||
127 | |||
128 | /** |
||
129 | * Working issuer name (working_issuer_name). |
||
130 | * |
||
131 | * The issuer distinguished name expected in the next certificate in the |
||
132 | * chain. |
||
133 | * |
||
134 | * @var Name $_workingIssuerName |
||
135 | */ |
||
136 | protected $_workingIssuerName; |
||
137 | |||
138 | /** |
||
139 | * Maximum certification path length (max_path_length). |
||
140 | * |
||
141 | * @var int $_maxPathLength |
||
142 | */ |
||
143 | protected $_maxPathLength; |
||
144 | |||
145 | /** |
||
146 | * Constructor. |
||
147 | */ |
||
148 | protected function __constructor() {} |
||
149 | |||
150 | /** |
||
151 | * Initialize variables according to RFC 5280 6.1.2. |
||
152 | * |
||
153 | * @link https://tools.ietf.org/html/rfc5280#section-6.1.2 |
||
154 | * @param PathValidationConfig $config |
||
155 | * @param Certificate $trust_anchor Trust anchor certificate |
||
156 | * @param int $n Number of certificates in the certification path |
||
157 | * @return self |
||
158 | */ |
||
159 | 46 | public static function initialize(PathValidationConfig $config, |
|
179 | |||
180 | /** |
||
181 | * Get self with current certification path index set. |
||
182 | * |
||
183 | * @param int $index |
||
184 | * @return self |
||
185 | */ |
||
186 | 44 | public function withIndex($index) { |
|
191 | |||
192 | /** |
||
193 | * Get self with valid_policy_tree. |
||
194 | * |
||
195 | * @param PolicyTree $policy_tree |
||
196 | * @return self |
||
197 | */ |
||
198 | 14 | public function withValidPolicyTree(PolicyTree $policy_tree) { |
|
203 | |||
204 | /** |
||
205 | * Get self with valid_policy_tree set to null. |
||
206 | * |
||
207 | * @return self |
||
208 | */ |
||
209 | 36 | public function withoutValidPolicyTree() { |
|
214 | |||
215 | /** |
||
216 | * Get self with explicit_policy. |
||
217 | * |
||
218 | * @param int $num |
||
219 | * @return self |
||
220 | */ |
||
221 | 30 | public function withExplicitPolicy($num) { |
|
226 | |||
227 | /** |
||
228 | * Get self with inhibit_anyPolicy. |
||
229 | * |
||
230 | * @param int $num |
||
231 | * @return self |
||
232 | */ |
||
233 | 23 | public function withInhibitAnyPolicy($num) { |
|
238 | |||
239 | /** |
||
240 | * Get self with policy_mapping. |
||
241 | * |
||
242 | * @param int $num |
||
243 | * @return self |
||
244 | */ |
||
245 | 21 | public function withPolicyMapping($num) { |
|
250 | |||
251 | /** |
||
252 | * Get self with working_public_key_algorithm. |
||
253 | * |
||
254 | * @param AlgorithmIdentifierType $algo |
||
255 | * @return self |
||
256 | */ |
||
257 | 42 | public function withWorkingPublicKeyAlgorithm(AlgorithmIdentifierType $algo) { |
|
262 | |||
263 | /** |
||
264 | * Get self with working_public_key. |
||
265 | * |
||
266 | * @param PublicKeyInfo $pubkey_info |
||
267 | * @return self |
||
268 | */ |
||
269 | 42 | public function withWorkingPublicKey(PublicKeyInfo $pubkey_info) { |
|
274 | |||
275 | /** |
||
276 | * Get self with working_public_key_parameters. |
||
277 | * |
||
278 | * @param Element|null $params |
||
279 | * @return self |
||
280 | */ |
||
281 | 42 | public function withWorkingPublicKeyParameters(Element $params = null) { |
|
286 | |||
287 | /** |
||
288 | * Get self with working_issuer_name. |
||
289 | * |
||
290 | * @param Name $issuer |
||
291 | * @return self |
||
292 | */ |
||
293 | 42 | public function withWorkingIssuerName(Name $issuer) { |
|
298 | |||
299 | /** |
||
300 | * Get self with max_path_length. |
||
301 | * |
||
302 | * @param int $length |
||
303 | * @return self |
||
304 | */ |
||
305 | 28 | public function withMaxPathLength($length) { |
|
310 | |||
311 | /** |
||
312 | * Get the certification path length (n). |
||
313 | * |
||
314 | * @return int |
||
315 | */ |
||
316 | 1 | public function pathLength() { |
|
319 | |||
320 | /** |
||
321 | * Get the current index in certification path in the range of 1..n. |
||
322 | * |
||
323 | * @return int |
||
324 | */ |
||
325 | 14 | public function index() { |
|
328 | |||
329 | /** |
||
330 | * Check whether valid_policy_tree is present. |
||
331 | * |
||
332 | * @return bool |
||
333 | */ |
||
334 | 35 | public function hasValidPolicyTree() { |
|
337 | |||
338 | /** |
||
339 | * Get valid_policy_tree. |
||
340 | * |
||
341 | * @throws \LogicException |
||
342 | * @return PolicyTree |
||
343 | */ |
||
344 | 15 | public function validPolicyTree() { |
|
350 | |||
351 | /** |
||
352 | * Get permitted_subtrees. |
||
353 | * |
||
354 | * @return mixed |
||
355 | */ |
||
356 | 35 | public function permittedSubtrees() { |
|
359 | |||
360 | /** |
||
361 | * Get excluded_subtrees. |
||
362 | * |
||
363 | * @return mixed |
||
364 | */ |
||
365 | 35 | public function excludedSubtrees() { |
|
368 | |||
369 | /** |
||
370 | * Get explicit_policy. |
||
371 | * |
||
372 | * @return int |
||
373 | */ |
||
374 | 43 | public function explicitPolicy() { |
|
377 | |||
378 | /** |
||
379 | * Get inhibit_anyPolicy. |
||
380 | * |
||
381 | * @return int |
||
382 | */ |
||
383 | 26 | public function inhibitAnyPolicy() { |
|
386 | |||
387 | /** |
||
388 | * Get policy_mapping. |
||
389 | * |
||
390 | * @return int |
||
391 | */ |
||
392 | 23 | public function policyMapping() { |
|
395 | |||
396 | /** |
||
397 | * Get working_public_key_algorithm. |
||
398 | * |
||
399 | * @return AlgorithmIdentifierType |
||
400 | */ |
||
401 | 1 | public function workingPublicKeyAlgorithm() { |
|
404 | |||
405 | /** |
||
406 | * Get working_public_key. |
||
407 | * |
||
408 | * @return PublicKeyInfo |
||
409 | */ |
||
410 | 44 | public function workingPublicKey() { |
|
413 | |||
414 | /** |
||
415 | * Get working_public_key_parameters. |
||
416 | * |
||
417 | * @return Element|null |
||
418 | */ |
||
419 | 1 | public function workingPublicKeyParameters() { |
|
422 | |||
423 | /** |
||
424 | * Get working_issuer_name. |
||
425 | * |
||
426 | * @return Name |
||
427 | */ |
||
428 | 43 | public function workingIssuerName() { |
|
431 | |||
432 | /** |
||
433 | * Get maximum certification path length. |
||
434 | * |
||
435 | * @return int |
||
436 | */ |
||
437 | 31 | public function maxPathLength() { |
|
440 | |||
441 | /** |
||
442 | * Check whether processing the final certificate of the certification path. |
||
443 | * |
||
444 | * @return bool |
||
445 | */ |
||
446 | 43 | public function isFinal() { |
|
449 | |||
450 | /** |
||
451 | * Get the path validation result. |
||
452 | * |
||
453 | * @param Certificate[] $certificates Certificates in a certification path |
||
454 | * @return PathValidationResult |
||
455 | */ |
||
456 | 28 | public function getResult(array $certificates) { |
|
461 | |||
462 | /** |
||
463 | * Get ASN.1 parameters from algorithm identifier. |
||
464 | * |
||
465 | * @param AlgorithmIdentifierType $algo |
||
466 | * @return Element|null ASN.1 element or null if parameters are omitted |
||
467 | */ |
||
468 | 46 | public static function getAlgorithmParameters(AlgorithmIdentifierType $algo) { |
|
472 | } |
||
473 |