Feature |
---|
Caching Cryptographic Materials Manager |
Specification |
---|
Caching Cryptographic Materials Manager |
Language | Repository |
---|---|
C | aws-encryption-sdk-c |
Java | aws-encryption-sdk-java |
JavaScript | aws-encryption-sdk-javascript |
Python | aws-encryption-sdk-python |
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
The caching Cryptographic Materials Manager (caching CMM) computes identifiers for each cache entry it places into its underlying Cryptographic Materials Cache (CMC). Existing caching CMM implementations agree on the set of formulas they use to compute these identifiers, and this change adds those formulas to the specification.
- Changing the shape of the caching CMM operations is out of scope.
- Changing the shape of the CMC interface operations is out of scope.
In all generally-available implementations of the AWS Encryption SDK (ESDK), the caching Cryptographic Materials Manager (caching CMM) uses a particular set of formulas to compute the identifiers for cache entries when interacting with the Cryptographic Materials Cache (CMC). Although these implementations agree on this set of formulas, the formulas are neither explicitly stated nor mandated in the specification.
Mandating that implementations share cache entry identifier formulas has a number of benefits:
- Implementers will have a definitive reference for precisely which cache entry fields MUST be used to distinguish cache entries, and also provides a concrete data format by which to serialize them.
- It is easier to reason about the caching CMM across implementations if one can assume that they distinguish cache entries by the same criteria.
- If it becomes necessary to change cache identifiers in the future (e.g., in order to distinguish cache entries by more features), then we can do so uniformly across implementations.
This change SHOULD NOT have any security implications.
We MUST add ESDK test vectors to verify that caching CMM implementations correctly implement the cache entry identifier formulas.
See Reference-level Explanation.
Each of the cache entry identifier formulas includes a serialized encryption context,
as defined in the
Key Value Pairs specification.
In the following sections we use SerializeEncryptionContext
to denote the function that,
given an encryption context,
returns the serialization of the encryption context.
Some of the cache entry identifier formulas include
the two-byte algorithm suite ID for the algorithm suite in a materials request.
The algorithm suite IDs are defined in the
Supported Algorithm Suites specification.
In the following sections we use AlgorithmSuiteId
to the denote the function that,
given an algorithm suite as specified in a materials request,
returns the corresponding two-byte algorithm suite ID.
If the Get Encryption Materials request does not specify an algorithm suite, then the cache entry identifier MUST be calculated as the SHA-512 hash of the concatenation of the following byte strings, in the order listed:
- The SHA-512 hash of a UTF-8 encoding of the caching CMM’s Partition ID
- One null byte (
0x00
) - The SHA-512 hash of the serialized encryption context
As a formula:
ENTRY_ID = SHA512(
SHA512(UTF8Encode(cachingCMM.partitionId))
+ 0x00
+ SHA512(SerializeEncryptionContext(getEncryptionMaterialsRequest.encryptionContext))
)
If the Get Encryption Materials request does specify an algorithm suite, then the cache entry identifier MUST be calculated as the SHA-512 hash of the concatenation of the following byte strings, in the order listed:
- The SHA-512 hash of a UTF-8 encoding of the caching CMM’s Partition ID
- One byte with value 1 (
0x01
) - The two-byte algorithm suite ID corresponding to the algorithm suite in the request
- The SHA-512 hash of the serialized encryption context
As a formula:
ENTRY_ID = SHA512(
SHA512(UTF8Encode(cachingCMM.partitionId))
+ 0x01
+ AlgorithmSuiteId(getEncryptionMaterialsRequest.algorithmSuite)
+ SHA512(SerializeEncryptionContext(getEncryptionMaterialsRequest.encryptionContext))
)
When the caching CMM receives a Decrypt Materials request, it MUST calculate the cache entry identifier as the SHA-512 hash of the concatenation of the following byte strings, in the order listed:
- The SHA-512 hash of a UTF-8 encoding of the caching CMM’s Partition ID
- The two-byte algorithm suite ID corresponding to the algorithm suite in the request
- The concatenation of the lexicographically-sorted SHA-512 hashes of the serialized encrypted data keys, where serialization is as defined in the Encrypted Data Key Entries specification.
- A sentinel field of 512 zero bits (or equivalently, 64 null bytes), indicating the end of the key hashes
- The SHA-512 hash of the serialized encryption context
As a formula:
EDK_HASHES = [SHA512(SerializeEncryptedDataKey(key)) for key in decryptMaterialsRequest.encryptedDataKeys]
ENTRY_ID = SHA512(
SHA512(UTF8Encode(cachingCMM.partitionId))
+ AlgorithmSuiteId(decryptMaterialsRequest.algorithmSuite)
+ CONCATENATE(SORTED(EDK_HASHES))
+ PADDING_OF_512_ZERO_BITS
+ SHA512(SerializeEncryptionContext(decryptMaterialsRequest.encryptionContext))
)