4
4
This example demonstrates how to set an encryption algorithm while using the Raw AES Keyring
5
5
in the AWS Encryption SDK.
6
6
7
+ The encryption algorithm used in the encrypt() method is the algorithm used to protect your
8
+ data using the data key. By setting this algorithm, you can configure the algorithm used
9
+ to encrypt and decrypt your data.
10
+
7
11
Encryption algorithms can be set in a similar manner in other keyrings as well. However,
8
12
please make sure that you're using a logical encryption algorithm that is compatible with your
9
- keyring. For example, AWS KMS RSA Keyring does not support use with an algorithm suite
10
- containing an asymmetric signature.
11
-
12
- The Raw AES keyring encrypts data by using the AES-GCM algorithm and a wrapping key that
13
- you specify as a byte array. You can specify only one wrapping key in each Raw AES keyring,
14
- but you can include multiple Raw AES keyrings, alone or with other keyrings, in a multi-keyring.
13
+ keyring. For more information on encryption algorithms supported by the AWS Encryption SDK, see
14
+ https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/supported-algorithms.html
15
15
16
16
The AES wrapping algorithm (AesWrappingAlg.ALG_AES256_GCM_IV12_TAG16) protects your data key using
17
17
the user-provided wrapping key. The encryption algorithm used in the encrypt() method is the
18
18
algorithm used to protect your data using the data key. This example demonstrates setting the
19
- latter, which is the encryption algorithm for protecting your data. The default algorithm used
20
- in encrypt method is AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384 when the commitment policy is
21
- REQUIRE_ENCRYPT_REQUIRE_DECRYPT which is a committing and signing algorithm. This example sets
22
- the encryption algorithm as AES_256_GCM_HKDF_SHA512_COMMIT_KEY which is a committing but
23
- non-signing algorithm.
19
+ latter, which is the encryption algorithm for protecting your data. When the commitment policy is
20
+ REQUIRE_ENCRYPT_REQUIRE_DECRYPT, the default algorithm used in the encrypt method is
21
+ AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384, which is a committing and signing algorithm.
22
+ Signature verification is extremely useful to ensure the integrity of a digital message as it
23
+ goes between systems. However, signature verification adds a significant performance cost on
24
+ decryption. If the users encrypting data and the users decrypting data are equally trusted, we can
25
+ consider using an algorithm suite that does not include signing. This example sets the encryption
26
+ algorithm as AES_256_GCM_HKDF_SHA512_COMMIT_KEY which is a committing but non-signing algorithm.
27
+ For more information on digital signatures, see
28
+ https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#digital-sigs
24
29
25
30
This example creates a Raw AES Keyring and then encrypts a custom input EXAMPLE_DATA
26
31
with an encryption context and the encryption algorithm AES_256_GCM_HKDF_SHA512_COMMIT_KEY.
@@ -101,6 +106,7 @@ def encrypt_and_decrypt_with_keyring():
101
106
config = MaterialProvidersConfig ()
102
107
)
103
108
109
+ # The wrapping algorithm here is NOT the encryption algorithm we set in this example.
104
110
keyring_input : CreateRawAesKeyringInput = CreateRawAesKeyringInput (
105
111
key_namespace = key_name_space ,
106
112
key_name = key_name ,
@@ -113,7 +119,8 @@ def encrypt_and_decrypt_with_keyring():
113
119
)
114
120
115
121
# 6. Encrypt the data with the encryptionContext.
116
- # Specify the encryption algorithm you want to use for encrypting your data here
122
+ # This is the important step in this example where we specify the encryption algorithm
123
+ # you want to use for encrypting your data here
117
124
ciphertext , _ = client .encrypt (
118
125
source = EXAMPLE_DATA ,
119
126
keyring = raw_aes_keyring ,
0 commit comments