PHP 7.4.33
Preview: AesGcmDecryptingStream.php Size: 2.61 KB
/home/godevadmin/www/admin/vendor/aws/Aws/Crypto/AesGcmDecryptingStream.php

<?php
namespace Aws\Crypto;

use Aws\Exception\CryptoException;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\StreamDecoratorTrait;
use Psr\Http\Message\StreamInterface;
use Aws\Crypto\Polyfill\AesGcm;
use Aws\Crypto\Polyfill\Key;

/**
 * @internal Represents a stream of data to be gcm decrypted.
 */
class AesGcmDecryptingStream implements AesStreamInterface
{
    use StreamDecoratorTrait;

    private $aad;

    private $initializationVector;

    private $key;

    private $keySize;

    private $cipherText;

    private $tag;

    private $tagLength;

    /**
     * @param StreamInterface $cipherText
     * @param string $key
     * @param string $initializationVector
     * @param string $tag
     * @param string $aad
     * @param int $tagLength
     * @param int $keySize
     */
    public function __construct(
        StreamInterface $cipherText,
        $key,
        $initializationVector,
        $tag,
        $aad = '',
        $tagLength = 128,
        $keySize = 256
    ) {
        $this->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\Utils::streamFor(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\Utils::streamFor($result);
        }
    }

    public function isWritable()
    {
        return false;
    }
}

Directory Contents

Dirs: 2 × Files: 20

Name Size Perms Modified Actions
Cipher DIR
- drwxrwxr-x 2024-06-18 20:10:10
Edit Download
Polyfill DIR
- drwxrwxr-x 2024-06-18 20:10:10
Edit Download
4.11 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
4.00 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
3.63 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
3.80 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
2.61 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
2.82 KB lrwxrwxr-x 2024-06-18 20:10:08
Edit Download
686 B lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
759 B lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
6.14 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
9.29 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
7.05 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
7.24 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
4.01 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
3.53 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
3.33 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.87 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.72 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
2.07 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.70 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.00 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).