Skip to content

Commit 5ab9ea1

Browse files
RustanLeinoseebees
andauthored
Caching CMM (#96)
* Add caching CMM This caching CMM does not share the Cryptographic Materials Cache. Therefore, it does not make use of a partition ID. The PR updates the pre/post-conditions of the CMM's GetEncryptionMaterials and DecryptMaterials methods. It also adds freshness and other `Repr` specifications. Add a predicate ContainsIdentityKDF to AlgorithmSuite.ID. Add a utility module Time, which has a method that returns the current time in seconds since some fixed time in the past. * fix: Make Option be co-variant in its type argument This makes sense for the type Option and could have been done before. We need it in writing a nice `KeyRepr` function for keyrings (see upcoming PR). * Add unit tests * fix: Put helper routines in separate module to avoid xUnit warnings Allow zero TTL for testing purposes The specification says that the time-to-live limit has to be positive, but it's convenient for tests to allow it to be 0. This commit adds a constructor, `ForTestingOnly_WithZeroTimeToLive`, that sets the TTL limit to 0. With this constructor, the previous uncommendable 2-second sleep in the test harness can be removed. Co-authored-by: seebees <[email protected]>
1 parent 2c5e165 commit 5ab9ea1

File tree

16 files changed

+957
-17
lines changed

16 files changed

+957
-17
lines changed

src/AWSEncryptionSDK.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<DafnySource Include="KMS/KMSUtils.dfy" />
2828
<DafnySource Include="SDK/AlgorithmSuite.dfy" />
2929
<DafnySource Include="SDK/Client.dfy" />
30+
<DafnySource Include="SDK/CMM/CachingCMM.dfy" />
3031
<DafnySource Include="SDK/CMM/DefaultCMM.dfy" />
3132
<DafnySource Include="SDK/CMM/Defs.dfy" />
3233
<DafnySource Include="SDK/Deserialize.dfy" />

src/Crypto/Digest.dfy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@ module {:extern "Digest"} Digest {
77

88
datatype Algorithm = SHA_512
99

10+
function method Length(alg: Algorithm): nat {
11+
match alg
12+
case SHA_512 => 64
13+
}
14+
1015
method {:extern "Digest.SHA", "Digest"} Digest(alg: Algorithm, msg: seq<uint8>) returns (digest: Result<seq<uint8>>)
1116
}

src/SDK/AlgorithmSuite.dfy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ module {:extern "AlgorithmSuite"} AlgorithmSuite {
2424
Suite[this].algorithm.keyLen as nat
2525
}
2626

27+
predicate method ContainsIdentityKDF() {
28+
Suite[this].hkdf == KeyDerivationAlgorithms.IDENTITY
29+
}
30+
2731
function method KDFInputKeyLength(): nat
28-
ensures Suite[this].hkdf == KeyDerivationAlgorithms.IDENTITY ==> KDFInputKeyLength() == KeyLength()
32+
ensures ContainsIdentityKDF() ==> KDFInputKeyLength() == KeyLength()
2933
{
3034
// We're intentionally using a match here so additional Key Derivation Algorithms force us to revisit this logic
3135
// and we don't accidentally use Suite[this].algorithm.keyLen by default. Also, prevent or KDFInputKeyLength from

0 commit comments

Comments
 (0)