Skip to content

Commit 9db6e78

Browse files
authored
chore: verify with Dafny 4.6 (#1072)
* chore: verify with 4.6
1 parent 135acd9 commit 9db6e78

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.github/workflows/ci_verification.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
uses: dafny-lang/[email protected]
5151
with:
5252
# A && B || C is the closest thing to an if .. then ... else ... or ?: expression the GitHub Actions syntax supports.
53-
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.2.0' }}
53+
dafny-version: ${{ (github.event_name == 'schedule' || inputs.nightly) && 'nightly-latest' || '4.6.0' }}
5454

5555
- name: Regenerate code using smithy-dafny if necessary
5656
if: ${{ inputs.nightly }}

DynamoDbEncryption/dafny/DynamoDbEncryption/src/DynamoToStruct.dfy

+7
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ module DynamoToStruct {
357357
&& U32ToBigEndian(|a.L|).Success?
358358
&& |ret.value| >= PREFIX_LEN + LENGTH_LEN
359359
&& ret.value[0..TYPEID_LEN] == SE.LIST
360+
&& ListAttrToBytes(a.L, depth).Success?
361+
&& ret.value[PREFIX_LEN..] == ListAttrToBytes(a.L, depth).value
362+
&& ListAttrToBytes(a.L, depth).value[..LENGTH_LEN] == U32ToBigEndian(|a.L|).value
360363
&& ret.value[PREFIX_LEN..PREFIX_LEN+LENGTH_LEN] == U32ToBigEndian(|a.L|).value
361364
&& (|a.L| == 0 ==> |ret.value| == PREFIX_LEN + LENGTH_LEN)
362365

@@ -492,6 +495,10 @@ module DynamoToStruct {
492495
}
493496

494497
function method ListAttrToBytes(l: ListAttributeValue, depth : nat): (ret: Result<seq<uint8>, string>)
498+
ensures ret.Success? ==>
499+
&& U32ToBigEndian(|l|).Success?
500+
&& LENGTH_LEN <= |ret.value|
501+
&& ret.value[..LENGTH_LEN] == U32ToBigEndian(|l|).value
495502
{
496503
var count :- U32ToBigEndian(|l|);
497504
var body :- CollectList(l, depth);

DynamoDbEncryption/dafny/DynamoDbEncryption/test/DynamoDbEncryptionBranchKeyIdSupplierTest.dfy

+6-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ module DynamoDbEncryptionBranchKeyIdSupplierTest {
4343
const BRANCH_KEY_ID_B := ALTERNATE_BRANCH_KEY_ID
4444
const EC_PARTITION_NAME := UTF8.EncodeAscii("aws-crypto-partition-name")
4545
const RESERVED_PREFIX := "aws-crypto-attr."
46+
const KEY_ATTR_NAME := UTF8.EncodeAscii(RESERVED_PREFIX + BRANCH_KEY)
47+
const BRANCH_KEY_NAME := UTF8.EncodeAscii(BRANCH_KEY)
4648

47-
method {:test} TestHappyCase()
49+
method {:test} {:vcs_split_on_every_assert} TestHappyCase()
4850
{
4951
var ddbKeyToBranchKeyId: Types.IDynamoDbKeyBranchKeyIdSupplier := new TestBranchKeyIdSupplier();
5052
var ddbEncResources :- expect DynamoDbEncryption.DynamoDbEncryption();
@@ -80,27 +82,26 @@ module DynamoDbEncryptionBranchKeyIdSupplierTest {
8082
)
8183
);
8284

83-
var keyAttrName := UTF8.EncodeAscii(RESERVED_PREFIX + BRANCH_KEY);
8485

8586
// Test Encryption Context with Case A
8687
var materials :- expect mpl.InitializeEncryptionMaterials(
8788
MPL.InitializeEncryptionMaterialsInput(
8889
algorithmSuiteId := TEST_DBE_ALG_SUITE_ID,
89-
encryptionContext := map[EC_PARTITION_NAME := UTF8.EncodeAscii(BRANCH_KEY)],
90+
encryptionContext := map[EC_PARTITION_NAME := BRANCH_KEY_NAME],
9091
requiredEncryptionContextKeys := [],
9192
signingKey := None,
9293
verificationKey := None
9394
)
9495
);
9596

9697
var caseA :- expect UTF8.Encode(Base64.Encode(CASE_A_BYTES));
97-
var contextCaseA := materials.encryptionContext[keyAttrName := caseA];
98+
var contextCaseA := materials.encryptionContext[KEY_ATTR_NAME := caseA];
9899
var materialsA := materials.(encryptionContext := contextCaseA);
99100
TestRoundtrip(hierarchyKeyring, materialsA, TEST_DBE_ALG_SUITE_ID, BRANCH_KEY_ID_A);
100101

101102
// Test Encryption Context with Case B
102103
var caseB :- expect UTF8.Encode(Base64.Encode(CASE_B_BYTES));
103-
var contextCaseB := materials.encryptionContext[keyAttrName := caseB];
104+
var contextCaseB := materials.encryptionContext[KEY_ATTR_NAME := caseB];
104105
var materialsB := materials.(encryptionContext := contextCaseB);
105106
TestRoundtrip(hierarchyKeyring, materialsB, TEST_DBE_ALG_SUITE_ID, BRANCH_KEY_ID_B);
106107
}

DynamoDbEncryption/dafny/StructuredEncryption/src/Canonize.dfy

+2
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ module {:options "/functionSyntax:4" } Canonize {
667667
forall i | 0 <= i < |input| ensures exists x :: x in origData && Updated2(x, input[i], DoDecrypt) {
668668
var x :| x in origData && Updated2(x, input[i], DoDecrypt);
669669
}
670+
assert forall i | 0 <= i < |input| :: exists x :: x in origData && Updated2(x, input[i], DoDecrypt);
670671
}
671672

672673
// command line tools that say /vcsSplitOnEveryAssert fail without the {:vcs_split_on_every_assert false}
@@ -678,6 +679,7 @@ module {:options "/functionSyntax:4" } Canonize {
678679
forall i | 0 <= i < |input| ensures exists x :: x in origData && Updated5(x, input[i], DoEncrypt) {
679680
var x :| x in origData && Updated5(x, input[i], DoEncrypt);
680681
}
682+
assert forall i | 0 <= i < |input| :: exists x :: x in origData && Updated5(x, input[i], DoEncrypt);
681683
}
682684

683685
lemma CryptoUpdatedAuthMaps(origData : AuthList, input : CanonCryptoList, output : CryptoList)

DynamoDbEncryption/dafny/StructuredEncryption/src/SortCanon.dfy

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ module SortCanon {
222222
ensures multiset(x) == multiset(result)
223223
ensures SortedBy(result, AuthBelow)
224224
ensures CanonAuthListHasNoDuplicates(result)
225+
ensures |result| == |x|
225226
{
226227
AuthBelowIsTotal();
227228
var ret := MergeSortBy(x, AuthBelow);
@@ -236,6 +237,7 @@ module SortCanon {
236237
ensures multiset(result) == multiset(x)
237238
ensures SortedBy(result, CryptoBelow)
238239
ensures CanonCryptoListHasNoDuplicates(result)
240+
ensures |result| == |x|
239241
{
240242
CryptoBelowIsTotal();
241243
var ret := MergeSortBy(x, CryptoBelow);

0 commit comments

Comments
 (0)