@@ -36,7 +36,7 @@ Getting Started
36
36
Required Prerequisites
37
37
======================
38
38
39
- * Python 2.7+ or 3.5+
39
+ * Python 2.7 or 3.5+
40
40
* cryptography >= 1.8.1
41
41
* boto3
42
42
* attrs
@@ -55,189 +55,42 @@ Installation
55
55
56
56
Concepts
57
57
========
58
- There are four main concepts that you need to understand to use this library:
58
+ There are three main concepts that are helpful to understand when using the AWS Encryption SDK.
59
+
60
+ For further information, see the `AWS Encryption SDK developer guide concepts `_.
59
61
60
62
Cryptographic Materials Managers
61
63
--------------------------------
62
- Cryptographic materials managers (CMMs) are resources that collect cryptographic materials and prepare them for
63
- use by the Encryption SDK core logic.
64
-
65
- An example of a CMM is the default CMM, which is automatically generated anywhere a caller provides a master
66
- key provider. The default CMM collects encrypted data keys from all master keys referenced by the master key
67
- provider.
68
-
69
- An example of a more advanced CMM is the caching CMM, which caches cryptographic materials provided by another CMM.
64
+ The cryptographic materials manager (CMM) assembles the cryptographic materials
65
+ that are used to encrypt and decrypt data.
70
66
71
- Master Key Providers
72
- --------------------
73
- Master key providers are resources that provide master keys.
74
- An example of a master key provider is `AWS KMS `_.
67
+ `For more details,
68
+ see the AWS Encryption SDK developer guide cryptographic materials manager concept.
69
+ <https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#crypt-materials-manager> `_
75
70
76
- To encrypt data in this client, a ``MasterKeyProvider `` object must contain at least one ``MasterKey `` object.
71
+ Keyrings
72
+ --------
77
73
78
- `` MasterKeyProvider `` objects can also contain other `` MasterKeyProvider `` objects .
74
+ A keyring generates, encrypts, and decrypts data keys .
79
75
80
- Master Keys
81
- -----------
82
- Master keys generate, encrypt, and decrypt data keys.
83
- An example of a master key is a `KMS customer master key (CMK) `_.
76
+ `For more details,
77
+ see the AWS Encryption SDK developer guide keyring concept.
78
+ <https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#keyring> `_
84
79
85
80
Data Keys
86
81
---------
87
- Data keys are the encryption keys that are used to encrypt your data. If your algorithm suite
88
- uses a key derivation function, the data key is used to generate the key that directly encrypts the data.
82
+
83
+ A data key is an encryption key that the AWS Encryption SDK uses to encrypt your data.
84
+
85
+ `For more details,
86
+ see the AWS Encryption SDK developer guide data key concept.
87
+ <https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#DEK> `_
89
88
90
89
*****
91
90
Usage
92
91
*****
93
- To use this client, you (the caller) must provide an instance of either a master key provider
94
- or a CMM. The examples in this readme use the ``KMSMasterKeyProvider `` class.
95
-
96
- KMSMasterKeyProvider
97
- ====================
98
- Because the ``KMSMasterKeyProvider `` uses the `boto3 SDK `_ to interact with `AWS KMS `_, it requires AWS Credentials.
99
- To provide these credentials, use the `standard means by which boto3 locates credentials `_ or provide a
100
- pre-existing instance of a ``botocore session `` to the ``KMSMasterKeyProvider ``.
101
- This latter option can be useful if you have an alternate way to store your AWS credentials or
102
- you want to reuse an existing instance of a botocore session in order to decrease startup costs.
103
-
104
- .. code :: python
105
-
106
- import aws_encryption_sdk
107
- import botocore.session
108
-
109
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider()
110
-
111
- existing_botocore_session = botocore.session.Session()
112
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(botocore_session = existing_botocore_session)
113
-
114
-
115
- You can pre-load the ``KMSMasterKeyProvider `` with one or more CMKs.
116
- To encrypt data, you must configure the ``KMSMasterKeyProvider `` with as least one CMK.
117
- If you configure the the ``KMSMasterKeyProvider `` with multiple CMKs, the `final message `_
118
- will include a copy of the data key encrypted by each configured CMK.
119
-
120
- .. code :: python
121
-
122
- import aws_encryption_sdk
123
-
124
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids = [
125
- ' arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222' ,
126
- ' arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
127
- ])
128
-
129
- You can add CMKs from multiple regions to the ``KMSMasterKeyProvider ``.
130
-
131
- .. code :: python
132
-
133
- import aws_encryption_sdk
134
-
135
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids = [
136
- ' arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222' ,
137
- ' arn:aws:kms:us-west-2:3333333333333:key/33333333-3333-3333-3333-333333333333' ,
138
- ' arn:aws:kms:ap-northeast-1:4444444444444:key/44444444-4444-4444-4444-444444444444'
139
- ])
140
-
141
-
142
- Encryption and Decryption
143
- =========================
144
- After you create an instance of a ``MasterKeyProvider ``, you can use either of the two
145
- high-level ``encrypt ``/``decrypt `` functions to encrypt and decrypt your data.
146
-
147
- .. code :: python
148
-
149
- import aws_encryption_sdk
150
-
151
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids = [
152
- ' arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222' ,
153
- ' arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
154
- ])
155
- my_plaintext = b ' This is some super secret data! Yup, sure is!'
156
-
157
- my_ciphertext, encryptor_header = aws_encryption_sdk.encrypt(
158
- source = my_plaintext,
159
- key_provider = kms_key_provider
160
- )
161
-
162
- decrypted_plaintext, decryptor_header = aws_encryption_sdk.decrypt(
163
- source = my_ciphertext,
164
- key_provider = kms_key_provider
165
- )
166
-
167
- assert my_plaintext == decrypted_plaintext
168
- assert encryptor_header.encryption_context == decryptor_header.encryption_context
169
-
170
- You can provide an `encryption context `_: a form of additional authenticating information.
171
-
172
- .. code :: python
173
-
174
- import aws_encryption_sdk
175
-
176
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids = [
177
- ' arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222' ,
178
- ' arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
179
- ])
180
- my_plaintext = b ' This is some super secret data! Yup, sure is!'
181
-
182
- my_ciphertext, encryptor_header = aws_encryption_sdk.encrypt(
183
- source = my_plaintext,
184
- key_provider = kms_key_provider,
185
- encryption_context = {
186
- ' not really' : ' a secret' ,
187
- ' but adds' : ' some authentication'
188
- }
189
- )
190
-
191
- decrypted_plaintext, decryptor_header = aws_encryption_sdk.decrypt(
192
- source = my_ciphertext,
193
- key_provider = kms_key_provider
194
- )
195
-
196
- assert my_plaintext == decrypted_plaintext
197
- assert encryptor_header.encryption_context == decryptor_header.encryption_context
198
-
199
-
200
- Streaming
201
- =========
202
- If you are handling large files or simply do not want to put the entire plaintext or ciphertext in
203
- memory at once, you can use this library's streaming clients directly. The streaming clients are
204
- file-like objects, and behave exactly as you would expect a Python file object to behave,
205
- offering context manager and iteration support.
206
-
207
- .. code :: python
208
-
209
- import aws_encryption_sdk
210
- import filecmp
211
-
212
- kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids = [
213
- ' arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222' ,
214
- ' arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
215
- ])
216
- plaintext_filename = ' my-secret-data.dat'
217
- ciphertext_filename = ' my-encrypted-data.ct'
218
-
219
- with open (plaintext_filename, ' rb' ) as pt_file, open (ciphertext_filename, ' wb' ) as ct_file:
220
- with aws_encryption_sdk.stream(
221
- mode = ' e' ,
222
- source = pt_file,
223
- key_provider = kms_key_provider
224
- ) as encryptor:
225
- for chunk in encryptor:
226
- ct_file.write(chunk)
227
-
228
- new_plaintext_filename = ' my-decrypted-data.dat'
229
92
230
- with open (ciphertext_filename, ' rb' ) as ct_file, open (new_plaintext_filename, ' wb' ) as pt_file:
231
- with aws_encryption_sdk.stream(
232
- mode = ' d' ,
233
- source = ct_file,
234
- key_provider = kms_key_provider
235
- ) as decryptor:
236
- for chunk in decryptor:
237
- pt_file.write(chunk)
238
-
239
- assert filecmp.cmp(plaintext_filename, new_plaintext_filename)
240
- assert encryptor.header.encryption_context == decryptor.header.encryption_context
93
+ For examples of how to use these concepts to accomplish different tasks, see our `examples `_.
241
94
242
95
Performance Considerations
243
96
==========================
@@ -249,6 +102,8 @@ to your use-case in order to obtain peak performance.
249
102
250
103
251
104
.. _AWS Encryption SDK : https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html
105
+ .. _AWS Encryption SDK developer guide concepts :
106
+ https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html
252
107
.. _cryptography : https://cryptography.io/en/latest/
253
108
.. _cryptography installation guide : https://cryptography.io/en/latest/installation/
254
109
.. _Read the Docs : http://aws-encryption-sdk-python.readthedocs.io/en/latest/
@@ -259,3 +114,4 @@ to your use-case in order to obtain peak performance.
259
114
.. _standard means by which boto3 locates credentials : https://boto3.readthedocs.io/en/latest/guide/configuration.html
260
115
.. _final message : https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html
261
116
.. _encryption context : https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#encrypt_context
117
+ .. _examples : https://github.com/aws/aws-encryption-sdk-python/tree/master/examples
0 commit comments