AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
KMSEncryptionMaterials.h
1
5#pragma once
6#include <aws/core/utils/crypto/EncryptionMaterials.h>
7#include <aws/core/utils/crypto/ContentCryptoMaterial.h>
8#include <aws/core/client/ClientConfiguration.h>
9#include <aws/kms/KMSClient.h>
10#include <aws/s3-encryption/s3Encryption_EXPORTS.h>
11
12#if defined(_MSC_VER) && (_MSC_VER <= 1900 )
13#pragma warning (disable : 4996)
14#endif
15namespace Aws
16{
17 namespace S3Encryption
18 {
19 namespace Materials
20 {
21 //identifier for materials description
22 extern AWS_S3ENCRYPTION_API const char* cmkID_Identifier;
23 extern AWS_S3ENCRYPTION_API const char* kmsEncryptionContextKey;
24
25 /*
26 * KMS Encryption Materials is responsible for handling the encryption/decryption of
27 * content encryption keys using KMS. This class will use a user provided customer
28 * master key ID to encrypt/decrypt keys. It also allows the user to pass in their
29 * own KMS Client, or a Client Configuration where it will create a KMS Client
30 * with that configuration.
31 */
33 {
34 public:
35 /*
36 Initialize with customer master key ID and client configuration. If no configuration is supplied, then use the default.
37 Client configuration will be used to setup KMS Client.
38 */
40
41 /*
42 Initialize with customer master key ID and KMS Client.
43 */
44 KMSEncryptionMaterialsBase(const Aws::String& customerMasterKeyID, const std::shared_ptr<Aws::KMS::KMSClient>& kmsClient);
45
46 /*
47 * This will encrypt the cek by calling to KMS. This will occur in place.
48 * It will set the key ID to the current customer master key ID and also set the encryption context to the materials
49 * description.
50 * A invalid customer master key ID will result in an empty content encryption key.
51 */
53
54 /*
55 * This will decrypt the cek by calling to KMS. This will occur in place.
56 * It will check to make sure that the key wrap algorithm is KMS and that the materials description matches
57 * the identifier + customer master key ID. It will then decrypt.
58 * A invalid customer master key ID will result in an empty content encryption key.
59 */
61
62 void SetKMSDecryptWithAnyCMK(bool allow) { m_allowDecryptWithAnyCMK = allow; }
63 bool IsKMSDecryptWithAnyCMKAllowed() const { return m_allowDecryptWithAnyCMK; }
64
65 protected:
66 virtual bool ValidateDecryptCEKMaterials(const Aws::Utils::Crypto::ContentCryptoMaterial& contentCryptoMaterial) const;
67
69 std::shared_ptr<Aws::KMS::KMSClient> m_kmsClient;
71 };
75 class
76 AWS_DEPRECATED("This class is in the maintenance mode, no new updates will be released, use KMSWithContextEncryptionMaterials. Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.")
77 AWS_S3ENCRYPTION_API KMSEncryptionMaterials : public KMSEncryptionMaterialsBase
78 {
79 public:
81 : KMSEncryptionMaterialsBase(customerMasterKeyID, clientConfig) {}
82
83 KMSEncryptionMaterials(const Aws::String& customerMasterKeyID, const std::shared_ptr<Aws::KMS::KMSClient>& kmsClient)
84 : KMSEncryptionMaterialsBase(customerMasterKeyID, kmsClient) {}
85 };
86
95 {
96 public:
98 : KMSEncryptionMaterialsBase(customerMasterKeyID, clientConfig)
99 {
100 SetKMSDecryptWithAnyCMK(false);
101 }
102
103 KMSWithContextEncryptionMaterials(const Aws::String& customerMasterKeyID, const std::shared_ptr<Aws::KMS::KMSClient>& kmsClient)
104 : KMSEncryptionMaterialsBase(customerMasterKeyID, kmsClient)
105 {
106 SetKMSDecryptWithAnyCMK(false);
107 }
108
110 };
111 }//namespace Materials
112 }//namespace S3Encryption
113}//namespace Aws
KMSEncryptionMaterialsBase(const Aws::String &customerMasterKeyID, const std::shared_ptr< Aws::KMS::KMSClient > &kmsClient)
virtual bool ValidateDecryptCEKMaterials(const Aws::Utils::Crypto::ContentCryptoMaterial &contentCryptoMaterial) const
Aws::Utils::Crypto::CryptoOutcome EncryptCEK(Aws::Utils::Crypto::ContentCryptoMaterial &contentCryptoMaterial) override
Aws::Utils::Crypto::CryptoOutcome DecryptCEK(Aws::Utils::Crypto::ContentCryptoMaterial &contentCryptoMaterial) override
KMSEncryptionMaterialsBase(const Aws::String &customerMasterKeyID, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
KMSEncryptionMaterials(const Aws::String &customerMasterKeyID, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
KMSEncryptionMaterials(const Aws::String &customerMasterKeyID, const std::shared_ptr< Aws::KMS::KMSClient > &kmsClient)
KMSWithContextEncryptionMaterials(const Aws::String &customerMasterKeyID, const std::shared_ptr< Aws::KMS::KMSClient > &kmsClient)
Aws::Utils::Crypto::CryptoOutcome EncryptCEK(Aws::Utils::Crypto::ContentCryptoMaterial &contentCryptoMaterial) override
KMSWithContextEncryptionMaterials(const Aws::String &customerMasterKeyID, const Aws::Client::ClientConfiguration &clientConfig=Aws::Client::ClientConfiguration())
AWS_S3ENCRYPTION_API const char * cmkID_Identifier
AWS_S3ENCRYPTION_API const char * kmsEncryptionContextKey
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String