/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { $seq = $el->asSequence(); $type_id = $seq->at(0)->asObjectIdentifier()->oid(); $value = $seq->getTagged(0)->asExplicit()->asElement(); return new self($type_id, $value); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromASN1(UnspecifiedType $el) { $seq = $el->asSequence(); $authority = null; if ($seq->hasTagged(0)) { $authority = GeneralNames::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); } $name = GeneralName::fromASN1($seq->getTagged(1)->asExplicit()->asTagged()); return new self($name, $authority); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $seq = $params->asSequence(); $salt = $seq->at(0)->asOctetString()->string(); $iteration_count = $seq->at(1)->asInteger()->number(); return new static($salt, $iteration_count); }
public static function fromASN1(UnspecifiedType $el) { $seq = $el->asSequence(); $service = GeneralName::fromASN1($seq->at(0)->asTagged()); $ident = GeneralName::fromASN1($seq->at(1)->asTagged()); $auth_info = null; if ($seq->has(2, Element::TYPE_OCTET_STRING)) { $auth_info = $seq->at(2)->asString()->string(); } return new static($service, $ident, $auth_info); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromQualifierASN1(UnspecifiedType $el) { $seq = $el->asSequence(); $ref = null; $text = null; $idx = 0; if ($seq->has($idx, Element::TYPE_SEQUENCE)) { $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence()); } if ($seq->has($idx, Element::TYPE_STRING)) { $text = DisplayText::fromASN1($seq->at($idx)->asString()); } return new self($text, $ref); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromASN1(UnspecifiedType $el) { $seq = $el->asSequence(); $authority = null; $idx = 0; if ($seq->hasTagged(0)) { $authority = GeneralNames::fromASN1($seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); ++$idx; } $values = array_map(function (UnspecifiedType $el) { return IetfAttrValue::fromASN1($el); }, $seq->at($idx)->asSequence()->elements()); $obj = new static(...$values); $obj->_policyAuthority = $authority; return $obj; }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $seq = $params->asSequence(); $kdf = AlgorithmIdentifier::fromASN1($seq->at(0)->asSequence()); // ensure we got proper key derivation function algorithm if (!$kdf instanceof PBKDF2AlgorithmIdentifier) { throw new \UnexpectedValueException("KDF algorithm " . $kdf->oid() . " not supported."); } $es = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence()); // ensure we got proper encryption algorithm if (!$es instanceof BlockCipherAlgorithmIdentifier) { throw new \UnexpectedValueException("ES algorithm " . $es->oid() . " not supported."); } return new self($kdf, $es); }
public static function fromASN1(UnspecifiedType $el) { return new self(Extensions::fromASN1($el->asSequence())); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { $obj = new self(); $obj->_element = $el->asSequence(); return $obj; }
/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { return new self(Name::fromASN1($el->asSequence())); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $seq = $params->asSequence(); $salt = null; $el = $seq->at(0); switch ($el->tag()) { // specified case Element::TYPE_OCTET_STRING: $salt = $el->asOctetString()->string(); break; // otherSource // otherSource case Element::TYPE_SEQUENCE: AlgorithmIdentifier::fromASN1($el->asSequence()); throw new \RuntimeException("otherSource not implemented."); } $iteration_count = $seq->at(1)->asInteger()->number(); $key_length = null; $prf_algo = null; $idx = 2; if ($seq->has($idx, Element::TYPE_INTEGER)) { $key_length = $seq->at($idx++)->asInteger()->number(); } if ($seq->has($idx, Element::TYPE_SEQUENCE)) { $prf_algo = AlgorithmIdentifier::fromASN1($seq->at($idx++)->asSequence()); if (!$prf_algo instanceof PRFAlgorithmIdentifier) { throw new \UnexpectedValueException($prf_algo->oid() . " is not supported as a pseudorandom function."); } } return new self($salt, $iteration_count, $key_length, $prf_algo); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $key_bits = 32; // rfc2268 a choice containing only IV if ($params->isType(Element::TYPE_OCTET_STRING)) { $iv = $params->asOctetString()->string(); } else { $seq = $params->asSequence(); $idx = 0; // version is optional in rfc2898 if ($seq->has($idx, Element::TYPE_INTEGER)) { $version = $seq->at($idx++)->asInteger()->number(); $key_bits = self::_versionToEKB($version); } // IV is present in all variants $iv = $seq->at($idx)->asOctetString()->string(); } return new self($key_bits, $iv); }