| 1 |
<?php |
| 2 |
|
| 3 |
namespace Dudlewebs\WPMCS\s3\Aws\Crypto; |
| 4 |
|
| 5 |
abstract class MaterialsProviderV2 implements MaterialsProviderInterfaceV2 |
| 6 |
{ |
| 7 |
private static $supportedKeySizes = [128 => \true, 256 => \true]; |
| 8 |
/** |
| 9 |
* Returns if the requested size is supported by AES. |
| 10 |
* |
| 11 |
* @param int $keySize Size of the requested key in bits. |
| 12 |
* |
| 13 |
* @return bool |
| 14 |
*/ |
| 15 |
public static function isSupportedKeySize($keySize) |
| 16 |
{ |
| 17 |
return isset(self::$supportedKeySizes[$keySize]); |
| 18 |
} |
| 19 |
/** |
| 20 |
* Returns the wrap algorithm name for this Provider. |
| 21 |
* |
| 22 |
* @return string |
| 23 |
*/ |
| 24 |
public abstract function getWrapAlgorithmName(); |
| 25 |
/** |
| 26 |
* Takes an encrypted content encryption key (CEK) and material description |
| 27 |
* for use decrypting the key according to the Provider's specifications. |
| 28 |
* |
| 29 |
* @param string $encryptedCek Encrypted key to be decrypted by the Provider |
| 30 |
* for use decrypting other data. |
| 31 |
* @param string $materialDescription Material Description for use in |
| 32 |
* decrypting the CEK. |
| 33 |
* @param string $options Options for use in decrypting the CEK. |
| 34 |
* |
| 35 |
* @return string |
| 36 |
*/ |
| 37 |
public abstract function decryptCek($encryptedCek, $materialDescription, $options); |
| 38 |
/** |
| 39 |
* @param string $keySize Length of a cipher key in bits for generating a |
| 40 |
* random content encryption key (CEK). |
| 41 |
* @param array $context Context map needed for key encryption |
| 42 |
* @param array $options Additional options to be used in CEK generation |
| 43 |
* |
| 44 |
* @return array |
| 45 |
*/ |
| 46 |
public abstract function generateCek($keySize, $context, $options); |
| 47 |
/** |
| 48 |
* @param string $openSslName Cipher OpenSSL name to use for generating |
| 49 |
* an initialization vector. |
| 50 |
* |
| 51 |
* @return string |
| 52 |
*/ |
| 53 |
public function generateIv($openSslName) |
| 54 |
{ |
| 55 |
return \openssl_random_pseudo_bytes(\openssl_cipher_iv_length($openSslName)); |
| 56 |
} |
| 57 |
} |
| 58 |
|