Skip to content

chore: Document encryption context interoperability for invalid UTF-8 #820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/aws/cryptosdk/enc_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ extern "C" {
* for the most part, aws_hash_table methods are used to manipulate these structures,
* but we provide some higher-level helper methods in this section. These helpers
* will mostly be of interest to developers of custom CMMs or keyrings.
*
* The values provided to the encryption context SHOULD be UTF-8 bytes.
* While it is technically possible to provide invalid UTF-8 bytes,
* doing so is strongly discouraged.
* Messages that include invalid UTF-8 bytes in their encryption context
* will not be interoperable across different language implementations
* of the AWS Encryption SDK.
* The ESDK for C permits writing and reading encryption contexts that
* contain invalid UTF-8 bytes, but ESDKs in other languages will neither
* read nor write messages whose encryption context contains invalid UTF-8.
* @{
*/

Expand Down
25 changes: 25 additions & 0 deletions include/aws/cryptosdk/materials.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ struct aws_cryptosdk_enc_request {
* The encryption context for this message. CMMs are permitted to modify this
* hash table in order to inject additional keys or otherwise modify the encryption
* context.
*
* The values provided to the encryption context SHOULD be UTF-8 bytes.
* While it is technically possible to provide invalid UTF-8 bytes,
* doing so is strongly discouraged.
* Messages that include invalid UTF-8 bytes in their encryption context
* will not be interoperable across different language implementations
* of the AWS Encryption SDK.
* The ESDK for C permits writing and reading encryption contexts that
* contain invalid UTF-8 bytes, but ESDKs in other languages will neither
* read nor write messages whose encryption context contains invalid UTF-8.
*/
struct aws_hash_table *enc_ctx;
/**
Expand Down Expand Up @@ -187,6 +197,21 @@ struct aws_cryptosdk_enc_materials {
*/
struct aws_cryptosdk_dec_request {
struct aws_allocator *alloc;
/**
* The encryption context for this message. CMMs are permitted to modify this
* hash table in order to inject additional keys or otherwise modify the encryption
* context.
*
* The values provided to the encryption context SHOULD be UTF-8 bytes.
* While it is technically possible to provide invalid UTF-8 bytes,
* doing so is strongly discouraged.
* Messages that include invalid UTF-8 bytes in their encryption context
* will not be interoperable across different language implementations
* of the AWS Encryption SDK.
* The ESDK for C permits writing and reading encryption contexts that
* contain invalid UTF-8 bytes, but ESDKs in other languages will neither
* read nor write messages whose encryption context contains invalid UTF-8.
*/
const struct aws_hash_table *enc_ctx;
struct aws_array_list encrypted_data_keys;
enum aws_cryptosdk_alg_id alg;
Expand Down
Loading