AWS SDK for C++

AWS SDK for C++ Version 1.11.718

Loading...
Searching...
No Matches
CryptoConfiguration.h
1
5#pragma once
6
7#include <aws/s3-encryption/s3Encryption_EXPORTS.h>
8#include <aws/s3-encryption/materials/KMSEncryptionMaterials.h>
9#include <aws/s3-encryption/materials/SimpleEncryptionMaterials.h>
10namespace Aws
11{
12 namespace S3Encryption
13 {
15
16 enum class StorageMethod
17 {
20 };
21
22 enum class CryptoMode
23 {
24 /*
25 * Encrypt with a non-authenticated mode of operation.
26 *
27 * NOTE: This feature is in maintenance mode, no new updates will be released.
28 * Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.
29 */
31 /*
32 * Encrypt with an authenticated mode of operation, but do not require that objects be authenticated on Get.
33 *
34 * NOTE: This feature is in maintenance mode, no new updates will be released.
35 * Please see https://docs.aws.amazon.com/general/latest/gr/aws_sdk_cryptography.html for more information.
36 */
38 /*
39 * Encrypt and decrypt with an authenticated mode of operation only.
40 */
42 };
43
44 enum class SecurityProfile
45 {
46 V2, // Client decrypt objects encrypted using best practice key wrap algorithms (KMS_CONTEXT and AES_GCM ) and best practice content crypto schemes (AES_GCM), but does not require Key Commitment.
47 V2_AND_LEGACY // Client will try to decrypt objects encrypted using all key wrap algorithms (KMS_CONTEXT, KMS, AES_KeyWrap, AES_GCM) and content crypto schemes (AES_GCM, AES_CBC), and does not require Key Commitment.
48 };
49
50 enum class CommitmentPolicy {
51 FORBID_ENCRYPT_ALLOW_DECRYPT, // Encrypt as V2, decrypt any
52 REQUIRE_ENCRYPT_ALLOW_DECRYPT, // Encrypt as V3, decrypt any
53 REQUIRE_ENCRYPT_REQUIRE_DECRYPT // Encrypt as V3, decrypt only V3
54 };
55
56 //= ../specification/s3-encryption/decryption.md#ranged-gets
57 //= type=implication
58 //# The S3EC MAY support the "range" parameter on GetObject which specifies a subset of bytes to download and decrypt.
59 enum class RangeGetMode
60 {
61 DISABLED, // Range get is not allowed
62 ALL, // Range get is allowed
63 };
64
65 enum class AlgorithmSuite {
66 AES_GCM,
67 // AES_GCM_WITH_COMMITMENT is AES_GCM, but with key commitment.
68 // That is, the encrypted key is used to derive both an encryption key and a commitment key
69 // The commitment key is stored in the meta data.
70 // On decrypt, commitment key is derived and must match the stored commitment key.
72 };
73
74 class AWS_S3ENCRYPTION_API CryptoConfiguration
75 {
76 public:
77 /*
78 * Default constructor.
79 */
81
82 /*
83 * Constructor that accepts a storage method and defaults the cryptoMode to authenticated encryption.
84 */
86
87 /*
88 * Constructor that accepts a crypto mode and defaults the storage method to metadata.
89 */
91
92 /*
93 * Constructor that accepts storage method and crypto mode. Default storage method is metadata and default crypto mode is authenticated encryption.
94 */
96
101 {
102 return m_storageMethod;
103 }
104
109 {
110 return m_cryptoMode;
111 }
112
117 {
118 return m_algorithmSuite;
119 }
120
125 {
126 return m_commitmentPolicy;
127 }
128
132 inline void SetStorageMethod(StorageMethod storageMethod)
133 {
134 m_storageMethod = storageMethod;
135 }
136
140 inline void SetCryptoMode(CryptoMode cryptoMode)
141 {
142 m_cryptoMode = cryptoMode;
143 }
144
145 private:
146 inline void SetSecurityProfile(SecurityProfile profile) { m_securityProfile = profile; }
147 inline void SetUnAuthenticatedRangeGet(RangeGetMode mode) { m_unAuthenticatedRangeGet = mode; }
148 inline RangeGetMode GetUnAuthenticatedRangeGet() const { return m_unAuthenticatedRangeGet; }
149 inline SecurityProfile GetSecurityProfile() const { return m_securityProfile; }
150 inline void SetCommitmentPolicy(CommitmentPolicy commitmentPolicy) { m_commitmentPolicy = commitmentPolicy; }
151 inline void SetEncryptionAlgorithm(AlgorithmSuite algorithmSuite) { m_algorithmSuite = algorithmSuite; }
152
153 StorageMethod m_storageMethod;
154 CryptoMode m_cryptoMode;
155 RangeGetMode m_unAuthenticatedRangeGet;
156 SecurityProfile m_securityProfile;
157 AlgorithmSuite m_algorithmSuite;
158 CommitmentPolicy m_commitmentPolicy;
159
163 };
164
165 class AWS_S3ENCRYPTION_API CryptoConfigurationV2
166 {
167 public:
168 CryptoConfigurationV2(const std::shared_ptr<Aws::S3Encryption::Materials::KMSWithContextEncryptionMaterials>& materials);
169 CryptoConfigurationV2(const std::shared_ptr<Aws::S3Encryption::Materials::SimpleEncryptionMaterialsWithGCMAAD>& materials);
170
171 inline void SetSecurityProfile(SecurityProfile profile) { m_securityProfile = profile; }
172 inline void SetUnAuthenticatedRangeGet(RangeGetMode mode) { m_unAuthenticatedRangeGet = mode; }
173 inline void SetStorageMethod(StorageMethod storageMethod) { m_storageMethod = storageMethod; }
174
175 inline SecurityProfile GetSecurityProfile() const { return m_securityProfile; }
176 inline RangeGetMode GetUnAuthenticatedRangeGet() const { return m_unAuthenticatedRangeGet; }
177 inline StorageMethod GetStorageMethod() const { return m_storageMethod; }
178 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> GetEncryptionMaterials() const { return m_encryptionMaterials; }
179 private:
180 StorageMethod m_storageMethod;
181 RangeGetMode m_unAuthenticatedRangeGet;
182 SecurityProfile m_securityProfile;
183 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> m_encryptionMaterials;
184 };
185
186 //= ../specification/s3-encryption/client.md#aws-sdk-compatibility
187 //= type=implication
188 //# The S3EC MUST provide a different set of configuration options than the conventional S3 client.
189 class AWS_S3ENCRYPTION_API CryptoConfigurationV3
190 {
191 public:
192 CryptoConfigurationV3(const std::shared_ptr<Aws::S3Encryption::Materials::KMSWithContextEncryptionMaterials>& materials);
193 CryptoConfigurationV3(const std::shared_ptr<Aws::S3Encryption::Materials::SimpleEncryptionMaterialsWithGCMAAD>& materials);
194
195 inline void AllowLegacy(bool allow = true) { m_securityProfile = (allow ? SecurityProfile::V2_AND_LEGACY : SecurityProfile::V2); }
196 inline void SetCommitmentPolicy(CommitmentPolicy commitmentPolicy) { m_commitmentPolicy = commitmentPolicy; }
197 inline void SetUnAuthenticatedRangeGet(RangeGetMode mode) { m_unAuthenticatedRangeGet = mode; }
198 inline void SetStorageMethod(StorageMethod storageMethod) { m_storageMethod = storageMethod; }
199
200 inline bool GetAllowLegacy() const { return m_securityProfile == SecurityProfile::V2_AND_LEGACY; }
201 inline RangeGetMode GetUnAuthenticatedRangeGet() const { return m_unAuthenticatedRangeGet; }
202 inline StorageMethod GetStorageMethod() const { return m_storageMethod; }
203 inline CommitmentPolicy GetCommitmentPolicy() const { return m_commitmentPolicy; }
204 inline SecurityProfile GetSecurityProfile() const { return m_securityProfile; }
205 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> GetEncryptionMaterials() const { return m_encryptionMaterials; }
206
207 private:
208 //= ../specification/s3-encryption/client.md#enable-legacy-wrapping-algorithms
209 //= type=implication
210 //# The S3EC MUST support the option to enable or disable legacy wrapping algorithms.
211
212 //= ../specification/s3-encryption/client.md#enable-legacy-unauthenticated-modes
213 //= type=implication
214 //# The S3EC MUST support the option to enable or disable legacy unauthenticated modes (content encryption algorithms).
215
216 //= ../specification/s3-encryption/client.md#enable-delayed-authentication
217 //= type=implication
218 //# The S3EC MUST support the option to enable or disable Delayed Authentication mode.
219
220 //= ../specification/s3-encryption/client.md#instruction-file-configuration
221 //= type=implication
222 //# The S3EC MAY support the option to provide Instruction File Configuration during its initialization.
223 //# If the S3EC in a given language supports Instruction Files, then it MUST accept Instruction File Configuration during its initialization.
224 //# In this case, the Instruction File Configuration SHOULD be optional, such that its default configuration is used when none is provided.
225
226 //= ../specification/s3-encryption/client.md#key-commitment
227 //= type=implication
228 //# The S3EC MUST support configuration of the [Key Commitment policy](./key-commitment.md) during its initialization.
229
230 StorageMethod m_storageMethod;
231 RangeGetMode m_unAuthenticatedRangeGet;
232 SecurityProfile m_securityProfile;
233 std::shared_ptr<Aws::Utils::Crypto::EncryptionMaterials> m_encryptionMaterials;
234 CommitmentPolicy m_commitmentPolicy;
235 };
236 }
237}
CryptoConfiguration(StorageMethod storageMethod)
void SetCryptoMode(CryptoMode cryptoMode)
CryptoConfiguration(CryptoMode cryptoMode)
CryptoConfiguration(StorageMethod storageMode, CryptoMode cryptoMode)
void SetStorageMethod(StorageMethod storageMethod)
std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > GetEncryptionMaterials() const
void SetStorageMethod(StorageMethod storageMethod)
CryptoConfigurationV2(const std::shared_ptr< Aws::S3Encryption::Materials::SimpleEncryptionMaterialsWithGCMAAD > &materials)
void SetSecurityProfile(SecurityProfile profile)
CryptoConfigurationV2(const std::shared_ptr< Aws::S3Encryption::Materials::KMSWithContextEncryptionMaterials > &materials)
std::shared_ptr< Aws::Utils::Crypto::EncryptionMaterials > GetEncryptionMaterials() const
void SetCommitmentPolicy(CommitmentPolicy commitmentPolicy)
void SetStorageMethod(StorageMethod storageMethod)
CryptoConfigurationV3(const std::shared_ptr< Aws::S3Encryption::Materials::SimpleEncryptionMaterialsWithGCMAAD > &materials)
CryptoConfigurationV3(const std::shared_ptr< Aws::S3Encryption::Materials::KMSWithContextEncryptionMaterials > &materials)