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 | 47 | protected function __construct() |
|
151 | |||
152 | /** |
||
153 | * Initialize variables according to RFC 5280 6.1.2. |
||
154 | * |
||
155 | * @link https://tools.ietf.org/html/rfc5280#section-6.1.2 |
||
156 | * @param PathValidationConfig $config |
||
157 | * @param Certificate $trust_anchor Trust anchor certificate |
||
158 | * @param int $n Number of certificates in the certification path |
||
159 | * @return self |
||
160 | */ |
||
161 | 47 | public static function initialize(PathValidationConfig $config, |
|
182 | |||
183 | /** |
||
184 | * Get self with current certification path index set. |
||
185 | * |
||
186 | * @param int $index |
||
187 | * @return self |
||
188 | */ |
||
189 | 44 | public function withIndex(int $index): self |
|
195 | |||
196 | /** |
||
197 | * Get self with valid_policy_tree. |
||
198 | * |
||
199 | * @param PolicyTree $policy_tree |
||
200 | * @return self |
||
201 | */ |
||
202 | 14 | public function withValidPolicyTree(PolicyTree $policy_tree): self |
|
208 | |||
209 | /** |
||
210 | * Get self with valid_policy_tree set to null. |
||
211 | * |
||
212 | * @return self |
||
213 | */ |
||
214 | 36 | public function withoutValidPolicyTree(): self |
|
220 | |||
221 | /** |
||
222 | * Get self with explicit_policy. |
||
223 | * |
||
224 | * @param int $num |
||
225 | * @return self |
||
226 | */ |
||
227 | 30 | public function withExplicitPolicy(int $num): self |
|
233 | |||
234 | /** |
||
235 | * Get self with inhibit_anyPolicy. |
||
236 | * |
||
237 | * @param int $num |
||
238 | * @return self |
||
239 | */ |
||
240 | 23 | public function withInhibitAnyPolicy(int $num): self |
|
246 | |||
247 | /** |
||
248 | * Get self with policy_mapping. |
||
249 | * |
||
250 | * @param int $num |
||
251 | * @return self |
||
252 | */ |
||
253 | 21 | public function withPolicyMapping(int $num): self |
|
259 | |||
260 | /** |
||
261 | * Get self with working_public_key_algorithm. |
||
262 | * |
||
263 | * @param AlgorithmIdentifierType $algo |
||
264 | * @return self |
||
265 | */ |
||
266 | 42 | public function withWorkingPublicKeyAlgorithm(AlgorithmIdentifierType $algo): self |
|
272 | |||
273 | /** |
||
274 | * Get self with working_public_key. |
||
275 | * |
||
276 | * @param PublicKeyInfo $pubkey_info |
||
277 | * @return self |
||
278 | */ |
||
279 | 42 | public function withWorkingPublicKey(PublicKeyInfo $pubkey_info): self |
|
285 | |||
286 | /** |
||
287 | * Get self with working_public_key_parameters. |
||
288 | * |
||
289 | * @param Element|null $params |
||
290 | * @return self |
||
291 | */ |
||
292 | 42 | public function withWorkingPublicKeyParameters(Element $params = null): self |
|
298 | |||
299 | /** |
||
300 | * Get self with working_issuer_name. |
||
301 | * |
||
302 | * @param Name $issuer |
||
303 | * @return self |
||
304 | */ |
||
305 | 42 | public function withWorkingIssuerName(Name $issuer): self |
|
311 | |||
312 | /** |
||
313 | * Get self with max_path_length. |
||
314 | * |
||
315 | * @param int $length |
||
316 | * @return self |
||
317 | */ |
||
318 | 28 | public function withMaxPathLength(int $length): self |
|
324 | |||
325 | /** |
||
326 | * Get the certification path length (n). |
||
327 | * |
||
328 | * @return int |
||
329 | */ |
||
330 | 1 | public function pathLength(): int |
|
334 | |||
335 | /** |
||
336 | * Get the current index in certification path in the range of 1..n. |
||
337 | * |
||
338 | * @return int |
||
339 | */ |
||
340 | 15 | public function index(): int |
|
344 | |||
345 | /** |
||
346 | * Check whether valid_policy_tree is present. |
||
347 | * |
||
348 | * @return bool |
||
349 | */ |
||
350 | 35 | public function hasValidPolicyTree(): bool |
|
354 | |||
355 | /** |
||
356 | * Get valid_policy_tree. |
||
357 | * |
||
358 | * @throws \LogicException |
||
359 | * @return PolicyTree |
||
360 | */ |
||
361 | 15 | public function validPolicyTree(): PolicyTree |
|
368 | |||
369 | /** |
||
370 | * Get permitted_subtrees. |
||
371 | * |
||
372 | * @return mixed |
||
373 | */ |
||
374 | 35 | public function permittedSubtrees() |
|
378 | |||
379 | /** |
||
380 | * Get excluded_subtrees. |
||
381 | * |
||
382 | * @return mixed |
||
383 | */ |
||
384 | 35 | public function excludedSubtrees() |
|
388 | |||
389 | /** |
||
390 | * Get explicit_policy. |
||
391 | * |
||
392 | * @return int |
||
393 | */ |
||
394 | 43 | public function explicitPolicy(): int |
|
398 | |||
399 | /** |
||
400 | * Get inhibit_anyPolicy. |
||
401 | * |
||
402 | * @return int |
||
403 | */ |
||
404 | 26 | public function inhibitAnyPolicy(): int |
|
408 | |||
409 | /** |
||
410 | * Get policy_mapping. |
||
411 | * |
||
412 | * @return int |
||
413 | */ |
||
414 | 23 | public function policyMapping(): int |
|
418 | |||
419 | /** |
||
420 | * Get working_public_key_algorithm. |
||
421 | * |
||
422 | * @return AlgorithmIdentifierType |
||
423 | */ |
||
424 | 1 | public function workingPublicKeyAlgorithm(): AlgorithmIdentifierType |
|
428 | |||
429 | /** |
||
430 | * Get working_public_key. |
||
431 | * |
||
432 | * @return PublicKeyInfo |
||
433 | */ |
||
434 | 44 | public function workingPublicKey(): PublicKeyInfo |
|
438 | |||
439 | /** |
||
440 | * Get working_public_key_parameters. |
||
441 | * |
||
442 | * @return Element|null |
||
443 | */ |
||
444 | 1 | public function workingPublicKeyParameters() |
|
448 | |||
449 | /** |
||
450 | * Get working_issuer_name. |
||
451 | * |
||
452 | * @return Name |
||
453 | */ |
||
454 | 43 | public function workingIssuerName(): Name |
|
458 | |||
459 | /** |
||
460 | * Get maximum certification path length. |
||
461 | * |
||
462 | * @return int |
||
463 | */ |
||
464 | 31 | public function maxPathLength(): int |
|
468 | |||
469 | /** |
||
470 | * Check whether processing the final certificate of the certification path. |
||
471 | * |
||
472 | * @return bool |
||
473 | */ |
||
474 | 43 | public function isFinal(): bool |
|
478 | |||
479 | /** |
||
480 | * Get the path validation result. |
||
481 | * |
||
482 | * @param Certificate[] $certificates Certificates in a certification path |
||
483 | * @return PathValidationResult |
||
484 | */ |
||
485 | 28 | public function getResult(array $certificates): PathValidationResult |
|
491 | |||
492 | /** |
||
493 | * Get ASN.1 parameters from algorithm identifier. |
||
494 | * |
||
495 | * @param AlgorithmIdentifierType $algo |
||
496 | * @return Element|null ASN.1 element or null if parameters are omitted |
||
497 | */ |
||
498 | 47 | public static function getAlgorithmParameters(AlgorithmIdentifierType $algo) |
|
503 | } |
||
504 |