/** * * @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 $params * @throws \UnexpectedValueException If parameters are invalid * @return self */ protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $iv = $params->asOctetString()->string(); return new static($iv); }
/** * Initialize from ASN.1 with given OID hint. * * @param string $oid Attribute's OID * @param UnspecifiedType $el * @return self */ public static function fromASN1ByOID($oid, UnspecifiedType $el) { if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) { return new UnknownAttributeValue($oid, $el->asElement()); } $cls = self::MAP_OID_TO_CLASS[$oid]; return $cls::fromASN1($el); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $params->asNull(); return new self(); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { $obj = new static(); // store parameters so re-encoding doesn't change if (isset($params)) { $obj->_params = $params->asElement(); } return $obj; }
protected static function _fromASN1Params(UnspecifiedType $params = null) { $obj = new static(); // if parameters field is present, it must be null type if (isset($params)) { $obj->_params = $params->asNull(); } return $obj; }
/** * * @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); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { /* * RFC 4231 states that the "parameter" component SHOULD be present * but have type NULL. */ $obj = new static(); if (isset($params)) { $obj->_params = $params->asNull(); } return $obj; }
/** * Initialize from ASN.1. * * @param UnspecifiedType $el CHOICE * @throws \UnexpectedValueException * @return self */ public static function fromASN1(UnspecifiedType $el) { if (!$el->isTagged()) { throw new \UnexpectedValueException("v1Form issuer not supported."); } $tagged = $el->asTagged(); switch ($tagged->tag()) { case 0: return V2Form::fromV2ASN1($tagged->asImplicit(Element::TYPE_SEQUENCE)->asSequence()); } throw new \UnexpectedValueException("Unsupported issuer type."); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { $octets = $el->asOctetString()->string(); switch (strlen($octets)) { case 4: case 8: return IPv4Address::fromOctets($octets); case 16: case 32: return IPv6Address::fromOctets($octets); default: throw new \UnexpectedValueException("Invalid octet length for IP address."); } }
/** * * @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(); $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."); } $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); }
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); }
/** * Initialize from ASN.1. * * @param UnspecifiedType $el * @throws \UnexpectedValueException * @return self */ public static function fromASN1(UnspecifiedType $el) { switch ($el->tag()) { case Element::TYPE_OCTET_STRING: case Element::TYPE_UTF8_STRING: return new self($el->asString()->string(), $el->tag()); case Element::TYPE_OBJECT_IDENTIFIER: return new self($el->asObjectIdentifier()->oid(), $el->tag()); } throw new \UnexpectedValueException("Type " . Element::tagToName($el->tag()) . " not supported."); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { return new self($el->asIA5String()->string()); }
/** * Constructor * * @param string $oid Algorithm OID * @param UnspecifiedType|null $params Parameters */ public function __construct($oid, UnspecifiedType $params = null) { $this->_oid = $oid; $this->_params = $params ? $params->asElement() : null; }
/** * * @param UnspecifiedType $el * @return self */ public static function fromQualifierASN1(UnspecifiedType $el) { return new self($el->asString()->string()); }
/** * * @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($el->asObjectIdentifier()->oid()); }
/** * * @see AttributeValue::fromASN1 * @param UnspecifiedType $el * @return self */ public static function fromASN1(UnspecifiedType $el) { return new static($el->asPrintableString()->string()); }
public static function fromASN1(UnspecifiedType $el) { return new self(Extensions::fromASN1($el->asSequence())); }
protected static function _fromASN1Params(UnspecifiedType $params = null) { if (!isset($params)) { throw new \UnexpectedValueException("No parameters."); } $named_curve = $params->asObjectIdentifier()->oid(); return new self($named_curve); }
/** * * @param UnspecifiedType $el * @return self */ public static function fromChosenASN1(UnspecifiedType $el) { return new self(Name::fromASN1($el->asSequence())); }
/** * * @see AttributeValue::fromASN1 * @param UnspecifiedType $el * @return self */ public static function fromASN1(UnspecifiedType $el) { $tag = $el->tag(); self::_tagToASN1Class($tag); return new static($el->asString()->string(), $tag); }