toPublic() public static method

public static toPublic ( RSAKey $private ) : RSAKey
$private RSAKey
return RSAKey
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function encryptKey(JWKInterface $key, $cek, array $complete_headers, array &$additional_headers)
 {
     $this->checkKey($key);
     $pub = RSAKey::toPublic(new RSAKey($key));
     if (self::ENCRYPTION_OAEP === $this->getEncryptionMode()) {
         $encrypted = JoseRSA::encrypt($pub, $cek, $this->getHashAlgorithm());
         Assertion::string($encrypted, 'Unable to encrypt the data.');
         return $encrypted;
     } else {
         $res = openssl_public_encrypt($cek, $encrypted, $pub->toPEM(), OPENSSL_PKCS1_PADDING | OPENSSL_RAW_DATA);
         Assertion::true($res, 'Unable to encrypt the data.');
         return $encrypted;
     }
 }