v2: Updates

* Simplifies & beautifies everything
* Introduces a new Class system.
* Errors are defaulted to AWS's handler.
* New function names & more efficient handling.
* Should fix a majority of the errors.

Please read the README for more!
This commit is contained in:
Devang Srivastava 2020-09-28 15:32:51 +05:30
parent ad0726e41e
commit e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions

View file

@ -3,6 +3,7 @@ namespace Aws\Crypto;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\LimitStream;
use Psr\Http\Message\StreamInterface;
trait DecryptionTrait
{
@ -35,12 +36,13 @@ trait DecryptionTrait
/**
* Builds an AesStreamInterface using cipher options loaded from the
* MetadataEnvelope and MaterialsProvider.
* MetadataEnvelope and MaterialsProvider. Can decrypt data from both the
* legacy and V2 encryption client workflows.
*
* @param string $cipherText Plain-text data to be encrypted using the
* materials, algorithm, and data provided.
* @param MaterialsProvider $provider A provider to supply and encrypt
* materials used in encryption.
* @param MaterialsProviderInterface $provider A provider to supply and encrypt
* materials used in encryption.
* @param MetadataEnvelope $envelope A storage envelope for encryption
* metadata to be read from.
* @param array $cipherOptions Additional verification options.
@ -52,9 +54,9 @@ trait DecryptionTrait
*
* @internal
*/
protected function decrypt(
public function decrypt(
$cipherText,
MaterialsProvider $provider,
MaterialsProviderInterface $provider,
MetadataEnvelope $envelope,
array $cipherOptions = []
) {
@ -79,18 +81,18 @@ trait DecryptionTrait
$envelope[MetadataEnvelope::CONTENT_CRYPTO_SCHEME_HEADER]
);
$decryptionSteam = $this->getDecryptingStream(
$decryptionStream = $this->getDecryptingStream(
$cipherText,
$cek,
$cipherOptions
);
unset($cek);
return $decryptionSteam;
return $decryptionStream;
}
private function getTagFromCiphertextStream(
Psr7\Stream $cipherText,
StreamInterface $cipherText,
$tagLength
) {
$cipherTextSize = $cipherText->getSize();
@ -106,7 +108,7 @@ trait DecryptionTrait
}
private function getStrippedCiphertextStream(
Psr7\Stream $cipherText,
StreamInterface $cipherText,
$tagLength
) {
$cipherTextSize = $cipherText->getSize();