Skip to content

Commit

Permalink
refine the cache
Browse files Browse the repository at this point in the history
Use the provided cache.

Calling `mpl.CreateCryptographicMaterialsCache`
with a `Shared` cache will result in an error.

Update the testing to
ensure that no shared cache is passed.
  • Loading branch information
seebees committed Oct 30, 2024
1 parent 1deae41 commit b6aa520
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 13 additions & 8 deletions DynamoDbEncryption/dafny/DynamoDbEncryption/src/ConfigToInfo.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ module SearchConfigToInfo {
else
MPT.Default(Default := MPT.DefaultCache(entryCapacity := 1));

//= specification/searchable-encryption/search-config.md#key-store-cache
//# For a Beacon Key Source a [CMC](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/cryptographic-materials-cache.md)
//# MUST be created.
var input := MPT.CreateCryptographicMaterialsCacheInput(
cache := cacheType
);
var maybeCache := mpl.CreateCryptographicMaterialsCache(input);
var cache :- maybeCache.MapFailure(e => AwsCryptographyMaterialProviders(e));
var cache;
if cacheType.Shared? {
cache := cacheType.Shared;
} else {
//= specification/searchable-encryption/search-config.md#key-store-cache
//# For a Beacon Key Source a [CMC](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/cryptographic-materials-cache.md)
//# MUST be created.
var input := MPT.CreateCryptographicMaterialsCacheInput(
cache := cacheType
);
var maybeCache := mpl.CreateCryptographicMaterialsCache(input);
cache :- maybeCache.MapFailure(e => AwsCryptographyMaterialProviders(e));
}

if config.multi? {
:- Need(0 < config.multi.cacheTTL, E("Beacon Cache TTL must be at least 1."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ module BeaconTestFixtures {
ensures output.keyStore.ValidState()
ensures fresh(output.keyStore.Modifies)
ensures output.version == 1
ensures
&& output.keySource.multi?
&& output.keySource.multi.cache.None?
{
var store := GetKeyStore();
return BeaconVersion (
Expand Down

0 comments on commit b6aa520

Please sign in to comment.