Generate ASN.1 structure.

@return Sequence
344142
public function toASN1(): Sequence
    {
        return new Sequence($this->_certificationRequestInfo->toASN1(),
            $this->_signatureAlgorithm->toASN1(), $this->_signature->bitString());
    }
1041863
public static function fromASN1(Sequence $seq): RSAPublicKey
    {
        $n = $seq->at(0)
            ->asInteger()
            ->number();
        $e = $seq->at(1)
            ->asInteger()
            ->number();
        return new self($n, $e);
    }
137265
public function toASN1(): Sequence
    {
        return new Sequence(new Integer(0), new Integer($this->_modulus),
            new Integer($this->_publicExponent),
            new Integer($this->_privateExponent), new Integer($this->_prime1),
            new Integer($this->_prime2), new Integer($this->_exponent1),
            new Integer($this->_exponent2), new Integer($this->_coefficient));
    }
1035781
public static function fromASN1(Sequence $seq): self
    {
        $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
        $values = array_map(
            function (UnspecifiedType $el) use ($type) {
                return AttributeValue::fromASN1ByOID($type->oid(), $el);
            }, $seq->at(1)
                ->asSet()
                ->elements());
        return new self($type, ...$values);
    }
1247141
protected function parseSequenceOrDifference()
    {
        if (null === ($item = $this->parse('Item', null))) {
            return [];
        }
        
        if ($this->type == '-') {
            $this->consume();
            
            return new AST\Difference($item, $this->parse('Item'));
        }
        
        $items = [
            $item
        ];
        
        while (null !== ($item = $this->parse('Item', null))) {
            $items[] = $item;
        }
        
        if (\count($items) === 1) {
            return $items[0];
        }
        
        return new AST\Sequence($items);
    }
1018940
public function getAlternatingSequence()
    {
        $edges    = $this->edges->getVector();
        $vertices = $this->vertices->getVector();

        $ret = array();
        for ($i = 0, $l = count($this->edges); $i < $l; ++$i) {
            $ret []= $vertices[$i];
            $ret []= $edges[$i];
        }
        $ret[] = $vertices[$i];

        return $ret;
    }
422108
public function toASN1(): Sequence
    {
        $elements = array(new Integer($this->_version), $this->_holder->toASN1(),
            $this->_issuer->toASN1(), $this->signature()->toASN1(),
            new Integer($this->serialNumber()),
            $this->_attrCertValidityPeriod->toASN1(),
            $this->_attributes->toASN1());
        if (isset($this->_issuerUniqueID)) {
            $elements[] = $this->_issuerUniqueID->toASN1();
        }
        if (count($this->_extensions)) {
            $elements[] = $this->_extensions->toASN1();
        }
        return new Sequence(...$elements);
    }
653049
public static function fromASN1(Sequence $seq): self
    {
        $targets = array_map(
            function (UnspecifiedType $el) {
                return Target::fromASN1($el->asTagged());
            }, $seq->elements());
        return new self(...$targets);
    }
731958
protected function parseChoice()
    {
        if (null === ($first = $this->parse('SequenceOrDifference', null))) {
            return $this;
        }
        
        $alternatives = [];
        
        if ($first !== []) {
            $alternatives[] = $first;
            
            if ($this->type == 'T_NEWLINE' && ($this->tokens[$this->offset + 1]->type ?? null) == '|') {
                $this->consume();
            }
            
            while ($this->type == '|') {
                $this->consume();
                $alternatives[] = $this->parse('SequenceOrDifference');
            }
        }
        
        if (\count($alternatives) === 1) {
            return $alternatives[0];
        }
        
        return new AST\Choice($alternatives);
    }
829562
function _extensionsToAsn1(exts) {
  // create top-level extension container
  var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);

  // create extension sequence (stores a sequence for each extension)
  var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
  rval.value.push(seq);

  var ext, extseq;
  for(var i = 0; i < exts.length; ++i) {
    ext = exts[i];

    // create a sequence for each extension
    extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
    seq.value.push(extseq);

    // extnID (OID)
    extseq.value.push(asn1.create(
      asn1.Class.UNIVERSAL, asn1.Type.OID, false,
      asn1.oidToDer(ext.id).getBytes()));

    // critical defaults to false
    if(ext.critical) {
      // critical BOOLEAN DEFAULT FALSE
      extseq.value.push(asn1.create(
        asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
        String.fromCharCode(0xFF)));
    }

    var value = ext.value;
    if(typeof ext.value !== 'string') {
      // value is asn.1
      value = asn1.toDer(value).getBytes();
    }

    // extnValue (OCTET STRING)
    extseq.value.push(asn1.create(
      asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));
  }

  return rval;
}
281702
public static function fromASN1(Sequence $seq): self
    {
        $oid = $seq->at(0)
            ->asObjectIdentifier()
            ->oid();
        $qualifiers = array();
        if (count($seq) > 1) {
            $qualifiers = array_map(
                function (UnspecifiedType $el) {
                    return PolicyQualifierInfo::fromASN1($el->asSequence());
                },
                $seq->at(1)
                    ->asSequence()
                    ->elements());
        }
        return new self($oid, ...$qualifiers);
    }
769076
public DERObject toASN1Object()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(new DERInteger(getModulus()));
        v.add(new DERInteger(getPublicExponent()));

        return new DERSequence(v);
    }
1155956
public static function fromASN1(Sequence $seq): Extensions
    {
        $extensions = array_map(
            function (UnspecifiedType $el) {
                return Ext\Extension::fromASN1($el->asSequence());
            }, $seq->elements());
        return new self(...$extensions);
    }
7226
protected function getSequenceMapper() {
    if (self::$sequenceMapper == null) {
      self::$sequenceMapper = self::getMapper(self::SEQUENCE_CLASS);
    }
    return self::$sequenceMapper;
  }
714819
public static function fromASN1(Sequence $seq): self
    {
        $attribs = array_map(
            function (UnspecifiedType $el) {
                return Attribute::fromASN1($el->asSequence());
            }, $seq->elements());
        // cast attributes
        $attribs = array_map(
            function (Attribute $attr) {
                $oid = $attr->oid();
                if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
                    $cls = self::MAP_OID_TO_CLASS[$oid];
                    $attr = $attr->castValues($cls);
                }
                return $attr;
            }, $attribs);
        return new self(...$attribs);
    }
994576
public static function fromASN1(Sequence $seq): Extension
    {
        $extnID = $seq->at(0)
            ->asObjectIdentifier()
            ->oid();
        $critical = false;
        $idx = 1;
        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
            $critical = $seq->at($idx++)
                ->asBoolean()
                ->value();
        }
        $data = $seq->at($idx)
            ->asOctetString()
            ->string();
        if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) {
            $cls = self::MAP_OID_TO_CLASS[$extnID];
            return $cls::_fromDER($data, $critical);
        }
        return UnknownExtension::fromRawString($extnID, $critical, $data);
    }
64725
private function buildFrom()
	{
		$froms = [];

		foreach ($this->from as $from)
		{
			$string = $this->connection->quoteName($from['table']);

			// See if we're including an alias
			if (isset($from['as']))
			{
				$string .= ' AS ' . $this->connection->quoteName($from['as']);
			}

			$froms[] = $string;
		}

		return 'FROM ' . implode(',', $froms);
	}