Generate ASN.1 structure.

@return Sequence
514531
public function toASN1(): Sequence
    {
        $elements = [];
        if (isset($this->_baseCertificateID)) {
            $elements[] = new ImplicitlyTaggedType(0,
                $this->_baseCertificateID->toASN1());
        }
        if (isset($this->_entityName)) {
            $elements[] = new ImplicitlyTaggedType(1,
                $this->_entityName->toASN1());
        }
        if (isset($this->_objectDigestInfo)) {
            $elements[] = new ImplicitlyTaggedType(2,
                $this->_objectDigestInfo->toASN1());
        }
        return new Sequence(...$elements);
    }
32178
public static function fromASN1(Sequence $seq): self
    {
        $idx = 0;
        if ($seq->hasTagged(0)) {
            $idx++;
            $version = $seq->getTagged(0)
                ->asExplicit()
                ->asInteger()
                ->intNumber();
        } else {
            $version = self::VERSION_1;
        }
        $serial = $seq->at($idx++)
            ->asInteger()
            ->number();
        $algo = AlgorithmIdentifier::fromASN1($seq->at($idx++)->asSequence());
        if (!$algo instanceof SignatureAlgorithmIdentifier) {
            throw new \UnexpectedValueException(
                "Unsupported signature algorithm " . $algo->name() . ".");
        }
        $issuer = Name::fromASN1($seq->at($idx++)->asSequence());
        $validity = Validity::fromASN1($seq->at($idx++)->asSequence());
        $subject = Name::fromASN1($seq->at($idx++)->asSequence());
        $pki = PublicKeyInfo::fromASN1($seq->at($idx++)->asSequence());
        $tbs_cert = new self($subject, $pki, $issuer, $validity);
        $tbs_cert->_version = $version;
        $tbs_cert->_serialNumber = $serial;
        $tbs_cert->_signature = $algo;
        if ($seq->hasTagged(1)) {
            $tbs_cert->_issuerUniqueID = UniqueIdentifier::fromASN1(
                $seq->getTagged(1)
                    ->asImplicit(Element::TYPE_BIT_STRING)
                    ->asBitString());
        }
        if ($seq->hasTagged(2)) {
            $tbs_cert->_subjectUniqueID = UniqueIdentifier::fromASN1(
                $seq->getTagged(2)
                    ->asImplicit(Element::TYPE_BIT_STRING)
                    ->asBitString());
        }
        if ($seq->hasTagged(3)) {
            $tbs_cert->_extensions = Extensions::fromASN1(
                $seq->getTagged(3)
                    ->asExplicit()
                    ->asSequence());
        }
        return $tbs_cert;
    }
839224
public function toASN1(): Sequence
    {
        $elements = array(new ObjectIdentifier($this->_oid));
        if (count($this->_qualifiers)) {
            $qualifiers = array_map(
                function (PolicyQualifierInfo $pqi) {
                    return $pqi->toASN1();
                }, array_values($this->_qualifiers));
            $elements[] = new Sequence(...$qualifiers);
        }
        return new Sequence(...$elements);
    }
810558
public static function fromASN1(Sequence $seq): self
    {
        $subtrees = array_map(
            function (UnspecifiedType $el) {
                return GeneralSubtree::fromASN1($el->asSequence());
            }, $seq->elements());
        if (!count($subtrees)) {
            throw new \UnexpectedValueException(
                "GeneralSubtrees must contain at least one GeneralSubtree.");
        }
        return new self(...$subtrees);
    }
1082487
public function buildEssentialsSequence(string $identifier): Sequence
    {
        $sequence = new Sequence($identifier);

        if ($this->context->isProduction()) {
            $lockManager = new LockManager();
            $lockManager->exitIfSiteLocked();
            if ($identifier === 'compiletime') {
                $lockManager->lockSiteOrExit();
                // make sure the site is unlocked even if the script ends unexpectedly due to an error/exception
                register_shutdown_function([$lockManager, 'unlockSite']);
            }
            $this->setEarlyInstance(LockManager::class, $lockManager);
        }

        $sequence->addStep(new Step('neos.flow:annotationregistry', [Scripts::class, 'registerClassLoaderInAnnotationRegistry']));
        $sequence->addStep(new Step('neos.flow:configuration', [Scripts::class, 'initializeConfiguration']), 'neos.flow:annotationregistry');
        $sequence->addStep(new Step('neos.flow:systemlogger', [Scripts::class, 'initializeSystemLogger']), 'neos.flow:configuration');

        $sequence->addStep(new Step('neos.flow:errorhandling', [Scripts::class, 'initializeErrorHandling']), 'neos.flow:systemlogger');
        $sequence->addStep(new Step('neos.flow:cachemanagement', [Scripts::class, 'initializeCacheManagement']), 'neos.flow:systemlogger');
        return $sequence;
    }
1094288
function createSequence() {
    $cnt = count( $this->sequence );
    if( 0 >= $cnt )
      return;
    $attributes = $this->_createParams( $this->sequence['params'] );
    return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
  }
326165
public function generate()
    {
        $str     = '';
        $keysize = strlen($this->_alphabet);

        for ($i = 0; $i < $this->_length; ++$i) {
            $str .= $this->_alphabet[\Sodium\randombytes_uniform($keysize)];
        }

        return $str;
    }
372334
public function toASN1(): Sequence
    {
        $elements = array(new Integer($this->_version),
            $this->_subject->toASN1(), $this->_subjectPKInfo->toASN1());
        if (isset($this->_attributes)) {
            $elements[] = new ImplicitlyTaggedType(0,
                $this->_attributes->toASN1());
        }
        return new Sequence(...$elements);
    }
