[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: KmsMaterialsProviderV2.php
<?php namespace Aws\Crypto; use Aws\Exception\CryptoException; use Aws\Kms\KmsClient; /** * Uses KMS to supply materials for encrypting and decrypting data. This * V2 implementation should be used with the V2 encryption clients (i.e. * S3EncryptionClientV2). */ class KmsMaterialsProviderV2 extends MaterialsProviderV2 implements MaterialsProviderInterfaceV2 { const WRAP_ALGORITHM_NAME = 'kms+context'; private $kmsClient; private $kmsKeyId; /** * @param KmsClient $kmsClient A KMS Client for use encrypting and * decrypting keys. * @param string $kmsKeyId The private KMS key id to be used for encrypting * and decrypting keys. */ public function __construct( KmsClient $kmsClient, $kmsKeyId = null ) { $this->kmsClient = $kmsClient; $this->kmsKeyId = $kmsKeyId; } /** * @inheritDoc */ public function getWrapAlgorithmName() { return self::WRAP_ALGORITHM_NAME; } /** * @inheritDoc */ public function decryptCek($encryptedCek, $materialDescription, $options) { $params = [ 'CiphertextBlob' => $encryptedCek, 'EncryptionContext' => $materialDescription ]; if (empty($options['@KmsAllowDecryptWithAnyCmk'])) { if (empty($this->kmsKeyId)) { throw new CryptoException('KMS CMK ID was not specified and the' . ' operation is not opted-in to attempting to use any valid' . ' CMK it discovers. Please specify a CMK ID, or explicitly' . ' enable attempts to use any valid KMS CMK with the' . ' @KmsAllowDecryptWithAnyCmk option.'); } $params['KeyId'] = $this->kmsKeyId; } $result = $this->kmsClient->decrypt($params); return $result['Plaintext']; } /** * @inheritDoc */ public function generateCek($keySize, $context, $options) { if (empty($this->kmsKeyId)) { throw new CryptoException('A KMS key id is required for encryption' . ' with KMS keywrap. Use a KmsMaterialsProviderV2 that has been' . ' instantiated with a KMS key id.'); } $options = array_change_key_case($options); if (!isset($options['@kmsencryptioncontext']) || !is_array($options['@kmsencryptioncontext']) ) { throw new CryptoException("'@KmsEncryptionContext' is a" . " required argument when using KmsMaterialsProviderV2, and" . " must be an associative array (or empty array)."); } if (isset($options['@kmsencryptioncontext']['aws:x-amz-cek-alg'])) { throw new CryptoException("Conflict in reserved @KmsEncryptionContext" . " key aws:x-amz-cek-alg. This value is reserved for the S3" . " Encryption Client and cannot be set by the user."); } $context = array_merge($options['@kmsencryptioncontext'], $context); $result = $this->kmsClient->generateDataKey([ 'KeyId' => $this->kmsKeyId, 'KeySpec' => "AES_{$keySize}", 'EncryptionContext' => $context ]); return [ 'Plaintext' => $result['Plaintext'], 'Ciphertext' => base64_encode($result['CiphertextBlob']), 'UpdatedContext' => $context ]; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.64 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002