/** * * @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); }
/** * * @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."); } }
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); }