Parses a private key from the given PEM content
public getPrivateKey ( Lcobucci\JWT\Signer\Key $key ) : Mdanter\Ecc\Crypto\Key\PrivateKeyInterface | ||
$key | Lcobucci\JWT\Signer\Key | |
리턴 | Mdanter\Ecc\Crypto\Key\PrivateKeyInterface |
/** * @test * * @expectedException \InvalidArgumentException * * @uses \Lcobucci\JWT\Signer\Ecdsa\KeyParser::__construct * @uses \Lcobucci\JWT\Signer\Key * * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getPrivateKey * @covers \Lcobucci\JWT\Signer\Ecdsa\KeyParser::getKeyContent */ public function getPrivateKeyShouldRaiseExceptionWhenAWrongKeyWasGiven() { $this->privateKeySerializer->expects($this->never())->method('parse'); $parser = new KeyParser($this->privateKeySerializer, $this->publicKeySerializer); $parser->getPrivateKey($this->getPublicKey()); }
/** * {@inheritdoc} */ public function createHash(string $payload, Key $key, RandomNumberGeneratorInterface $generator = null) : string { $privateKey = $this->parser->getPrivateKey($key); $generator = $generator ?: RandomGeneratorFactory::getRandomGenerator(); return $this->createSignatureHash($this->signer->sign($privateKey, $this->createSigningHash($payload), $generator->generate($privateKey->getPoint()->getOrder()))); }
/** * {@inheritdoc} */ public function createHash(string $payload, Key $key) : string { return $this->adapter->createHash($this->keyParser->getPrivateKey($key), $this->adapter->createSigningHash($payload, $this->getAlgorithm()), $this->getAlgorithm()); }