/**
* @param \Jose\Object\JWEInterface $jwe
* @param string $cek
* @param \Jose\Algorithm\ContentEncryption\ContentEncryptionInterface $content_encryption_algorithm
*
* @return bool
*/
private function decryptPayload(JWEInterface &$jwe, $cek, $content_encryption_algorithm)
{
$payload = $content_encryption_algorithm->decryptContent($jwe->getCiphertext(), $cek, $jwe->getIV(), $jwe->getAAD(), $jwe->getEncodedProtectedHeader(), $jwe->getTag());
if (null === $payload) {
return false;
}
if ($jwe->hasHeader('zip')) {
$compression_method = $this->getCompressionMethod($jwe->getHeader('zip'));
$payload = $compression_method->uncompress($payload);
if (!is_string($payload)) {
throw new \RuntimeException('Decompression failed');
}
}
$payload = $this->getPayloadConverter()->convertStringToPayload($jwe->getHeaders(), $payload);
$result = new JWE($jwe->getInput(), $jwe->getCiphertext(), $jwe->getEncryptedKey(), $jwe->getIV(), $jwe->getAAD(), $jwe->getTag(), $jwe->getEncodedProtectedHeader(), $jwe->getUnprotectedHeaders(), $payload);
$jwe = $result;
return true;
}