Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
8db6855
CreateKeyInput changes
rishav-karanjit Jun 25, 2025
464271c
Update branch-key-store.md
rishav-karanjit Jun 25, 2025
5a46148
auto commit
rishav-karanjit Jun 25, 2025
1ce8bf0
bkc
rishav-karanjit Jun 25, 2025
3ebc886
auto commit
rishav-karanjit Jun 26, 2025
178bd9a
auto commit
rishav-karanjit Jun 26, 2025
f246cc4
auto commit
rishav-karanjit Jun 26, 2025
838e818
auto commit
rishav-karanjit Jun 26, 2025
6bff806
auto commit
rishav-karanjit Jun 26, 2025
413d74d
auto commit
rishav-karanjit Jun 26, 2025
ab82862
auto commit
rishav-karanjit Jun 26, 2025
5f9db4c
auto commit
rishav-karanjit Jun 26, 2025
8b54bac
auto commit
rishav-karanjit Jun 26, 2025
8308fcb
auto commit
rishav-karanjit Jun 26, 2025
8baeb72
auto commit
rishav-karanjit Jun 26, 2025
879f13c
auto commit
rishav-karanjit Jun 26, 2025
13aef97
auto commit
rishav-karanjit Jun 26, 2025
6a35be8
auto commit
rishav-karanjit Jun 26, 2025
1360dab
auto commit
rishav-karanjit Jun 26, 2025
4550add
auto commit
rishav-karanjit Jun 27, 2025
757de04
nits
rishav-karanjit Jun 27, 2025
fe9405c
Update framework/branch-key-store.md
rishav-karanjit Jun 30, 2025
117b632
Update framework/branch-key-store.md
rishav-karanjit Jun 30, 2025
9f7b93e
DQ1
rishav-karanjit Jun 30, 2025
05a9cf7
formatting:
rishav-karanjit Jun 30, 2025
95b70f3
auto commit
rishav-karanjit Jul 1, 2025
e8f5784
auto commit
rishav-karanjit Jul 1, 2025
02ea9a3
Initial empty commit
rishav-karanjit Jul 1, 2025
9635b60
auto commit
rishav-karanjit Jul 1, 2025
686f21c
auto commit
rishav-karanjit Jul 1, 2025
b822360
chore: add hv-2 changes in ./changes directory
rishav-karanjit Jul 1, 2025
ebac8ac
auto commit
rishav-karanjit Jul 1, 2025
a2d8a48
auto commit
rishav-karanjit Jul 2, 2025
01a22e6
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 2, 2025
ef6d1dc
Update branch-key-store.md
rishav-karanjit Jul 2, 2025
e8d54f2
auto commit
rishav-karanjit Jul 9, 2025
e768f46
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
0481ed3
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
4aa2261
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
db3300d
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
a48aabf
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
02de72b
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
bbe76a8
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
83bff87
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
8963404
auto commit
rishav-karanjit Jul 14, 2025
4eafe3d
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Jul 14, 2025
d538a41
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
a341b0d
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
72d95fb
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
a16bcbb
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
d853d8f
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
55d690f
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
8ed6bfe
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
d3100a9
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
0593bdb
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
865c3ed
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
9858b49
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
7529099
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
bc6c700
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
47d1cdc
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
2b28735
Update changes/2025-06-30_branch_keys_version_2/designquestion.md
rishav-karanjit Jul 14, 2025
9e4c9aa
Update framework/branch-key-store.md
rishav-karanjit Jul 14, 2025
3ee3a0c
Update framework/branch-key-store.md
rishav-karanjit Jul 14, 2025
d827b21
Update framework/branch-key-store.md
rishav-karanjit Jul 14, 2025
25c5b20
Update framework/branch-key-store.md
rishav-karanjit Jul 14, 2025
55fccff
Apply suggestions from code review
rishav-karanjit Jul 14, 2025
8095f24
auto commit
rishav-karanjit Jul 15, 2025
ca4d912
auto commit
rishav-karanjit Jul 15, 2025
77c3833
Merge branch 'master' into rishav/hv-2-spec
rishav-karanjit Jul 16, 2025
8d4eb7f
auto commit
rishav-karanjit Jul 16, 2025
541c729
Update framework/branch-key-store.md
rishav-karanjit Jul 16, 2025
82c1ad8
auto commit
rishav-karanjit Jul 16, 2025
688c354
auto commit
rishav-karanjit Jul 16, 2025
81b60e8
auto commit
rishav-karanjit Jul 16, 2025
30e58d9
Update background.md
rishav-karanjit Jul 16, 2025
ec22bf4
auto commit
rishav-karanjit Jul 16, 2025
8db8704
auto commit
rishav-karanjit Jul 16, 2025
d062762
formatting
rishav-karanjit Jul 16, 2025
b49dd3f
auto commit
rishav-karanjit Jul 17, 2025
1ad7803
auto commit
rishav-karanjit Jul 17, 2025
15bc50a
auto commit
rishav-karanjit Jul 17, 2025
aad0ee3
designq -> protect_branch_key_without_kms_ec
rishav-karanjit Jul 17, 2025
2d105ea
resolve https://github.com/awslabs/aws-encryption-sdk-specification/p…
rishav-karanjit Jul 18, 2025
7d10c1f
resolve https://github.com/awslabs/aws-encryption-sdk-specification/p…
rishav-karanjit Jul 18, 2025
a725bc0
nit fix
rishav-karanjit Jul 18, 2025
79c5efd
resolve https://github.com/awslabs/aws-encryption-sdk-specification/p…
rishav-karanjit Jul 18, 2025
feaa9f0
Update framework/branch-key-store.md
rishav-karanjit Jul 18, 2025
e2f3eb8
Update framework/branch-key-store.md
rishav-karanjit Jul 21, 2025
625ec56
auto commit
rishav-karanjit Jul 21, 2025
e818581
Update framework/branch-key-store.md
rishav-karanjit Jul 21, 2025
3725032
Update framework/structures.md
rishav-karanjit Jul 21, 2025
d6fd990
Update framework/branch-key-store.md
rishav-karanjit Jul 21, 2025
9c5c281
auto commit
rishav-karanjit Jul 21, 2025
1ccbcbe
auto commit
rishav-karanjit Jul 21, 2025
e982ff0
auto commit
rishav-karanjit Jul 21, 2025
24b76b8
auto commit
rishav-karanjit Jul 21, 2025
f300cd0
formatting
rishav-karanjit Jul 21, 2025
d3453f8
Merge branch 'master' into rishav/hv-2-spec
rishav-karanjit Jul 22, 2025
7fa3363
chore: encryption-context changes (#300)
rishav-karanjit Jul 23, 2025
ebec074
Update framework/branch-key-store.md
rishav-karanjit Aug 5, 2025
921c377
Apply suggestions from code review
rishav-karanjit Aug 5, 2025
d273219
chore: fix typos (#303)
ajewellamz Aug 5, 2025
10327a3
m
ajewellamz Aug 6, 2025
c282b60
m
ajewellamz Aug 13, 2025
4ff8581
m
ajewellamz Aug 14, 2025
1c1ebce
m
ajewellamz Aug 18, 2025
01a3bc4
m
ajewellamz Aug 19, 2025
107dbde
Merge branch 'master' into rishav/hv-2-spec
rishav-karanjit Aug 20, 2025
cbe0ace
Un-modeled Branch Key Context Key Values
rishav-karanjit Aug 25, 2025
b8ec944
Merge branch 'master' into rishav/hv-2-spec
rishav-karanjit Aug 28, 2025
3825803
auto commit
rishav-karanjit Aug 28, 2025
f0fe48f
auto commit
rishav-karanjit Aug 28, 2025
fb3cf07
auto commit
rishav-karanjit Aug 28, 2025
edbd262
auto commit
rishav-karanjit Aug 28, 2025
10edc73
Update changes/2025-06-30_branch_keys_version_2/background.md
seebees Aug 28, 2025
39b1cb3
Update framework/branch-key-store.md
rishav-karanjit Aug 28, 2025
966b22c
Update changes/2025-06-30_branch_keys_version_2/protect_branch_key_wi…
rishav-karanjit Aug 28, 2025
c26bf4b
Update changes/2025-06-30_branch_keys_version_2/un-modeled_branch_key…
rishav-karanjit Aug 28, 2025
8c23b61
Update changes/2025-06-30_branch_keys_version_2/background.md
rishav-karanjit Aug 28, 2025
db09f47
Update changes/2025-06-30_branch_keys_version_2/protect_branch_key_wi…
rishav-karanjit Aug 28, 2025
fc08e88
formatting
rishav-karanjit Aug 29, 2025
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
328 changes: 328 additions & 0 deletions changes/2025-06-30_branch_keys_version_2/background.md
Copy link
Member Author

@rishav-karanjit rishav-karanjit Jul 17, 2025

Choose a reason for hiding this comment

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

Note to readers: This was reviewed in design doc review of hv-2

Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
[//]: # "Copyright Amazon.com Inc. or its affiliates. All Rights Reserved."
[//]: # "SPDX-License-Identifier: CC-BY-SA-4.0"

# Customers should control encryption context

# Definitions

## Conventions used in this document

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](https://tools.ietf.org/html/rfc2119).

## HV-1

The Branch Key Store's Branch Keys are designated as `"hierarchy-version" : "1"`.

This document proposes changes to theses Branch Keys;
when HV-1 is written,
we mean a Branch Key Item written by the Branch Key Store prior to this change, which will always describe it's self as `"hierarchy-version" : "1"`.

## Branch Key's Cryptographic Material

Cryptographic material (AES-256 bit key) generated and protected by KMS.

## Branch Key's Properities

These three values are stored on every
Active,
Version,
and Beacon Key Item in the Branch Key Store's Storage.

They are also present in the KMS Encryption Context.

```json
"kms-arn" : "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
"create-time" : "2023-06-03T19:03:29.358Z",
"hierarchy-version" : "1",
```

The Active has an additional field:

```json
"version": "branch:version:83eec007-5659-4554-bf11-699b90f41ac6"
```

## Branch Key's Location

These two values are stored on every
Active,
Version,
and Beacon Key Item in the Branch Key Store's Storage.

For Active:

```json
"branch-key-id" : "bbb9baf1-03e6-4716-a586-6bf29995314b",
"type" : "branch:ACTIVE"
```

For Version:

```json
"branch-key-id" : "bbb9baf1-03e6-4716-a586-6bf29995314b",
"type": "branch:version:83eec007-5659-4554-bf11-699b90f41ac6"
```

For Beacon:

```json
"branch-key-id" : "bbb9baf1-03e6-4716-a586-6bf29995314b",
"type": "beacon:ACTIVE"
```

However,
the Logical Key Store Name is also included in the KMS Encryption Context.

```json
"branch-key-id" : "bbb9baf1-03e6-4716-a586-6bf29995314b",
"type" : "branch:ACTIVE",
"tablename": "KeyStore"
```

These three values describe where the Branch Key is stored; however, the tablename is a logical description, not a physical description.
At this time, no cryptography binds the Branch Key to the physical table.

```json
"branch-key-id" : "bbb9baf1-03e6-4716-a586-6bf29995314b",
"tablename": "KeyStore"
```

These two values label the Branch Key, seperating it from all other Branch Keys.

## Branch Key's Encryption Context

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

In DynamoDB and in KMS Encryption Requests for HV-1,
their keys are prefixed with `aws-crypto-ec:`.

```json
"aws-crypto-ec:department" : "admin"
```

However,
when returned to the requesters of the Branch Key Store's
`Get*Key*` operations,
the prefix is removed.

## Branch Key's Context

The union of the Branch Key's:

- Properities
- Location (including logical key store name)
- Encryption Context

# Background

The current Branch Key Store's Branch Keys use KMS Encryption Context
to cryptographically bind the Branch Key's cryptographic material to
the Branch Key's Context.

This cryptographic binding mitigates a number of threats around
storing the Branch Keys
and is vital to the safe usage of the Hierarchal Keyring.

However,
it is not clear that this is the best use of KMS Encryption Context,
as it interferes with customers ability to use KMS Key Policies to
constrain Key Usage.

Further more,
Encryption Context evaluation can be customized by the calling principles authorization;
KMS Key Grants can have restricted but unique conditions.

Many potential Branch Key Customers are prevented from using
the Hierarchy Keyring,
as they have pre-existing Key Policies with their tenants
that cannot be met if the KMS Encryption Context is transformed
by the Branch Key Store.

# Requirements

1. Branch Key's Context be cryptographically bound to the Branch Key's Cryptographic Material

2. Branch Key's Encryption Context, untransformed in any way, is the KMS Encryption Context

3. Support for all of Behaviors of the current Branch Key Store (Create, Version, Get\*)

# Out of Scope

- Abstracting away from KMS
- Supporting any Branch Key protection Scheme via the DB-ESDK, much like the DDBEC's MetaStore.

## Why not Abstract away from KMS

Over the past year,
Crypto Tools has spent a significant amount of our time
supporting services integrating with KMS for multi-tenant applications.

While we MAY eventually want to support GCP or Azure,
we MUST focus on the fasting growing customer base we have;
AWS Services and Software-as-a-service providers integrating with KMS.

## Why not the MetaStore approach?

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.

However, our customers have complained that the DB-ESDK is complicated;
using the DB-ESDK to protect the materials used by the DB-ESDK and the ESDK is NOT
a step towards simplification.

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.

# Design Questions

## 1 How can the Branch Key's Context be protected without using KMS EC?

See [protect_branch_key_without_kms_ec.md](./protect_branch_key_without_kms_ec.md).

## 2 How are we going to offer operation in a mixed mode?

UPDATE: 2.1 was rejected.
There will be no Policy (2.2).

### 2.1 `hierarchy-version-policy`

Much like [Key Commitment](https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#key-commitment),
we could introduce a policy that
would allow for mixed usage or restricting to one or the other.

Something like `hierarchy-version-policy`:

- ALLOW_V1
- ALLOW_V2
- ALLOW_V1_OR_V2
- ANY

This policy would be part of (all) Branch Key Store configuration.

(all: Branch Key Store, any future Branch Key Store Usage client.)

This allows our customers to
restrict to one KMS Encryption Context
experience or another.

The effort to implement and test this is very low,
relative to other code paths in this effort.

### 2.2 Do Nothing

UPDATE: We are going with Do Nothing

There is no immediate customer demand for a policy like this.
In general,
the Branch Key in the table,
in combination with KMS,
the authority of it's treatment.

However,
given the low effort required to implement/support this,
and the aid it gives our customers in having
a consistent KMS Encryption Context experience,
I suggest we implement the policy.

### 2.3 Pros of 2.1

**Update Readers, than Writers**:
To use HV-2,
customers already using the H-Keyring will need
to update their readers before they start creating
or mutating Branch Keys to HV-2.

i.e: They need to update their readers before they update their writers.

This alone is justification for the policy.

**Consistent KMS Encryption Context**:
The arguments for the HV-1 Encryption Context suggest
users SHOULD be able to restrict their Branch Key Store clients
to a HV-1 such that they know any IAM or KMS Key Policies
they created that depend on HV-1's Encryption Context
are still valid.

### 2.4 Cons

**Additional Development work and documentation**:
Nothing is free;
we would need to implement, document, test, and maintain this policy.

Still,
the migration benefit justifies this cost.

## 3 Branch Key Creation

UPDATE: The team decided that the Branch Key Store would create and version both HV-1 and HV-2 BKs.

UPDATE: The team changed their mind; the Branch Key Store WILL support HV-2 Branch Key Creation, via a flag.

Customers MUST be able to chose which `hierarchy-version`
new Branch Keys are created with.

The question is what should the UX be.

### 3.1 Specify the `hierarchy-version` at Creation

Currently, our library has one Branch Key Creation operations:

- `BranchKeyStore#CreateKey`

To this operation,
we add a flag that dictates the `hierarchy-version` to be created with.

If that flag conflicts with `hierarchy-version-policy`,
then FAIL (update: `hierarchy-version-policy` was rejected, see [section 2](#2-how-are-we-going-to-offer-operation-in-a-mixed-mode)).

Otherwise, respect the flag.

**Plumbing through `GenerateRandom`**:
UPDATE: `kms:GenerateDataKey` closed this negative consequence.

### 3.2 Follow the Configuration

This does not work if the configuration is `ALLOW\_V1\_OR_V2`;
this is not recommended.

### 3.3 New Operation or Client

We could leave the old Branch Key Store alone,
and introduce a new Branch Key Store V2.

The UX advantage here is that we can introduce new error types
without breaking customers.

For example,
the creation of the `hierarchy-version-policy` implies
that we will need an error type for rejecting a Branch Key
that does not match.

Particularly if we went down the additional KMS approaches (1.2, 1.3),
new error types will need to be created to represent
failures from the additional KMS key.

But we have committed to 1.4;
this limits the failure modes/additional errors
to the point that I do not think new client
or operation is needed.

### 3.4 Author's conclusion

Unless someone can think of something else,
3.1.

## 4 Branch Key Versioning (Rotation)

Branch key store can VersionKey for HV-1 or HV-2 based on schema version (equivalent to hierarchical version) of the branch key item.
Loading