Skip to content

Commit e5f998e

Browse files
committed
cleanup
1 parent ebd4c14 commit e5f998e

File tree

7 files changed

+21
-61
lines changed

7 files changed

+21
-61
lines changed

DynamoDbEncryption/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ SERVICE_DEPS_DynamoDbEncryptionTransforms := \
7878
format_net:
7979
pushd runtimes/net && dotnet format DynamoDbEncryption.csproj && popd
8080

81-
# First, export DAFNY_VERSION=4.2
8281
polymorph:
82+
export DAFNY_VERSION=4.2
8383
npm i --no-save prettier@3 [email protected]
8484
make polymorph_code_gen PROJECT_DEPENDENCIES=

DynamoDbEncryption/dafny/DynamoDbItemEncryptor/src/AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations.dfy

+4-6
Original file line numberDiff line numberDiff line change
@@ -641,15 +641,13 @@ module AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations refines Abs
641641
function method ConvertCryptoSchemaToAttributeActions(config: ValidConfig, schema: CSE.CryptoSchemaMap)
642642
: (ret: Result<map<ComAmazonawsDynamodbTypes.AttributeName, CSE.CryptoAction>, Error>)
643643
requires forall k <- schema :: SE.IsAuthAttr(schema[k])
644-
// ensures ret.Success? ==> forall k <- ret.value.Keys :: InSignatureScope(config, k)
645-
// ensures ret.Success? ==> forall k <- ret.value.Keys :: !ret.value[k].DO_NOTHING?
644+
ensures ret.Success? ==> forall k <- ret.value.Keys :: InSignatureScope(config, k)
645+
ensures ret.Success? ==> forall k <- ret.value.Keys :: !ret.value[k].DO_NOTHING?
646646
{
647-
// We can formally verify these properties, but it is too resource intensive
648-
// :- Need(forall k <- schema :: InSignatureScope(config, k),
649-
// DynamoDbItemEncryptorException( message := "Received unexpected Crypto Schema: mismatch with signature scope"));
647+
:- Need(forall k <- schema :: InSignatureScope(config, k),
648+
DynamoDbItemEncryptorException( message := "Received unexpected Crypto Schema: mismatch with signature scope"));
650649
:- Need(forall k <- schema :: ComAmazonawsDynamodbTypes.IsValid_AttributeName(k),
651650
DynamoDbItemEncryptorException( message := "Received unexpected Crypto Schema: Invalid attribute names"));
652-
// Success(map k <- schema :: k := schema[k])
653651
Success(schema)
654652
}
655653

