芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/joolsmen.com/vendor/lcobucci/jwt/test/unit/Signer/EcdsaTest.php
pointsManipulator = new MultibyteStringConverter(); } private function getSigner() { $signer = $this->getMockForAbstractClass(Ecdsa::class, [$this->pointsManipulator]); $signer->method('getAlgorithm') ->willReturn(OPENSSL_ALGO_SHA256); $signer->method('getAlgorithmId') ->willReturn('ES256'); $signer->method('getKeyLength') ->willReturn(64); return $signer; } /** * @test * * @covers \Lcobucci\JWT\Signer\Ecdsa::createHash * @covers \Lcobucci\JWT\Signer\Ecdsa::getKeyType * @covers \Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter * @covers \Lcobucci\JWT\Signer\OpenSSL * @covers \Lcobucci\JWT\Signer\BaseSigner * * @uses \Lcobucci\JWT\Signer\Ecdsa::__construct * @uses \Lcobucci\JWT\Signer\Key * @uses \Lcobucci\JWT\Signature */ public function createHashShouldReturnTheAHashBasedOnTheOpenSslSignature() { $payload = 'testing'; $signer = $this->getSigner(); $signature = $signer->sign($payload, self::$ecdsaKeys['private']); $publicKey = openssl_pkey_get_public(self::$ecdsaKeys['public1']->getContent()); self::assertInternalType('resource', $publicKey); self::assertSame( 1, openssl_verify( $payload, $this->pointsManipulator->toAsn1($signature, $signer->getKeyLength()), $publicKey, OPENSSL_ALGO_SHA256 ) ); } /** * @test * * @covers \Lcobucci\JWT\Signer\Ecdsa::doVerify * @covers \Lcobucci\JWT\Signer\Ecdsa::getKeyType * @covers \Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter * @covers \Lcobucci\JWT\Signer\OpenSSL * @covers \Lcobucci\JWT\Signer\BaseSigner * * @uses \Lcobucci\JWT\Signer\Ecdsa::__construct * @uses \Lcobucci\JWT\Signer\Key */ public function doVerifyShouldDelegateToEcdsaSignerUsingPublicKey() { $payload = 'testing'; $privateKey = openssl_pkey_get_private(self::$ecdsaKeys['private']->getContent()); self::assertInternalType('resource', $privateKey); $signature = ''; openssl_sign($payload, $signature, $privateKey, OPENSSL_ALGO_SHA256); $signer = $this->getSigner(); self::assertTrue( $signer->verify( $this->pointsManipulator->fromAsn1($signature, $signer->getKeyLength()), $payload, self::$ecdsaKeys['public1'] ) ); } }