Exemplo n.º 1
0
 /**
  * Initialize variables according to RFC 5280 6.1.2.
  *
  * @link https://tools.ietf.org/html/rfc5280#section-6.1.2
  * @param PathValidationConfig $config
  * @param Certificate $trust_anchor Trust anchor certificate
  * @param int $n Number of certificates in the certification path
  * @return self
  */
 public static function initialize(PathValidationConfig $config, Certificate $trust_anchor, $n)
 {
     $state = new self();
     $state->_pathLength = $n;
     $state->_index = 1;
     $state->_validPolicyTree = new PolicyTree(PolicyNode::anyPolicyNode());
     $state->_permittedSubtrees = null;
     $state->_excludedSubtrees = null;
     $state->_explicitPolicy = $config->explicitPolicy() ? 0 : $n + 1;
     $state->_inhibitAnyPolicy = $config->anyPolicyInhibit() ? 0 : $n + 1;
     $state->_policyMapping = $config->policyMappingInhibit() ? 0 : $n + 1;
     $state->_workingPublicKeyAlgorithm = $trust_anchor->signatureAlgorithm();
     $tbsCert = $trust_anchor->tbsCertificate();
     $state->_workingPublicKey = $tbsCert->subjectPublicKeyInfo();
     $state->_workingPublicKeyParameters = self::getAlgorithmParameters($state->_workingPublicKey->algorithmIdentifier());
     $state->_workingIssuerName = $tbsCert->issuer();
     $state->_maxPathLength = $config->maxLength();
     return $state;
 }