OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
Xpress_backup
/
vendor
/
aws
/
aws-sdk-php
/
tests
/
Crypto
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:19 AM
rwxr-xr-x
📄
AesDecryptingStreamTest.php
4.66 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
AesEncryptingStreamTest.php
5.62 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
AesEncryptionStreamTestTrait.php
2.47 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
AesGcmDecryptingStreamTest.php
4.74 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
AesGcmEncryptingStreamTest.php
7.22 KB
05/19/2025 10:07:19 AM
rw-r--r--
📁
Cipher
-
05/19/2025 10:07:19 AM
rwxr-xr-x
📄
KmsMaterialsProviderTest.php
1.93 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
KmsMaterialsProviderV2Test.php
7.24 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
MetadataEnvelopeTest.php
1.23 KB
05/19/2025 10:07:19 AM
rw-r--r--
📁
Polyfill
-
05/19/2025 10:07:19 AM
rwxr-xr-x
📄
RandomByteStream.php
935 bytes
05/19/2025 10:07:19 AM
rw-r--r--
📄
UsesCryptoParamsTrait.php
3.66 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
UsesCryptoParamsTraitV2.php
2.69 KB
05/19/2025 10:07:19 AM
rw-r--r--
📄
UsesMetadataEnvelopeTrait.php
2.53 KB
05/19/2025 10:07:19 AM
rw-r--r--
Editing: AesDecryptingStreamTest.php
Close
<?php namespace Aws\Test\Crypto; use Aws\Crypto\AesDecryptingStream; use Aws\Crypto\Cipher\Cbc; use Aws\Crypto\Cipher\CipherMethod; use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; class AesDecryptingStreamTest extends TestCase { const KB = 1024; const MB = 1048576; use AesEncryptionStreamTestTrait; /** * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv */ public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, CipherMethod $iv ) { $key = 'foo'; $cipherText = openssl_encrypt( (string) $plainText, $iv->getOpenSslName(), $key, OPENSSL_RAW_DATA, $iv->getCurrentIv() ); $aesDecryptingStream = new AesDecryptingStream( Psr7\Utils::streamFor($cipherText), $key, $iv ); $this->assertSame( (string) $aesDecryptingStream, (string) $plainText ); $this->assertSame( $iv->getOpenSslName(), $aesDecryptingStream->getOpenSslName() ); $this->assertSame( $iv->getAesName(), $aesDecryptingStream->getAesName() ); } /** * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv */ public function testReportsSizeOfPlaintextWherePossible( StreamInterface $plainText, CipherMethod $iv ) { $key = 'foo'; $cipherText = openssl_encrypt( (string) $plainText, $iv->getOpenSslName(), $key, OPENSSL_RAW_DATA, $iv->getCurrentIv() ); $deciphered = new AesDecryptingStream( Psr7\Utils::streamFor($cipherText), $key, $iv ); if ($iv->requiresPadding()) { $this->assertNull($deciphered->getSize()); } else { $this->assertSame($plainText->getSize(), $deciphered->getSize()); } } /** * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv */ public function testSupportsRewinding( StreamInterface $plainText, CipherMethod $iv ) { $key = 'foo'; $cipherText = openssl_encrypt( (string) $plainText, $iv->getOpenSslName(), $key, OPENSSL_RAW_DATA, $iv->getCurrentIv() ); $deciphered = new AesDecryptingStream(Psr7\Utils::streamFor($cipherText), $key, $iv); $firstBytes = $deciphered->read(256 * 2 + 3); $deciphered->rewind(); $this->assertSame($firstBytes, $deciphered->read(256 * 2 + 3)); } /** * @dataProvider cipherMethodProvider * * @param CipherMethod $iv */ public function testMemoryUsageRemainsConstant(CipherMethod $iv) { $memory = memory_get_usage(); $stream = new AesDecryptingStream(new RandomByteStream(6 * self::MB), 'foo', $iv); while (!$stream->eof()) { $stream->read(self::MB); } // Reading 1MB chunks should take 2MB $this->assertLessThanOrEqual($memory + 2 * self::MB, memory_get_usage()); } public function testIsNotWritable() { $stream = new AesDecryptingStream( new RandomByteStream(124 * self::MB), 'foo', new Cbc(openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'))) ); $this->assertFalse($stream->isWritable()); } public function testDoesNotSupportArbitrarySeeking() { $this->expectException(\LogicException::class); $stream = new AesDecryptingStream( new RandomByteStream(124 * self::MB), 'foo', new Cbc(openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'))) ); $stream->seek(1); } /** * @dataProvider cipherMethodProvider * * @param CipherMethod $cipherMethod */ public function testReturnsEmptyStringWhenSourceStreamEmpty( CipherMethod $cipherMethod ) { $stream = new AesDecryptingStream(Psr7\Utils::streamFor(''), 'foo', $cipherMethod); $this->assertEmpty($stream->read(self::MB)); $this->assertSame($stream->read(self::MB), ''); } }