芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/kwesioben.com/paymoney/vendor/mdanter/ecc/src/Serializer/PublicKey/Der/Parser.php
adapter = $adapter; $this->pointSerializer = $pointSerializer ?: new UncompressedPointSerializer(); } /** * @param string $binaryData * @return PublicKeyInterface * @throws \FG\ASN1\Exception\ParserException */ public function parse(string $binaryData): PublicKeyInterface { $asnObject = ASNObject::fromBinary($binaryData); if ($asnObject->getType() !== Identifier::SEQUENCE) { throw new \RuntimeException('Invalid data.'); } /** @var Sequence $asnObject */ if ($asnObject->getNumberofChildren() != 2) { throw new \RuntimeException('Invalid data.'); } $children = $asnObject->getChildren(); if (count($children) != 2) { throw new \RuntimeException('Invalid data.'); } if (count($children) != 2) { throw new \RuntimeException('Invalid data.'); } if ($children[0]->getType() !== Identifier::SEQUENCE) { throw new \RuntimeException('Invalid data.'); } if (count($children[0]->getChildren()) != 2) { throw new \RuntimeException('Invalid data.'); } if ($children[0]->getChildren()[0]->getType() !== Identifier::OBJECT_IDENTIFIER) { throw new \RuntimeException('Invalid data.'); } if ($children[0]->getChildren()[1]->getType() !== Identifier::OBJECT_IDENTIFIER) { throw new \RuntimeException('Invalid data.'); } if ($children[1]->getType() !== Identifier::BITSTRING) { throw new \RuntimeException('Invalid data.'); } $oid = $children[0]->getChildren()[0]; $curveOid = $children[0]->getChildren()[1]; $encodedKey = $children[1]; if ($oid->getContent() !== DerPublicKeySerializer::X509_ECDSA_OID) { throw new \RuntimeException('Invalid data: non X509 data.'); } $generator = CurveOidMapper::getGeneratorFromOid($curveOid); return $this->parseKey($generator, $encodedKey->getContent()); } /** * @param GeneratorPoint $generator * @param string $data * @return PublicKeyInterface */ public function parseKey(GeneratorPoint $generator, string $data): PublicKeyInterface { $point = $this->pointSerializer->unserialize($generator->getCurve(), $data); return new PublicKey($this->adapter, $generator, $point); } }