PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / Crypto / AbstractCryptoClient.php
transferito / vendor / aws / aws-sdk-php / src / Crypto Last commit date
Cipher 11 months ago Polyfill 11 months ago AbstractCryptoClient.php 11 months ago AbstractCryptoClientV2.php 11 months ago AesDecryptingStream.php 11 months ago AesEncryptingStream.php 11 months ago AesGcmDecryptingStream.php 11 months ago AesGcmEncryptingStream.php 11 months ago AesStreamInterface.php 11 months ago AesStreamInterfaceV2.php 11 months ago DecryptionTrait.php 11 months ago DecryptionTraitV2.php 11 months ago EncryptionTrait.php 11 months ago EncryptionTraitV2.php 11 months ago KmsMaterialsProvider.php 11 months ago KmsMaterialsProviderV2.php 11 months ago MaterialsProvider.php 11 months ago MaterialsProviderInterface.php 11 months ago MaterialsProviderInterfaceV2.php 11 months ago MaterialsProviderV2.php 11 months ago MetadataEnvelope.php 11 months ago MetadataStrategyInterface.php 11 months ago
AbstractCryptoClient.php
122 lines
1 <?php
2 namespace Aws\Crypto;
3
4 use Aws\Crypto\Cipher\CipherMethod;
5 use Aws\Crypto\Cipher\Cbc;
6 use GuzzleHttp\Psr7\Stream;
7
8 /**
9 * Legacy abstract encryption client. New workflows should use
10 * AbstractCryptoClientV2.
11 *
12 * @deprecated
13 * @internal
14 */
15 abstract class AbstractCryptoClient
16 {
17 public static $supportedCiphers = ['cbc', 'gcm'];
18
19 public static $supportedKeyWraps = [
20 KmsMaterialsProvider::WRAP_ALGORITHM_NAME
21 ];
22
23 /**
24 * Returns if the passed cipher name is supported for encryption by the SDK.
25 *
26 * @param string $cipherName The name of a cipher to verify is registered.
27 *
28 * @return bool If the cipher passed is in our supported list.
29 */
30 public static function isSupportedCipher($cipherName)
31 {
32 return in_array($cipherName, self::$supportedCiphers);
33 }
34
35 /**
36 * Returns an identifier recognizable by `openssl_*` functions, such as
37 * `aes-256-cbc` or `aes-128-ctr`.
38 *
39 * @param string $cipherName Name of the cipher being used for encrypting
40 * or decrypting.
41 * @param int $keySize Size of the encryption key, in bits, that will be
42 * used.
43 *
44 * @return string
45 */
46 abstract protected function getCipherOpenSslName($cipherName, $keySize);
47
48 /**
49 * Constructs a CipherMethod for the given name, initialized with the other
50 * data passed for use in encrypting or decrypting.
51 *
52 * @param string $cipherName Name of the cipher to generate for encrypting.
53 * @param string $iv Base Initialization Vector for the cipher.
54 * @param int $keySize Size of the encryption key, in bits, that will be
55 * used.
56 *
57 * @return CipherMethod
58 *
59 * @internal
60 */
61 abstract protected function buildCipherMethod($cipherName, $iv, $keySize);
62
63 /**
64 * Performs a reverse lookup to get the openssl_* cipher name from the
65 * AESName passed in from the MetadataEnvelope.
66 *
67 * @param $aesName
68 *
69 * @return string
70 *
71 * @internal
72 */
73 abstract protected function getCipherFromAesName($aesName);
74
75 /**
76 * Dependency to provide an interface for building an encryption stream for
77 * data given cipher details, metadata, and materials to do so.
78 *
79 * @param Stream $plaintext Plain-text data to be encrypted using the
80 * materials, algorithm, and data provided.
81 * @param array $cipherOptions Options for use in determining the cipher to
82 * be used for encrypting data.
83 * @param MaterialsProvider $provider A provider to supply and encrypt
84 * materials used in encryption.
85 * @param MetadataEnvelope $envelope A storage envelope for encryption
86 * metadata to be added to.
87 *
88 * @return AesStreamInterface
89 *
90 * @internal
91 */
92 abstract public function encrypt(
93 Stream $plaintext,
94 array $cipherOptions,
95 MaterialsProvider $provider,
96 MetadataEnvelope $envelope
97 );
98
99 /**
100 * Dependency to provide an interface for building a decryption stream for
101 * cipher text given metadata and materials to do so.
102 *
103 * @param string $cipherText Plain-text data to be decrypted using the
104 * materials, algorithm, and data provided.
105 * @param MaterialsProviderInterface $provider A provider to supply and encrypt
106 * materials used in encryption.
107 * @param MetadataEnvelope $envelope A storage envelope for encryption
108 * metadata to be read from.
109 * @param array $cipherOptions Additional verification options.
110 *
111 * @return AesStreamInterface
112 *
113 * @internal
114 */
115 abstract public function decrypt(
116 $cipherText,
117 MaterialsProviderInterface $provider,
118 MetadataEnvelope $envelope,
119 array $cipherOptions = []
120 );
121 }
122