PluginProbe
Media Cloud Sync / 1.2.9
Media Cloud Sync v1.2.9
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 / AbstractCryptoClient.php

AbstractCryptoClient.php in Media Cloud Sync 1.2.9, at includes/sdk/s3/Aws/Crypto/AbstractCryptoClient.php

103 lines 4.0 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\Aws\Crypto\Cipher\Cbc;
7 use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Stream;
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 public static $supportedKeyWraps = [KmsMaterialsProvider::WRAP_ALGORITHM_NAME];
19 /**
20 * Returns if the passed cipher name is supported for encryption by the SDK.
21 *
22 * @param string $cipherName The name of a cipher to verify is registered.
23 *
24 * @return bool If the cipher passed is in our supported list.
25 */
26 public static function isSupportedCipher($cipherName)
27 {
28 return \in_array($cipherName, self::$supportedCiphers);
29 }
30 /**
31 * Returns an identifier recognizable by `openssl_*` functions, such as
32 * `aes-256-cbc` or `aes-128-ctr`.
33 *
34 * @param string $cipherName Name of the cipher being used for encrypting
35 * or decrypting.
36 * @param int $keySize Size of the encryption key, in bits, that will be
37 * used.
38 *
39 * @return string
40 */
41 protected abstract function getCipherOpenSslName($cipherName, $keySize);
42 /**
43 * Constructs a CipherMethod for the given name, initialized with the other
44 * data passed for use in encrypting or decrypting.
45 *
46 * @param string $cipherName Name of the cipher to generate for encrypting.
47 * @param string $iv Base Initialization Vector for the cipher.
48 * @param int $keySize Size of the encryption key, in bits, that will be
49 * used.
50 *
51 * @return CipherMethod
52 *
53 * @internal
54 */
55 protected abstract function buildCipherMethod($cipherName, $iv, $keySize);
56 /**
57 * Performs a reverse lookup to get the openssl_* cipher name from the
58 * AESName passed in from the MetadataEnvelope.
59 *
60 * @param $aesName
61 *
62 * @return string
63 *
64 * @internal
65 */
66 protected abstract function getCipherFromAesName($aesName);
67 /**
68 * Dependency to provide an interface for building an encryption stream for
69 * data given cipher details, metadata, and materials to do so.
70 *
71 * @param Stream $plaintext Plain-text data to be encrypted using the
72 * materials, algorithm, and data provided.
73 * @param array $cipherOptions Options for use in determining the cipher to
74 * be used for encrypting data.
75 * @param MaterialsProvider $provider A provider to supply and encrypt
76 * materials used in encryption.
77 * @param MetadataEnvelope $envelope A storage envelope for encryption
78 * metadata to be added to.
79 *
80 * @return AesStreamInterface
81 *
82 * @internal
83 */
84 public abstract function encrypt(Stream $plaintext, array $cipherOptions, MaterialsProvider $provider, MetadataEnvelope $envelope);
85 /**
86 * Dependency to provide an interface for building a decryption stream for
87 * cipher text given metadata and materials to do so.
88 *
89 * @param string $cipherText Plain-text data to be decrypted using the
90 * materials, algorithm, and data provided.
91 * @param MaterialsProviderInterface $provider A provider to supply and encrypt
92 * materials used in encryption.
93 * @param MetadataEnvelope $envelope A storage envelope for encryption
94 * metadata to be read from.
95 * @param array $cipherOptions Additional verification options.
96 *
97 * @return AesStreamInterface
98 *
99 * @internal
100 */
101 public abstract function decrypt($cipherText, MaterialsProviderInterface $provider, MetadataEnvelope $envelope, array $cipherOptions = []);
102 }
103