cipherText = $cipherText; $this->key = $key; $this->initializationVector = $initializationVector; $this->tag = $tag; $this->aad = $aad; $this->tagLength = $tagLength; $this->keySize = $keySize; } public function getOpenSslName() { return "aes-{$this->keySize}-gcm"; } public function getAesName() { return 'AES/GCM/NoPadding'; } public function getCurrentIv() { return $this->initializationVector; } public function createStream() { if (version_compare(PHP_VERSION, '7.1', '<')) { return Psr7\stream_for(AesGcm::decrypt( (string) $this->cipherText, $this->initializationVector, new Key($this->key), $this->aad, $this->tag, $this->keySize )); } else { $result = \openssl_decrypt( (string)$this->cipherText, $this->getOpenSslName(), $this->key, OPENSSL_RAW_DATA, $this->initializationVector, $this->tag, $this->aad ); if ($result === false) { throw new CryptoException('The requested object could not be' . ' decrypted due to an invalid authentication tag.'); } return Psr7\stream_for($result); } } public function isWritable() { return false; } }