-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: Cache across Hierarchy Keyrings #273
Conversation
The Hierarchy Keyring, | ||
and it's component the (Branch) Keystore, | ||
allow MPL Consumers to reduce their KMS Call volume | ||
by persisting KMS protected cryptographic materials into | ||
an avabile medium | ||
(currently, only a DynamoDB table is avabile as persistence medium). | ||
|
||
We call these cryptographic materials Branch Keys. | ||
|
||
However, an instance of the Hierarchy Keyring | ||
can only ever call KMS with one KMS Relationship, | ||
which is, at least partly, | ||
configured on the KMS Client determined | ||
at the Hierarchy Keyring's construction. | ||
|
||
By KMS Relationship, we mean any or all of the following: | ||
|
||
- KMS Configuration | ||
- Credentials used when creating the KMS Client, and thus used when calling KMS | ||
- Other properties of the KMS Client, such as the region, or request headers | ||
|
||
The Local Cryptographic Material Cache of | ||
the Hierarchy Keyring instance is then only | ||
populated with Branch Keys that correspond with | ||
that KMS relationship. | ||
|
||
Which is appropriate, | ||
as it is clear under what KMS relationship | ||
a Branch Key is accessed. | ||
|
||
However, | ||
the Hierarchy Keyring, | ||
and it's Keystore, | ||
have a runtime cost, | ||
exerting memory pressure | ||
and, without manual optimization, | ||
requiring at least 2 TLS handshakes | ||
when first serving a request | ||
(TLS to KMS & TLS to DDB). | ||
|
||
Additionally, | ||
the local Cryptographic Materials Cache | ||
exerts some runtime cost, | ||
particularly in a multi-threaded environment, | ||
when a background worker thread MAY be refreshing | ||
or pruning entries of the cache. | ||
|
||
For MPL Consumers that MUST work with Branch Keys | ||
under different KMS Relationships, | ||
this runtime cost adds up. | ||
|
||
These MPL Consumers MAY end up establishing | ||
a LRU Cache of Hierarchy Keyrings. | ||
|
||
Which, while workable, is sub-optimal, | ||
and clearly makes the Hierarchy Keyring, | ||
in these conditions, | ||
"Hard to Use". | ||
|
||
The objective, with these changes, | ||
is to make the Hierarchy Keyring | ||
"Easy to Use" in a multiple KMS Relationship | ||
environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking: All of this should be moved to the Motivation.
To facilitate Caching across KeyStores/KMS Clients/KMS Keys, | ||
we MUST break the Cryptographic Materials Cache (CMC) | ||
out of the Hierarchy Keyring. | ||
|
||
By allowing MPL Consumers to provide an already initialized CMC | ||
to the Hierarchy Keyring at construction, | ||
the CMC MAY cache Branch Keys protected by different | ||
KMS Relationships. | ||
|
||
This simplifies Multiple KMS Relationship MPL Consumers, | ||
as they do not need to stand up LRU Cache of Hierarchy Keyrings. | ||
|
||
Instead, they may maintain one CMC. | ||
They still create a Hierarchy Keyring instance per KMS Relationship, | ||
and they MUST use the correct Keyring to retrieve material | ||
from the Cache. | ||
|
||
But they need not maintain many Keyrings; | ||
only the common cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably sufficient for the Summary.
## Motivation | ||
|
||
TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I am going to break our convention, and move Motivation to be right behind Summary.
Issue #, if available:
Description of changes:
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: