public static toPublic ( |
||
$private | ||
return |
public static function toPublic(RSAKey $private)
{
$data = $private->toArray();
$keys = ['p', 'd', 'q', 'dp', 'dq', 'qi'];
foreach ($keys as $key) {
if (array_key_exists($key, $data)) {
unset($data[$key]);
}
}
return new self($data);
}
/** * {@inheritdoc} */ public function verify(JWKInterface $key, $input, $signature) { $this->checkKey($key); $pub = RSAKey::toPublic(new RSAKey($key)); if ($this->getSignatureMethod() === self::SIGNATURE_PSS) { return JoseRSA::verify($pub, $input, $signature, $this->getAlgorithm()); } else { return 1 === openssl_verify($input, $signature, $pub->toPEM(), $this->getAlgorithm()); } }