-
Notifications
You must be signed in to change notification settings - Fork 12
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: Adding Caching CMM #80
base: main
Are you sure you want to change the base?
Conversation
Adding a Caching CMM implementation
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 know it's not finished, but I don't have any blocking complaints.
AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/Model/cmms.smithy
Outdated
Show resolved
Hide resolved
AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/Model/cmms.smithy
Outdated
Show resolved
Hide resolved
@javadoc("The Cryptographic Materials Cache the Caching Cryptographic Materials Manager will use to cache requests.") | ||
underlyingCMC: CryptographicMaterialsCacheReference, | ||
@required | ||
@javadoc("Sets the maximum lifetime for entries in the cache, for both encrypt and decrypt operations. When the specified amount of time passes after initial creation of the entry, the entry will be considered unusable, and the next operation will incur a cache miss.") |
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.
Nit/Suggestion: we cache materials, not operations
@javadoc("Sets the maximum lifetime for entries in the cache, for both encrypt and decrypt operations. When the specified amount of time passes after initial creation of the entry, the entry will be considered unusable, and the next operation will incur a cache miss.") | |
@javadoc("Sets the maximum lifetime for entries in the cache, for both encrypt and decrypt materials. When the specified amount of time passes after initial creation of the entry, the entry will be considered unusable, and the next operation will incur a cache miss.") |
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.
Hum, I think I want operations but I'm not sure.
The point here is that there is 1 cache.
But that items put in from encrypt are not hits on decrypt.
//# - [Partition ID](#partition-id) | ||
//# - [Limit Bytes](#limit-bytes) | ||
//# - [Limit Messages](#limit-messages) | ||
@javadoc("Sets the partition ID for this CMM. By default, two CMMs will never use each other's cache entries. This helps ensure that CMMs with different delegates won't incorrectly use each other's encrypt and decrypt results. However, in certain special circumstances it can be useful to share entries between different CMMs - for example, if the backing CMM is constructed based on some parameters that depend on the operation, you may wish for delegates constructed with the same parameters to share the same partition. To accomplish this, set the same partition ID and backing cache on both CMMs; entries cached from one of these CMMs can then be used by the other. This should only be done with careful consideration and verification that the CMM delegates are equivalent for your application's purposes. By default, the partition ID is set to a random UUID to avoid any collisions.") |
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.
Question: javadoc
is not handled by our Polymorph-.NET.
Is this content recorded in the public hosted docs?
Otherwise, .NET customers will never receive it.
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 content comes from the ESDK-Java.
So it is somewhat public.
I'd like to get javadoc
to work in every language so we don't have to worry about this :)
AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/Model/cmms.smithy
Outdated
Show resolved
Hide resolved
// For Dafny keyrings this is a trivial statement | ||
// because they implement a trait that ensures this. | ||
// However not all keyrings are Dafny keyrings. | ||
// Customers can create custom keyrings. |
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.
Praise: These comments are very helpful
...yptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/src/CMMs/CachingCMM.dfy
Outdated
Show resolved
Hide resolved
0,0,0,0,0,0,0,0 | ||
] | ||
|
||
lemma PaddingIsCorrect() |
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 kinda of fun.
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 was very pleased myself.
Especially since the first time I wrote it I have 8x9!
:= cryptoPrimitives.History.Digest[ | ||
|old(cryptoPrimitives.History.Digest)| .. |old(cryptoPrimitives.History.Digest)| + |input.encryptedDataKeys| | ||
]; |
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.
Question: Is this selection by index of History of Digest calls?
I'm not familiar with ..
in Dafny,
but I presume it is slicing.
I am confused because |old(cryptoPrimitives.History.Digest)|
is used twice...
OH, select from oldIndex
to oldIndex
+ EDK count.
Got it.
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.
Yes, it is slice.
Since there are some number of EDKs, I need to get all of them.
http://dafny.org/dafny/DafnyRef/DafnyRef#sec-other-sequence-expressions
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 had not realized the Decrypt cache's identifier included a digest of all EDKs for a message.
Updates to CachingCMM Small update to the create operation small update
…alProviders/Model/cmms.smithy Co-authored-by: Tony Knapp <5892063+texastony@users.noreply.github.com>
…alProviders/Model/cmms.smithy Co-authored-by: Tony Knapp <5892063+texastony@users.noreply.github.com>
…alProviders/Model/cmms.smithy Co-authored-by: Tony Knapp <5892063+texastony@users.noreply.github.com>
…alProviders/Model/cmms.smithy Co-authored-by: Tony Knapp <5892063+texastony@users.noreply.github.com>
See test vector PR for updates
Adding a Caching CMM implementation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Resolves #480