getCiphertext() public method

public getCiphertext ( ) : string | null
return string | null The cyphertext
Beispiel #1
0
 /**
  * @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;
 }
Beispiel #2
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;
 }