1 | <?php |
||
19 | class ValidatorState |
||
20 | { |
||
21 | /** |
||
22 | * Length of the certification path (n). |
||
23 | * |
||
24 | * @var int $_pathLength |
||
25 | */ |
||
26 | protected $_pathLength; |
||
27 | |||
28 | /** |
||
29 | * Current index in the certification path in the range of 1..n (i). |
||
30 | * |
||
31 | * @var int $_index |
||
32 | */ |
||
33 | protected $_index; |
||
34 | |||
35 | /** |
||
36 | * Valid policy tree (valid_policy_tree). |
||
37 | * |
||
38 | * A tree of certificate policies with their optional qualifiers. |
||
39 | * Each of the leaves of the tree represents a valid policy at this stage in |
||
40 | * the certification path validation. |
||
41 | * Once the tree is set to NULL, policy processing ceases. |
||
42 | * |
||
43 | * @var PolicyTree|null $_validPolicyTree |
||
44 | */ |
||
45 | protected $_validPolicyTree; |
||
46 | |||
47 | /** |
||
48 | * Permitted subtrees (permitted_subtrees). |
||
49 | * |
||
50 | * A set of root names for each name type defining a set of subtrees within |
||
51 | * which all subject names in subsequent certificates in the certification |
||
52 | * path must fall. |
||
53 | * |
||
54 | * @var mixed $_permittedSubtrees |
||
55 | */ |
||
56 | protected $_permittedSubtrees; |
||
57 | |||
58 | /** |
||
59 | * Excluded subtrees (excluded_subtrees). |
||
60 | * |
||
61 | * A set of root names for each name type defining a set of subtrees within |
||
62 | * which no subject name in subsequent certificates in the certification |
||
63 | * path may fall. |
||
64 | * |
||
65 | * @var mixed $_excludedSubtrees |
||
66 | */ |
||
67 | protected $_excludedSubtrees; |
||
68 | |||
69 | /** |
||
70 | * Explicit policy (explicit_policy). |
||
71 | * |
||
72 | * An integer that indicates if a non-NULL valid_policy_tree is required. |
||
73 | * |
||
74 | * @var int $_explicitPolicy |
||
75 | */ |
||
76 | protected $_explicitPolicy; |
||
77 | |||
78 | /** |
||
79 | * Inhibit anyPolicy (inhibit_anyPolicy). |
||
80 | * |
||
81 | * An integer that indicates whether the anyPolicy policy identifier is |
||
82 | * considered a match. |
||
83 | * |
||
84 | * @var int $_inhibitAnyPolicy |
||
85 | */ |
||
86 | protected $_inhibitAnyPolicy; |
||
87 | |||
88 | /** |
||
89 | * Policy mapping (policy_mapping). |
||
90 | * |
||
91 | * An integer that indicates if policy mapping is permitted. |
||
92 | * |
||
93 | * @var int $_policyMapping |
||
94 | */ |
||
95 | protected $_policyMapping; |
||
96 | |||
97 | /** |
||
98 | * Working public key algorithm (working_public_key_algorithm). |
||
99 | * |
||
100 | * The digital signature algorithm used to verify the signature of a |
||
101 | * certificate. |
||
102 | * |
||
103 | * @var AlgorithmIdentifierType $_workingPublicKeyAlgorithm |
||
104 | */ |
||
105 | protected $_workingPublicKeyAlgorithm; |
||
106 | |||
107 | /** |
||
108 | * Working public key (working_public_key). |
||
109 | * |
||
110 | * The public key used to verify the signature of a certificate. |
||
111 | * |
||
112 | * @var PublicKeyInfo $_workingPublicKey |
||
113 | */ |
||
114 | protected $_workingPublicKey; |
||
115 | |||
116 | /** |
||
117 | * Working public key parameters (working_public_key_parameters). |
||
118 | * |
||
119 | * Parameters associated with the current public key that may be required to |
||
120 | * verify a signature. |
||
121 | * |
||
122 | * @var Element|null $_workingPublicKeyParameters |
||
123 | */ |
||
124 | protected $_workingPublicKeyParameters; |
||
125 | |||
126 | /** |
||
127 | * Working issuer name (working_issuer_name). |
||
128 | * |
||
129 | * The issuer distinguished name expected in the next certificate in the |
||
130 | * chain. |
||
131 | * |
||
132 | * @var Name $_workingIssuerName |
||
133 | */ |
||
134 | protected $_workingIssuerName; |
||
135 | |||
136 | /** |
||
137 | * Maximum certification path length (max_path_length). |
||
138 | * |
||
139 | * @var int $_maxPathLength |
||
140 | */ |
||
141 | protected $_maxPathLength; |
||
142 | |||
143 | /** |
||
144 | * Constructor. |
||
145 | */ |
||
146 | 47 | protected function __construct() |
|
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 | 47 | public static function initialize(PathValidationConfig $config, |
|
180 | |||
181 | /** |
||
182 | * Get self with current certification path index set. |
||
183 | * |
||
184 | * @param int $index |
||
185 | * @return self |
||
186 | */ |
||
187 | 44 | public function withIndex($index) |
|
193 | |||
194 | /** |
||
195 | * Get self with valid_policy_tree. |
||
196 | * |
||
197 | * @param PolicyTree $policy_tree |
||
198 | * @return self |
||
199 | */ |
||
200 | 14 | public function withValidPolicyTree(PolicyTree $policy_tree) |
|
206 | |||
207 | /** |
||
208 | * Get self with valid_policy_tree set to null. |
||
209 | * |
||
210 | * @return self |
||
211 | */ |
||
212 | 36 | public function withoutValidPolicyTree() |
|
218 | |||
219 | /** |
||
220 | * Get self with explicit_policy. |
||
221 | * |
||
222 | * @param int $num |
||
223 | * @return self |
||
224 | */ |
||
225 | 30 | public function withExplicitPolicy($num) |
|
231 | |||
232 | /** |
||
233 | * Get self with inhibit_anyPolicy. |
||
234 | * |
||
235 | * @param int $num |
||
236 | * @return self |
||
237 | */ |
||
238 | 23 | public function withInhibitAnyPolicy($num) |
|
244 | |||
245 | /** |
||
246 | * Get self with policy_mapping. |
||
247 | * |
||
248 | * @param int $num |
||
249 | * @return self |
||
250 | */ |
||
251 | 21 | public function withPolicyMapping($num) |
|
257 | |||
258 | /** |
||
259 | * Get self with working_public_key_algorithm. |
||
260 | * |
||
261 | * @param AlgorithmIdentifierType $algo |
||
262 | * @return self |
||
263 | */ |
||
264 | 42 | public function withWorkingPublicKeyAlgorithm(AlgorithmIdentifierType $algo) |
|
270 | |||
271 | /** |
||
272 | * Get self with working_public_key. |
||
273 | * |
||
274 | * @param PublicKeyInfo $pubkey_info |
||
275 | * @return self |
||
276 | */ |
||
277 | 42 | public function withWorkingPublicKey(PublicKeyInfo $pubkey_info) |
|
283 | |||
284 | /** |
||
285 | * Get self with working_public_key_parameters. |
||
286 | * |
||
287 | * @param Element|null $params |
||
288 | * @return self |
||
289 | */ |
||
290 | 42 | public function withWorkingPublicKeyParameters(Element $params = null) |
|
296 | |||
297 | /** |
||
298 | * Get self with working_issuer_name. |
||
299 | * |
||
300 | * @param Name $issuer |
||
301 | * @return self |
||
302 | */ |
||
303 | 42 | public function withWorkingIssuerName(Name $issuer) |
|
309 | |||
310 | /** |
||
311 | * Get self with max_path_length. |
||
312 | * |
||
313 | * @param int $length |
||
314 | * @return self |
||
315 | */ |
||
316 | 28 | public function withMaxPathLength($length) |
|
322 | |||
323 | /** |
||
324 | * Get the certification path length (n). |
||
325 | * |
||
326 | * @return int |
||
327 | */ |
||
328 | 1 | public function pathLength() |
|
332 | |||
333 | /** |
||
334 | * Get the current index in certification path in the range of 1..n. |
||
335 | * |
||
336 | * @return int |
||
337 | */ |
||
338 | 15 | public function index() |
|
342 | |||
343 | /** |
||
344 | * Check whether valid_policy_tree is present. |
||
345 | * |
||
346 | * @return bool |
||
347 | */ |
||
348 | 35 | public function hasValidPolicyTree() |
|
352 | |||
353 | /** |
||
354 | * Get valid_policy_tree. |
||
355 | * |
||
356 | * @throws \LogicException |
||
357 | * @return PolicyTree |
||
358 | */ |
||
359 | 15 | public function validPolicyTree() |
|
366 | |||
367 | /** |
||
368 | * Get permitted_subtrees. |
||
369 | * |
||
370 | * @return mixed |
||
371 | */ |
||
372 | 35 | public function permittedSubtrees() |
|
376 | |||
377 | /** |
||
378 | * Get excluded_subtrees. |
||
379 | * |
||
380 | * @return mixed |
||
381 | */ |
||
382 | 35 | public function excludedSubtrees() |
|
386 | |||
387 | /** |
||
388 | * Get explicit_policy. |
||
389 | * |
||
390 | * @return int |
||
391 | */ |
||
392 | 43 | public function explicitPolicy() |
|
396 | |||
397 | /** |
||
398 | * Get inhibit_anyPolicy. |
||
399 | * |
||
400 | * @return int |
||
401 | */ |
||
402 | 26 | public function inhibitAnyPolicy() |
|
406 | |||
407 | /** |
||
408 | * Get policy_mapping. |
||
409 | * |
||
410 | * @return int |
||
411 | */ |
||
412 | 23 | public function policyMapping() |
|
416 | |||
417 | /** |
||
418 | * Get working_public_key_algorithm. |
||
419 | * |
||
420 | * @return AlgorithmIdentifierType |
||
421 | */ |
||
422 | 1 | public function workingPublicKeyAlgorithm() |
|
426 | |||
427 | /** |
||
428 | * Get working_public_key. |
||
429 | * |
||
430 | * @return PublicKeyInfo |
||
431 | */ |
||
432 | 44 | public function workingPublicKey() |
|
436 | |||
437 | /** |
||
438 | * Get working_public_key_parameters. |
||
439 | * |
||
440 | * @return Element|null |
||
441 | */ |
||
442 | 1 | public function workingPublicKeyParameters() |
|
446 | |||
447 | /** |
||
448 | * Get working_issuer_name. |
||
449 | * |
||
450 | * @return Name |
||
451 | */ |
||
452 | 43 | public function workingIssuerName() |
|
456 | |||
457 | /** |
||
458 | * Get maximum certification path length. |
||
459 | * |
||
460 | * @return int |
||
461 | */ |
||
462 | 31 | public function maxPathLength() |
|
466 | |||
467 | /** |
||
468 | * Check whether processing the final certificate of the certification path. |
||
469 | * |
||
470 | * @return bool |
||
471 | */ |
||
472 | 43 | public function isFinal() |
|
476 | |||
477 | /** |
||
478 | * Get the path validation result. |
||
479 | * |
||
480 | * @param Certificate[] $certificates Certificates in a certification path |
||
481 | * @return PathValidationResult |
||
482 | */ |
||
483 | 28 | public function getResult(array $certificates) |
|
489 | |||
490 | /** |
||
491 | * Get ASN.1 parameters from algorithm identifier. |
||
492 | * |
||
493 | * @param AlgorithmIdentifierType $algo |
||
494 | * @return Element|null ASN.1 element or null if parameters are omitted |
||
495 | */ |
||
496 | 47 | public static function getAlgorithmParameters(AlgorithmIdentifierType $algo) |
|
501 | } |
||
502 |