DynamoDbEncryption/dafny/StructuredEncryption/src/Crypt.dfy

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ module StructuredEncryptionCrypt {
127127

128128
datatype EncryptionSelector = DoEncrypt | DoDecrypt
129129

130+
// Updated return true if the given item has been updated properly for the given operation.
131+
// Updated2..Update5 do exactly the same thing, but with different data types.
130132
predicate Updated(oldVal : CanonCryptoItem, newVal : CanonCryptoItem, mode : EncryptionSelector)
131133
{
132134
&& oldVal.key == newVal.key

DynamoDbEncryption/dafny/StructuredEncryption/src/Header.dfy

+12-20
Original file line numberDiff line numberDiff line change
@@ -419,36 +419,28 @@ module StructuredEncryptionHeader {
419419
// as well as being included in the encryption context.
420420
// This indicates that this field MUST NOT be attempted to be decrypted during decryption. // - no entry if the attribute is not signed
421421
ensures match (x) {
422-
case ENCRYPT_AND_SIGN => ret == ENCRYPT_AND_SIGN_LEGEND
423-
case SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT => ret == SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT_LEGEND
424-
case SIGN_ONLY => ret == SIGN_ONLY_LEGEND
422+
case ENCRYPT_AND_SIGN() => ret == ENCRYPT_AND_SIGN_LEGEND
423+
case SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT() => ret == SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT_LEGEND
424+
case SIGN_ONLY() => ret == SIGN_ONLY_LEGEND
425425
}
426426
{
427427
match (x) {
428-
case ENCRYPT_AND_SIGN => ENCRYPT_AND_SIGN_LEGEND
429-
case SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT => SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT_LEGEND
430-
case SIGN_ONLY => SIGN_ONLY_LEGEND
428+
case ENCRYPT_AND_SIGN() => ENCRYPT_AND_SIGN_LEGEND
429+
case SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT() => SIGN_AND_INCLUDE_IN_ENCRYPTION_CONTEXT_LEGEND
430+
case SIGN_ONLY() => SIGN_ONLY_LEGEND
431431
}
432432
}
433433

434434
// How many elements of Schema are included in the signature?
435435
function method CountAuthAttrs(data : CanonCryptoList)
436436
: nat
437437
{
438-
|RestrictAuthAttrs(data)|
439-
}
440-
441-
/*
442-
* Restrict `data` to just the authenticated attributes.
443-
*/
444-
function method RestrictAuthAttrs(data: CanonCryptoList)
445-
: (authData: CanonCryptoList)
446-
// ensures authData.Keys <= data.Keys
447-
// ensures forall k <- data :: IsAuthAttr(data[k]) <==> k in authData
448-
// ensures forall k <- authData :: authData[k] == data[k]
449-
// ensures forall k <- authData :: IsAuthAttr(authData[k])
450-
{
451-
Seq.Filter((s : CanonCryptoItem) => IsAuthAttr(s.action), data)
438+
if |data| == 0 then
439+
0
440+
else if IsAuthAttr(data[0].action) then
441+
1 + CountAuthAttrs(data[1..])
442+
else
443+
CountAuthAttrs(data[1..])
452444
}
453445

454446
// Legend to Bytes

DynamoDbEncryption/dafny/StructuredEncryption/src/Paths.dfy

-19
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,6 @@ module StructuredEncryptionPaths {
253253
}
254254
}
255255

256-
// lemma SelectorNeverPrefixList(x : Selector, y : Selector)
257-
// requires x != y
258-
// requires x.List?
259-
// requires y.List?
260-
// ensures !(CanonicalPart(x) <= CanonicalPart(y))
261-
// ensures !(CanonicalPart(y) <= CanonicalPart(x))
262-
// {
263-
// assert x.pos != y.pos;
264-
// var cpX := CanonicalPart(x);
265-
// var cpY := CanonicalPart(y);
266-
// assert cpX == [ARRAY_TAG] + UInt64ToSeq(x.pos as uint64);
267-
// assert cpY == [ARRAY_TAG] + UInt64ToSeq(y.pos as uint64);
268-
// assert UInt64ToSeq(x.pos as uint64) != UInt64ToSeq(y.pos as uint64);
269-
// OnePlusOne([ARRAY_TAG], UInt64ToSeq(x.pos as uint64), UInt64ToSeq(y.pos as uint64));
270-
// assert cpX != cpY;
271-
// assert !(cpY <= cpX);
272-
// assert !(cpX <= cpY);
273-
// }
274-
275256
lemma SelectorNeverPrefix(x : PathSegment, y : PathSegment)
276257
requires x != y
277258
requires ValidString(x.member.key) && ValidString(y.member.key)

DynamoDbEncryption/dafny/StructuredEncryption/src/SortCanon.dfy

+2-6
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ module SortCanon {
4040
BelowIsReflexive(x.key);
4141
}
4242

43+
// not actually required for sorting. Standard library being updated.
4344
lemma {:axiom} AuthBelowIsAntiSymmetric(x: CanonAuthItem, y: CanonAuthItem)
4445
requires AuthBelow(x, y) && AuthBelow(y, x)
4546
ensures x == y
46-
// {
47-
// assert Below(x.key, y.key);
48-
// assert Below(y.key, x.key);
49-
// BelowIsAntiSymmetric(x.key, y.key);
50-
// BelowIsAntiSymmetric(y.key, x.key);
51-
// }
5247

48+
// not actually required for sorting. Standard library being updated.
5349
lemma {:axiom} CryptoBelowIsAntiSymmetric(x: CanonCryptoItem, y: CanonCryptoItem)
5450
requires CryptoBelow(x, y) && CryptoBelow(y, x)
5551
ensures x == y

DynamoDbEncryption/dafny/StructuredEncryption/src/Util.dfy

-9
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ module StructuredEncryptionUtil {
105105
&& UTF8.Encode(x).Success?
106106
}
107107

108-
// type StructuredDataPlain = map<GoodPath, StructuredDataTerminal>
109-
// type StructuredDataCanon = map<CanonicalPath, StructuredDataTerminal>
110-
// type CryptoSchemaPlain = map<GoodPath, CSE.CryptoAction>
111-
// type CryptoSchemaCanon = map<CanonicalPath, CSE.CryptoAction>
112-
// type AuthSchemaPlain = map<GoodPath, AuthenticateAction>
113-
// type AuthSchemaCanon = map<CanonicalPath, AuthenticateAction>
114-
// type CanonMap = map<CanonicalPath, GoodPath>
115-
116-
117108
// Within the context of the StructuredEncryptionClient, certain things must be true of any Algorithm Suite
118109
predicate method ValidSuite(alg : CMP.AlgorithmSuiteInfo)
119110
{

0 commit comments

Comments
 (0)