Example #1
0
File: JWE.php Project: sop/jwx
 /**
  * Decrypt content using a key from the given JWK set.
  *
  * Correct key shall be sought by the key ID indicated by the header.
  *
  * @param JWKSet $set Set of JSON Web Keys
  * @throws \RuntimeException If algorithm initialization fails
  * @return string Plaintext payload
  */
 public function decryptWithJWKSet(JWKSet $set)
 {
     if (!count($set)) {
         throw new \RuntimeException("No keys.");
     }
     $header = $this->header();
     $factory = new KeyAlgorithmFactory($header);
     $key_algo = $factory->algoByKeys($set);
     $enc_algo = EncryptionAlgorithmFactory::algoByHeader($header);
     return $this->decrypt($key_algo, $enc_algo);
 }