PluginProbe
Media Cloud Sync / 1.1.1
Media Cloud Sync v1.1.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Crypto / AbstractCryptoClientV2.php

AbstractCryptoClientV2.php in Media Cloud Sync 1.1.1, at includes/sdk/s3/Aws/Crypto/AbstractCryptoClientV2.php

99 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Crypto;
4
5 use Dudlewebs\WPMCS\s3\Aws\Crypto\Cipher\CipherMethod;
6 use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Stream;
7 /**
8 * @internal
9 */
10 abstract class AbstractCryptoClientV2
11 {
12 public static $supportedCiphers = ['gcm'];
13 public static $supportedKeyWraps = [KmsMaterialsProviderV2::WRAP_ALGORITHM_NAME];
14 public static $supportedSecurityProfiles = ['V2', 'V2_AND_LEGACY'];
15 public static $legacySecurityProfiles = ['V2_AND_LEGACY'];
16 /**
17 * Returns if the passed cipher name is supported for encryption by the SDK.
18 *
19 * @param string $cipherName The name of a cipher to verify is registered.
20 *
21 * @return bool If the cipher passed is in our supported list.
22 */
23 public static function isSupportedCipher($cipherName)
24 {
25 return \in_array($cipherName, self::$supportedCiphers, \true);
26 }
27 /**
28 * Returns an identifier recognizable by `openssl_*` functions, such as
29 * `aes-256-gcm`
30 *
31 * @param string $cipherName Name of the cipher being used for encrypting
32 * or decrypting.
33 * @param int $keySize Size of the encryption key, in bits, that will be
34 * used.
35 *
36 * @return string
37 */
38 protected abstract function getCipherOpenSslName($cipherName, $keySize);
39 /**
40 * Constructs a CipherMethod for the given name, initialized with the other
41 * data passed for use in encrypting or decrypting.
42 *
43 * @param string $cipherName Name of the cipher to generate for encrypting.
44 * @param string $iv Base Initialization Vector for the cipher.
45 * @param int $keySize Size of the encryption key, in bits, that will be
46 * used.
47 *
48 * @return CipherMethod
49 *
50 * @internal
51 */
52 protected abstract function buildCipherMethod($cipherName, $iv, $keySize);
53 /**
54 * Performs a reverse lookup to get the openssl_* cipher name from the
55 * AESName passed in from the MetadataEnvelope.
56 *
57 * @param $aesName
58 *
59 * @return string
60 *
61 * @internal
62 */
63 protected abstract function getCipherFromAesName($aesName);
64 /**
65 * Dependency to provide an interface for building an encryption stream for
66 * data given cipher details, metadata, and materials to do so.
67 *
68 * @param Stream $plaintext Plain-text data to be encrypted using the
69 * materials, algorithm, and data provided.
70 * @param array $options Options for use in encryption.
71 * @param MaterialsProviderV2 $provider A provider to supply and encrypt
72 * materials used in encryption.
73 * @param MetadataEnvelope $envelope A storage envelope for encryption
74 * metadata to be added to.
75 *
76 * @return AesStreamInterface
77 *
78 * @internal
79 */
80 public abstract function encrypt(Stream $plaintext, array $options, MaterialsProviderV2 $provider, MetadataEnvelope $envelope);
81 /**
82 * Dependency to provide an interface for building a decryption stream for
83 * cipher text given metadata and materials to do so.
84 *
85 * @param string $cipherText Plain-text data to be decrypted using the
86 * materials, algorithm, and data provided.
87 * @param MaterialsProviderInterface $provider A provider to supply and encrypt
88 * materials used in encryption.
89 * @param MetadataEnvelope $envelope A storage envelope for encryption
90 * metadata to be read from.
91 * @param array $options Options used for decryption.
92 *
93 * @return AesStreamInterface
94 *
95 * @internal
96 */
97 public abstract function decrypt($cipherText, MaterialsProviderInterfaceV2 $provider, MetadataEnvelope $envelope, array $options = []);
98 }
99