Skip to content

feat(branch-keys): add hv-2 spec #297

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

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Conversation

rishav-karanjit
Copy link
Member

@rishav-karanjit rishav-karanjit commented Jun 26, 2025

Issue #, if available:

Description of changes:
Crypto tools is adding a new feature (Hierarchical Keyring V2) in MPL main branch. This PR adds the specification for it.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

- `DestinationEncryptionContext` MUST be the [encryption context](#encryption-context) of the EncryptedHierarchicalKey to be authenticated
- `DestinationEncryptionContext` MUST be the [encryption context](#encryption-context) constructed above

#### Authenticating a Keystore item for item with `hierarchy-version` v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Branch Key Store item.

There are many Key Stores in the world.
Ours is the Branch Key Store.

Copy link
Member Author

@rishav-karanjit rishav-karanjit Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it as Authenticating a Branch Keystore item for item with hierarchy-version v(1/2)


If the `hierarchy-version` is v1, Beacon Encryption Context is same as [Beacon Key Branch Key Context](#beacon-key-branch-key-context)

### Custom Encryption Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I am not sure we need "Custom Encryption Context".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mentioned in many places. There should be a variation of EC that we can point at saying this is the key value pair what customer has send for which we added the prefix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, I removed "Custom branch key context"

@rishav-karanjit rishav-karanjit marked this pull request as ready for review June 26, 2025 19:28
@rishav-karanjit rishav-karanjit requested a review from a team as a code owner June 26, 2025 19:28
Copy link
Contributor

@texastony texastony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits, need to do a proper review when I get home.

The operation MUST call [AWS KMS API Encrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html)
with a request constructed as follows:

- `Plaintext` **beacon plain-text tuple**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved at 757de04

the operation MUST use the Encrypt result `CiphertextBlob`
as the wrapped `ACTIVE` Branch Key.

#### Writing Branch Key and Beacon Key to Keystore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch Key Store table

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved at 757de04

If the `hierarchy-version` is v1, AWS KMS encryption context MUST be same as [branch key context](#branch-key-context).
If the `hierarchy-version` is v2, AWS KMS encryption context MUST be the [encryption context](../structures.md#encryption-context) send by users without any transformation.

AWS KMS encryption context MUST be always the same encryption context send by user regardless of any variation of encryption context (i.e.: ACTIVE Encryption Context, DECRYPT_ONLY Encryption Context, Beacon Key Encryption Context and Custom Encryption Context).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line reads funny. I think I understand what we are trying to say.
But I think we need to clean it up.

Copy link
Member Author

@rishav-karanjit rishav-karanjit Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrase it to

"""
If the hierarchy-version is v2, the encryption context send to AWS KMS MUST always match the encryption context originally sent by the user, without any variations. This requirement applies regardless of the type of encryption context being used, whether it is the ACTIVE encryption context, the DECRYPT_ONLY encryption context, the Beacon Key encryption context, or a custom encryption context.
"""

lmk if you have any suggestion

@rishav-karanjit rishav-karanjit marked this pull request as draft July 1, 2025 21:53
@rishav-karanjit
Copy link
Member Author

Moved to work in progress PR to go through the spec one more time tomorrow.

@rishav-karanjit rishav-karanjit marked this pull request as ready for review July 2, 2025 18:12
Copy link
Contributor

@texastony texastony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good start.

These values are determined by the Branch Key Creator
or last Branch Key Mutator.

In DynamoDB and in KMS Encryption Requests,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In DynamoDB and in KMS Encryption Requests,
In DynamoDB and in KMS Encryption Requests for HV-1,


# Background

The current Branch Key Store's Branch Key's use KMS Encryption Context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The current Branch Key Store's Branch Key's use KMS Encryption Context
The current Branch Key Store's Branch Keys use KMS Encryption Context

Comment on lines +144 to +147
Finally,
some of the users have insisted that
Crypto Tools refactor the KMS Encryption Context
to only be the Branch Key's Encryption Context.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Remove; this made sense in private, when I was trying to sell HV-2, but now we have sold HV-2, and do not need this sentence.

Suggested change
Finally,
some of the users have insisted that
Crypto Tools refactor the KMS Encryption Context
to only be the Branch Key's Encryption Context.

Comment on lines +174 to +176
The MetaStore was the predecessor to the Branch Key Store; it is the "caching" solution for the legacy DynamoDB Encryption Client (DDBEC). The MetaStore used the DDBEC itself to protect the hierarchical material with KMS.

Which affords for some flexibility, as the MetaStore was an interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The MetaStore was the predecessor to the Branch Key Store; it is the "caching" solution for the legacy DynamoDB Encryption Client (DDBEC). The MetaStore used the DDBEC itself to protect the hierarchical material with KMS.
Which affords for some flexibility, as the MetaStore was an interface.
The MetaStore was the predecessor to the Branch Key Store;
it is the "caching" solution for the legacy DynamoDB Encryption Client (DDBEC).
The MetaStore used the DDBEC itself to protect the hierarchical material with KMS;
this affords for some flexibility,
as the MetaStore was an interface that exposes the full breadth of DDBEC functionality.
This gives customers significant freedom on what data is bound to a Branch Key Item's material and how that binding is facilitated.

Comment on lines +182 to +185
While such a feature MAY provide the greatest flexibility to
our customers,
it is not a simplification of the Hierarchy Keyring,
but a complication to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
While such a feature MAY provide the greatest flexibility to
our customers,
it is not a simplification of the Hierarchy Keyring,
but a complication to it.
While such a feature MAY provide the greatest flexibility to
our customers,
it is not a simplification of the Hierarchy Keyring,
but a complication to it.
It also would make the DB-ESDK a dependency of the ESDK,
and introduce a circular dependency between the MPL and the DB-ESDK.


The DECRYPT_ONLY encryption context MUST NOT have a `version` attribute.
The DECRYPT_ONLY branch key context MUST NOT have a `version` attribute.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The DECRYPT_ONLY branch key context MUST NOT have a `version` attribute.
The DECRYPT_ONLY branch key context MUST NOT have a `version` key.


The DECRYPT_ONLY encryption context MUST NOT have a `version` attribute.
The DECRYPT_ONLY branch key context MUST NOT have a `version` attribute.
The `type` attribute MUST stores the branch key version formatted like `"branch:version:"` + `version`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `type` attribute MUST stores the branch key version formatted like `"branch:version:"` + `version`.
The `type` value MUST store the branch key version formatted like `"branch:version:"` + `<version UUID>`.

### Beacon Key Encryption Context
### Beacon Branch Key Context

In addition to the [branch key context](#encryption-context):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In addition to the [branch key context](#encryption-context):
In addition to the [branch key context](#branch-key-context):

In addition to the [branch key context](#encryption-context):

The Beacon key branch key context MUST includes a key `type` and the value MUST be `"beacon:ACTIVE"`.
The Beacon key branch key context MUST NOT have a `version` attribute.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Beacon key branch key context MUST NOT have a `version` attribute.
The Beacon key branch key context MUST NOT have a `version` key.

If the `hierarchy-version` is v1, AWS KMS encryption context MUST be same as [branch key context](#branch-key-context).
If the `hierarchy-version` is v2, AWS KMS encryption context MUST be the [encryption context](../structures.md#encryption-context) send by users without any transformation.

If the `hierarchy-version` is v2, the encryption context send to AWS KMS MUST always match the encryption context originally sent by the user, without any variations. This requirement applies regardless of the type of encryption context being used, whether it is the ACTIVE encryption context, the DECRYPT_ONLY encryption context, the Beacon Key encryption context, or a custom encryption context.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be revised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants