Jose\KeyConverter\RSAKey::toPublic PHP Method

toPublic() public static method

public static toPublic ( RSAKey $private ) : RSAKey
$private RSAKey
return RSAKey
    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);
    }

Usage Example

Beispiel #1
0
 /**
  * {@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());
     }
 }
All Usage Examples Of Jose\KeyConverter\RSAKey::toPublic