Skip to content

Commit e5c8677

Browse files
committed
Explaining the support and maintenance policy
1 parent f5e81f1 commit e5c8677

26 files changed

+388
-248
lines changed

doc_source/about-versions.md

+51-17
Large diffs are not rendered by default.

doc_source/best-practices.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The AWS Encryption SDK is designed to make it easy for you to protect your data using industry standards and best practices\. While many best practices are selected for you in default values, some practices are optional but recommended whenever it's practical\.
44

55
**Use the latest version**
6-
When you start using the AWS Encryption SDK, use the latest version offered in your preferred [programming language](programming-languages.md)\. If you've been using the AWS Encryption SDK, upgrade to each latest version as soon as possible\. This assures that you're using the recommended configuration and taking advantage of new security properties to protect your data\. For details about supported versions, including guidance for migration and deployment, see [Migrating to version 2\.0\.*x*](migration.md)\.
6+
When you start using the AWS Encryption SDK, use the latest version offered in your preferred [programming language](programming-languages.md)\. If you've been using the AWS Encryption SDK, upgrade to each latest version as soon as possible\. This assures that you're using the recommended configuration and taking advantage of new security properties to protect your data\. For details about supported versions, including guidance for migration and deployment, see [Support and maintenance](introduction.md#support) and [Versions of the AWS Encryption SDK](about-versions.md)\.
77
If a new version deprecates elements in your code, replace them as soon as you can\. Deprecation warnings and code comments typically recommend a good alternative\.
88
To make significant upgrades easier and less prone to error, we occasionally provide a temporary or transitional release\. Use these releases, and their accompanying documentation, to assure that you can upgrade your application without disrupting your production workflow\.
99

doc_source/c-examples.md

+36-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following examples show you how to use the AWS Encryption SDK for C to encrypt and decrypt data\.
44

5-
The examples in this section show how to use version 2\.0\.*x* and later of the AWS Encryption SDK for C\. For examples that use earlier versions, find your release in the [Releases](https://github.com/aws/aws-encryption-sdk-c/releases) list of the [aws\-encryption\-sdk\-c repository](https://github.com/aws/aws-encryption-sdk-c/) repository on GitHub\.
5+
The examples in this section show how to use versions 2\.0\.*x* and later of the AWS Encryption SDK for C\. For examples that use earlier versions, find your release in the [Releases](https://github.com/aws/aws-encryption-sdk-c/releases) list of the [aws\-encryption\-sdk\-c repository](https://github.com/aws/aws-encryption-sdk-c/) repository on GitHub\.
66

77
When you install and build the AWS Encryption SDK for C, the source code for these and other examples are included in the `examples` subdirectory, and they are compiled and built into the `build` directory\. You can also find them in the [examples](https://github.com/aws/aws-encryption-sdk-c/tree/master/examples) subdirectory of the [aws\-encryption\-sdk\-c](https://github.com/aws/aws-encryption-sdk-c/) repository on GitHub\.
88

@@ -13,9 +13,9 @@ When you install and build the AWS Encryption SDK for C, the source code for the
1313

1414
The following example shows you how to use the AWS Encryption SDK for C to encrypt and decrypt a string\.
1515

16-
This example features the KMS [keyring](concepts.md#keyring), a type of keyring that uses an AWS KMS key in [AWS Key Management Service \(AWS KMS\)](https://aws.amazon.com/kms/) to generate and encrypt data keys\. The example includes some code written in C\+\+ because the AWS Encryption SDK for C uses the AWS SDK for C\+\+ to call AWS KMS\.
16+
This example features the [AWS KMS keyring](use-kms-keyring.md), a type of keyring that uses an AWS KMS key in [AWS Key Management Service \(AWS KMS\)](https://docs.aws.amazon.com/kms/latest/developerguide/) to generate and encrypt data keys\. The example includes code written in C\+\+\. The AWS Encryption SDK for C requires the AWS SDK for C\+\+ to call AWS KMS when using AWS KMS keyrings\. If you're using a keyring that doesn't interact with AWS KMS, such as a raw AES keyring, a raw RSA keyring, or a multi\-keyring that doesn't include an AWS KMS keyring, the AWS SDK for C\+\+ is not required\.
1717

18-
For help creating an AWS KMS key, see [Creating Keys](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html) in the *AWS Key Management Service Developer Guide*\. For help identifying the AWS KMS keys in an AWS KMS keyring, see [Identifying AWS KMS keys in an AWS KMS keyring](use-kms-keyring.md#kms-keyring-id)
18+
For help creating an AWS KMS key, see [Creating Keys](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html) in the *AWS Key Management Service Developer Guide*\. For help identifying the AWS KMS keys in an AWS KMS keyring, see [Identifying AWS KMS keys in an AWS KMS keyring](use-kms-keyring.md#kms-keyring-id)\.
1919

2020
**See the complete code sample**: [string\.cpp](https://github.com/aws/aws-encryption-sdk-c/blob/master/examples/string.cpp)
2121

@@ -27,7 +27,16 @@ For help creating an AWS KMS key, see [Creating Keys](https://docs.aws.amazon.co
2727

2828
The first part of this example uses an AWS KMS keyring with one AWS KMS key to encrypt a plaintext string\.
2929

30-
Step 1: Construct the keyring\.
30+
Step 1\. Load error strings\.
31+
Call the `aws_cryptosdk_load_error_strings()` method in your C or C\+\+ code\. It loads error information that is very useful for debugging\.
32+
You only need to call it once, such as in your `main` method\.
33+
34+
```
35+
/* Load error strings for debugging */
36+
aws_cryptosdk_load_error_strings();
37+
```
38+
39+
Step 2: Construct the keyring\.
3140
Create an AWS KMS keyring for encryption\. The keyring in this example is configured with one AWS KMS key, but you can configure an AWS KMS keyring with multiple AWS KMS keys, including AWS KMS keys in different AWS Regions and different accounts\.
3241
To identify an AWS KMS key in an encryption keyring in the AWS Encryption SDK for C, specify a [key ARN](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN) or [alias ARN](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-alias-arn)\. In a decryption keyring, you must use a key ARN\. For details, see [Identifying AWS KMS keys in an AWS KMS keyring](use-kms-keyring.md#kms-keyring-id)\.
3342
[Identifying AWS KMS keys in an AWS KMS keyring](use-kms-keyring.md#kms-keyring-id)
@@ -41,7 +50,7 @@ struct aws_cryptosdk_keyring *kms_keyring =
4150
Aws::Cryptosdk::KmsKeyring::Builder().Build(key_arn);
4251
```
4352

44-
Step 2: Create a session\.
53+
Step 3: Create a session\.
4554
Create a session using the allocator, a mode enumerator, and the keyring\.
4655
Every session requires a mode: either `AWS_CRYPTOSDK_ENCRYPT` to encrypt or `AWS_CRYPTOSDK_DECRYPT` to decrypt\. To change the mode of an existing session, use the `aws_cryptosdk_session_reset` method\.
4756
After you create a session with the keyring, you can release your reference to the keyring using the method that the SDK provides\. The session retains a reference to the keyring object during its lifetime\. References to the keyring and session objects are released when you destroy the session\. This [reference counting](c-language-using.md#c-language-using-release) technique helps to prevent memory leaks and to prevent the objects from being released while they are in use\.
@@ -50,16 +59,16 @@ After you create a session with the keyring, you can release your reference to t
5059
struct aws_cryptosdk_session *session =
5160
aws_cryptosdk_session_new_from_keyring_2(alloc, AWS_CRYPTOSDK_ENCRYPT, kms_keyring);
5261
53-
// When you add the keyring to the session, release the keyring object
62+
/* When you add the keyring to the session, release the keyring object */
5463
aws_cryptosdk_keyring_release(kms_keyring);
5564
```
5665

57-
Step 3: Set the encryption context\.
66+
Step 4: Set the encryption context\.
5867
An [encryption context](concepts.md#encryption-context) is arbitrary, non\-secret additional authenticated data\. When you provide an encryption context on encrypt, the AWS Encryption SDK cryptographically binds the encryption context to the ciphertext so that the same encryption context is required to decrypt the data\. Using an encryption context is optional, but we recommend it as a best practice\.
5968
First, create a hash table that includes the encryption context strings\.
6069

6170
```
62-
// Allocate a hash table for the encryption context.
71+
/* Allocate a hash table for the encryption context */
6372
int set_up_enc_ctx(struct aws_allocator *alloc, struct aws_hash_table *my_enc_ctx)
6473
6574
// Create encryption context strings
@@ -81,12 +90,12 @@ struct aws_hash_table *session_enc_ctx = aws_cryptosdk_session_get_enc_ctx_ptr_m
8190
aws_cryptosdk_enc_ctx_clone(alloc, session_enc_ctx, my_enc_ctx)
8291
```
8392

84-
Step 4: Encrypt the string\.
93+
Step 5: Encrypt the string\.
8594
To encrypt the plaintext string, use the `aws_cryptosdk_session_process_full` method with the session in encryption mode\. This method, introduced in AWS Encryption SDK versions 1\.9\.*x* and 2\.2\.*x*, is designed for non\-streaming encryption and decryption\. To handle streaming data, call the `aws_cryptosdk_session_process` in a loop\.
8695
When encrypting, the plaintext fields are input fields; the ciphertext fields are output fields\. When the processing is complete, the `ciphertext_output` field contains the [encrypted message](concepts.md#message), including the actual ciphertext, encrypted data keys, and the encryption context\. You can decrypt this encrypted message by using the AWS Encryption SDK for any supported programming language\.
8796

8897
```
89-
// Gets the length of the plaintext that the session processed
98+
/* Gets the length of the plaintext that the session processed */
9099
size_t ciphertext_len_output;
91100
if (AWS_OP_SUCCESS != aws_cryptosdk_session_process_full(session,
92101
ciphertext_output,
@@ -99,15 +108,24 @@ if (AWS_OP_SUCCESS != aws_cryptosdk_session_process_full(session,
99108
}
100109
```
101110

102-
Step 5: Clean up the session\.
111+
Step 6: Clean up the session\.
103112
The final step destroys the session including references to the CMM and the keyring\.
104113
If you prefer, instead of destroying the session, you can reuse the session with the same keyring and CMM to decrypt the string, or to encrypt or decrypt other messages\. To use the session for decrypting, use the `aws_cryptosdk_session_reset` method to change the mode to `AWS_CRYPTOSDK_DECRYPT`\.
105114

106115
### Decrypt a string<a name="c-example-string-decrypt"></a>
107116

108117
The second part of this example decrypts an encrypted message that contains the ciphertext of the original string\.
109118

110-
Step 1: Construct the keyring\.
119+
Step 1: Load error strings\.
120+
Call the `aws_cryptosdk_load_error_strings()` method in your C or C\+\+ code\. It loads error information that is very useful for debugging\.
121+
You only need to call it once, such as in your `main` method\.
122+
123+
```
124+
/* Load error strings for debugging */
125+
aws_cryptosdk_load_error_strings();
126+
```
127+
128+
Step 2: Construct the keyring\.
111129
When you decrypt data in AWS KMS, you pass in the [encrypted message](concepts.md#message) that the encrypt API returned\. The [Decrypt API](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html) doesn't take an AWS KMS key as input\. Instead, AWS KMS uses the same AWS KMS key to decrypt the ciphertext that it used to encrypt it\. However, the AWS Encryption SDK lets you specify an AWS KMS keyring with AWS KMS keys on encrypt and decrypt\.
112130
On decrypt, you can configure a keyring with only the AWS KMS keys that you want to use to decrypt the encrypted message\. For example, you might want to create a keyring with only the AWS KMS key that is used by a particular role in your organization\. The AWS Encryption SDK will never use an AWS KMS key unless it appears in the decryption keyring\. If the SDK can't decrypt the encrypted data keys by using the AWS KMS keys in the keyring that you provide, either because none of AWS KMS keys in the keyring were used to encrypt any of the data keys, or because the caller doesn't have permission to use the AWS KMS keys in the keyring to decrypt, the decrypt call fails\.
113131
When you specify an AWS KMS key for a decryption keyring, you must use its [key ARN](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-ARN)\. [Alias ARNs](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-alias-arn) are permitted only in encryption keyrings\. For help identifying the AWS KMS keys in an AWS KMS keyring, see [Identifying AWS KMS keys in an AWS KMS keyring](use-kms-keyring.md#kms-keyring-id)\.
@@ -120,19 +138,19 @@ struct aws_cryptosdk_keyring *kms_keyring =
120138
Aws::Cryptosdk::KmsKeyring::Builder().Build(key_arn);
121139
```
122140

123-
Step 2: Create a session\.
141+
Step 3: Create a session\.
124142
Create a session using the allocator and the keyring\. To configure the session for decryption, configure the session with the `AWS_CRYPTOSDK_DECRYPT` mode\.
125143
After you create a session with a keyring, you can release your reference to the keyring using the method that the SDK provides\. The session retains a reference to the keyring object during its lifetime, and both the session and keyring are released when you destroy the session\. This reference counting technique helps to prevent memory leaks and to prevent the objects from being released while they are in use\.
126144

127145
```
128146
struct aws_cryptosdk_session *session =
129147
aws_cryptosdk_session_new_from_keyring_2(alloc, AWS_CRYPTOSDK_DECRYPT, kms_keyring);
130148
131-
// When you add the keyring to the session, release the keyring object
149+
/* When you add the keyring to the session, release the keyring object */
132150
aws_cryptosdk_keyring_release(kms_keyring);
133151
```
134152

135-
Step 3: Decrypt the string\.
153+
Step 4: Decrypt the string\.
136154
To decrypt the string, use the `aws_cryptosdk_session_process_full` method with the session that is configured for decryption\. This method, introduced in AWS Encryption SDK versions 1\.9\.*x* and 2\.2\.*x*, is designed for non\-streaming encryption and decryption\. To handle streaming data, call the `aws_cryptosdk_session_process` in a loop\.
137155
When decrypting, the ciphertext fields are input fields and the plaintext fields are output fields\. The `ciphertext_input` field holds the [encrypted message](message-format.md) that the encrypt method returned\. When the processing is complete, the `plaintext_output` field contains the plaintext \(decrypted\) string\.
138156

@@ -150,7 +168,7 @@ if (AWS_OP_SUCCESS != aws_cryptosdk_session_process_full(session,
150168
}
151169
```
152170

153-
Step 4: Verify the encryption context\.
171+
Step 5: Verify the encryption context\.
154172
Be sure that the actual encryption context — the one that was used to decrypt the message — contains the encryption context that you provided when encrypting the message\. The actual encryption context might include extra pairs, because the [cryptographic materials manager](concepts.md#crypt-materials-manager) \(CMM\) can add pairs to the provided encryption context before encrypting the message\.
155173
In the AWS Encryption SDK for C, you are not required to provide an encryption context when decrypting because the encryption context is included in the encrypted message that the SDK returns\. But, before it returns the plaintext message, your decrypt function should verify that all pairs in the provided encryption context appear in the encryption context that was used to decrypt the message\.
156174
First, get a read\-only pointer to the hash table in the session\. This hash table contains the encryption context that was used to decrypt the message\.
@@ -175,8 +193,8 @@ for (struct aws_hash_iter iter = aws_hash_iter_begin(my_enc_ctx); !aws_hash_iter
175193
}
176194
```
177195

178-
Clean up the session\.
179-
After you verify the encryption context, you can destroy the session\. As usual, you can reuse the session\. If you need to reconfigure it, use the `aws_cryptosdk_session_reset` method\.
196+
Step 6: Clean up the session\.
197+
After you verify the encryption context, you can destroy the session, or reuse it\. If you need to reconfigure the session, use the `aws_cryptosdk_session_reset` method\.
180198

181199
```
182200
aws_cryptosdk_session_destroy(session);

doc_source/c-language-installation.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
You can find detailed instructions for installing and building the AWS Encryption SDK for C in the [README file](https://github.com/aws/aws-encryption-sdk-c/#readme) of the [aws\-encryption\-sdk\-c](https://github.com/aws/aws-encryption-sdk-c/) repository\. It includes instructions for building on Amazon Linux, Ubuntu, macOS, and Windows platforms\.
44

5-
Before you begin, decide whether you want to use [AWS KMS keyrings](use-kms-keyring.md) in the AWS Encryption SDK\. If you use an AWS KMS keyring, you need to install the AWS SDK for C\+\+\. AWS KMS keyrings use [AWS Key Management Service](https://docs.aws.amazon.com/kms/latest/developerguide/) \(AWS KMS\) to generate and protect the encryption keys that protect your data\. Otherwise, you need to generate and protect your own raw wrapping keys\.
5+
Before you begin, decide whether you want to use [AWS KMS keyrings](use-kms-keyring.md) in the AWS Encryption SDK\. If you use an AWS KMS keyring, you need to install the AWS SDK for C\+\+\. The AWS SDK is required to interact with [AWS Key Management Service](https://docs.aws.amazon.com/kms/latest/developerguide/) \(AWS KMS\)\. When you use AWS KMS keyrings, the AWS Encryption SDK uses AWS KMS to generate and protect the encryption keys that protect your data\.
6+
7+
You do not need to install the AWS SDK for C\+\+ if you are using another keyring type, such as a raw AES keyring, a raw RSA keyring, or a multi\-keyring that doesn't include an AWS KMS keyring\. However, when using a raw keyring type, you need to generate and protect your own raw wrapping keys\.
8+
9+
For help deciding which keyring types to use, see [Choosing a keyring](which-keyring.md)\.
610

711
If you're having trouble with your installation, [file an issue](https://github.com/aws/aws-encryption-sdk-c/issues) in the `aws-encryption-sdk-c` repository or use any of the feedback links on this page\.

0 commit comments

Comments
 (0)