831993
public function toASN1(): Set
    {
        $elements = array_map(
            function (Attribute $attr) {
                return $attr->toASN1();
            }, array_values($this->_attributes));
        $set = new Set(...$elements);
        return $set->sortedSetOf();
    }
813367
public function toASN1(): Sequence
    {
        $elements = array_map(
            function (Target $target) {
                return $target->toASN1();
            }, $this->_targets);
        return new Sequence(...$elements);
    }
1197571
public static function sequential(): string
	{
		[$usec, $sec] = explode(' ', microtime());

		$random = hex2bin(dechex($sec . substr($usec, 2, 5)) . bin2hex(random_bytes(10)));

		$random[6] = chr(ord($random[6]) & 0x0f | 0x40);

		$random[8] = chr(ord($random[8]) & 0x3f | 0x80);

		return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($random), 4));
	}
847729
@Override
    public DERObject toASN1Object()
    {
        ASN1EncodableVector v = new ASN1EncodableVector();

        if (cA != null)
        {
            v.add(cA);

            if (pathLenConstraint != null)
            {
                v.add(pathLenConstraint);
            }
        }

        return new DERSequence(v);
    }
201271
public static function fromASN1(Sequence $seq): self
    {
        $version = $seq->at(0)
            ->asInteger()
            ->intNumber();
        if (!in_array($version, [self::VERSION_1, self::VERSION_2])) {
            throw new \UnexpectedValueException(
                "Version $version not supported.");
        }
        $algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
        $key = $seq->at(2)
            ->asOctetString()
            ->string();
        // @todo parse attributes and public key
        $obj = new static($algo, $key);
        $obj->_version = $version;
        return $obj;
    }
1018122
protected function buildXmlStructure()
	{
		$buffer = array();

		foreach ($this->from as $table)
		{
			// Replace the magic prefix if found.
			$table = $this->getGenericTableName($table);

			// Get the details columns information.
			$fields    = $this->db->getTableColumns($table, false);
			$keys      = $this->db->getTableKeys($table);
			$sequences = $this->db->getTableSequences($table);

			$buffer[] = '  <table_structure name="' . $table . '">';

			foreach ($sequences as $sequence)
			{
				if (version_compare($this->db->getVersion(), '9.1.0') < 0)
				{
					$sequence->start_value = null;
				}

				$buffer[] = '   <sequence Name="' . $sequence->sequence . '" Schema="' . $sequence->schema . '"' .
					' Table="' . $sequence->table . '" Column="' . $sequence->column . '" Type="' . $sequence->data_type . '"' .
					' Start_Value="' . $sequence->start_value . '" Min_Value="' . $sequence->minimum_value . '"' .
					' Max_Value="' . $sequence->maximum_value . '" Increment="' . $sequence->increment . '"' .
					' Cycle_option="' . $sequence->cycle_option . '"' .
					' />';
			}

			foreach ($fields as $field)
			{
				$buffer[] = '   <field Field="' . $field->column_name . '" Type="' . $field->type . '" Null="' . $field->null . '"' .
							(isset($field->default) ? ' Default="' . $field->default . '"' : '') . ' Comments="' . $field->comments . '"' .
					' />';
			}

			foreach ($keys as $key)
			{
				$buffer[] = '   <key Index="' . $key->idxName . '" is_primary="' . $key->isPrimary . '" is_unique="' . $key->isUnique . '"' .
					' Query="' . $key->Query . '" />';
			}

			$buffer[] = '  </table_structure>';
		}

		return $buffer;
	}
1258024
public static function fromASN1(Sequence $seq): ObjectDigestInfo
    {
        $type = $seq->at(0)
            ->asEnumerated()
            ->intNumber();
        $oid = null;
        $idx = 1;
        if ($seq->has($idx, Element::TYPE_OBJECT_IDENTIFIER)) {
            $oid = $seq->at($idx++)
                ->asObjectIdentifier()
                ->oid();
        }
        $algo = AlgorithmIdentifier::fromASN1($seq->at($idx++)->asSequence());
        $digest = $seq->at($idx)->asBitString();
        $obj = new self($type, $algo, $digest);
        $obj->_otherObjectTypeID = $oid;
        return $obj;
    }
985460
public function buildRuntimeSequence(): Sequence
    {
        $sequence = $this->buildEssentialsSequence('runtime');
        $sequence->addStep(new Step('neos.flow:objectmanagement:proxyclasses', [Scripts::class, 'initializeProxyClasses']), 'neos.flow:systemlogger');
        $sequence->addStep(new Step('neos.flow:classloader:cache', [Scripts::class, 'initializeClassLoaderClassesCache']), 'neos.flow:objectmanagement:proxyclasses');
        $sequence->addStep(new Step('neos.flow:objectmanagement:runtime', [Scripts::class, 'initializeObjectManager']), 'neos.flow:classloader:cache');

        if (!$this->context->isProduction()) {
            $sequence->addStep(new Step('neos.flow:systemfilemonitor', [Scripts::class, 'initializeSystemFileMonitor']), 'neos.flow:objectmanagement:runtime');
            $sequence->addStep(new Step('neos.flow:objectmanagement:recompile', [Scripts::class, 'recompileClasses']), 'neos.flow:systemfilemonitor');
        }

        $sequence->addStep(new Step('neos.flow:reflectionservice:factory', [Scripts::class, 'initializeReflectionServiceFactory']), 'neos.flow:objectmanagement:runtime');
        $sequence->addStep(new Step('neos.flow:resources', [Scripts::class, 'initializeResources']), 'neos.flow:reflectionservice:factory');
        return $sequence;
    }
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);
    }