Skip to content

Commit b6aa520

Browse files
committed
refine the cache
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.
1 parent 1deae41 commit b6aa520

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/src/ConfigToInfo.dfy

+13-8
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,19 @@ module SearchConfigToInfo {
137137
else
138138
MPT.Default(Default := MPT.DefaultCache(entryCapacity := 1));
139139

140-
//= specification/searchable-encryption/search-config.md#key-store-cache
141-
//# For a Beacon Key Source a [CMC](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/cryptographic-materials-cache.md)
142-
//# MUST be created.
143-
var input := MPT.CreateCryptographicMaterialsCacheInput(
144-
cache := cacheType
145-
);
146-
var maybeCache := mpl.CreateCryptographicMaterialsCache(input);
147-
var cache :- maybeCache.MapFailure(e => AwsCryptographyMaterialProviders(e));
140+
var cache;
141+
if cacheType.Shared? {
142+
cache := cacheType.Shared;
143+
} else {
144+
//= specification/searchable-encryption/search-config.md#key-store-cache
145+
//# For a Beacon Key Source a [CMC](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/cryptographic-materials-cache.md)
146+
//# MUST be created.
147+
var input := MPT.CreateCryptographicMaterialsCacheInput(
148+
cache := cacheType
149+
);
150+
var maybeCache := mpl.CreateCryptographicMaterialsCache(input);
151+
cache :- maybeCache.MapFailure(e => AwsCryptographyMaterialProviders(e));
152+
}
148153

149154
if config.multi? {
150155
:- Need(0 < config.multi.cacheTTL, E("Beacon Cache TTL must be at least 1."));

DynamoDbEncryption/dafny/DynamoDbEncryption/test/BeaconTestFixtures.dfy

+3
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ module BeaconTestFixtures {
181181
ensures output.keyStore.ValidState()
182182
ensures fresh(output.keyStore.Modifies)
183183
ensures output.version == 1
184+
ensures
185+
&& output.keySource.multi?
186+
&& output.keySource.multi.cache.None?
184187
{
185188
var store := GetKeyStore();
186189
return BeaconVersion (

0 commit comments

Comments
 (0)