Jose\Algorithm\ContentEncryptionAlgorithmInterface::decryptContent PHP Method

decryptContent() public method

Decrypt data.
public decryptContent ( string $data, string $cek, string $iv, string | null $aad, string $encoded_protected_header, string $tag ) : string
$data string The data to decrypt
$cek string The content encryption key
$iv string The Initialization Vector
$aad string | null Additional Additional Authenticated Data
$encoded_protected_header string The Protected Header encoded in Base64Url
$tag string Tag
return string
    public function decryptContent($data, $cek, $iv, $aad, $encoded_protected_header, $tag);

Usage Example

Example #1
0
 /**
  * @param \Jose\Object\JWEInterface                           $jwe
  * @param string                                              $cek
  * @param \Jose\Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm
  * @param array                                               $complete_headers
  *
  * @return bool
  */
 private function decryptPayload(Object\JWEInterface &$jwe, $cek, Algorithm\ContentEncryptionAlgorithmInterface $content_encryption_algorithm, array $complete_headers)
 {
     $payload = $content_encryption_algorithm->decryptContent($jwe->getCiphertext(), $cek, $jwe->getIV(), null === $jwe->getAAD() ? null : Base64Url::encode($jwe->getAAD()), $jwe->getEncodedSharedProtectedHeaders(), $jwe->getTag());
     if (null === $payload) {
         return false;
     }
     $this->decompressIfNeeded($payload, $complete_headers);
     $decoded = json_decode($payload, true);
     $jwe = $jwe->withPayload(null === $decoded ? $payload : $decoded);
     return true;
 }