PluginProbe
Media Cloud Sync / 1.2.10
Media Cloud Sync v1.2.10
1.4.2 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 All 36 releases
media-cloud-sync / includes / sdk / s3 / Aws / Crypto / Cipher / CipherBuilderTrait.php

CipherBuilderTrait.php in Media Cloud Sync 1.2.10, at includes/sdk/s3/Aws/Crypto/Cipher/CipherBuilderTrait.php

67 lines 1.9 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\Cipher;
4
5 use Dudlewebs\WPMCS\s3\Aws\Exception\CryptoException;
6 trait CipherBuilderTrait
7 {
8 /**
9 * Returns an identifier recognizable by `openssl_*` functions, such as
10 * `aes-256-cbc` or `aes-128-ctr`.
11 *
12 * @param string $cipherName Name of the cipher being used for encrypting
13 * or decrypting.
14 * @param int $keySize Size of the encryption key, in bits, that will be
15 * used.
16 *
17 * @return string
18 */
19 protected function getCipherOpenSslName($cipherName, $keySize)
20 {
21 return "aes-{$keySize}-{$cipherName}";
22 }
23 /**
24 * Constructs a CipherMethod for the given name, initialized with the other
25 * data passed for use in encrypting or decrypting.
26 *
27 * @param string $cipherName Name of the cipher to generate for encrypting.
28 * @param string $iv Base Initialization Vector for the cipher.
29 * @param int $keySize Size of the encryption key, in bits, that will be
30 * used.
31 *
32 * @return CipherMethod
33 *
34 * @internal
35 */
36 protected function buildCipherMethod($cipherName, $iv, $keySize)
37 {
38 switch ($cipherName) {
39 case 'cbc':
40 return new Cbc($iv, $keySize);
41 default:
42 return null;
43 }
44 }
45 /**
46 * Performs a reverse lookup to get the openssl_* cipher name from the
47 * AESName passed in from the MetadataEnvelope.
48 *
49 * @param $aesName
50 *
51 * @return string
52 *
53 * @internal
54 */
55 protected function getCipherFromAesName($aesName)
56 {
57 switch ($aesName) {
58 case 'AES/GCM/NoPadding':
59 return 'gcm';
60 case 'AES/CBC/PKCS5Padding':
61 return 'cbc';
62 default:
63 throw new CryptoException('Unrecognized or unsupported' . ' AESName for reverse lookup.');
64 }
65 }
66 }
67