16
16
import DynamoDbItemEncryptor
17
17
import SearchConfigToInfo
18
18
import Seq
19
+ import SortedSets
19
20
import ET = AwsCryptographyDbEncryptionSdkDynamoDbTypes
20
21
import SET = AwsCryptographyDbEncryptionSdkStructuredEncryptionTypes
21
22
import DDB = ComAmazonawsDynamodbTypes
@@ -119,6 +120,9 @@ module
119
120
// # [DynamoDb Item Encryptor](./ddb-table-encryption-config.md)
120
121
// # per configured table, using these table encryption configs.
121
122
var m' := config. tableEncryptionConfigs;
123
+ var mKeys := m'. Keys;
124
+ var tableNamesSeq := SortedSets. ComputeSetToSequence (mKeys);
125
+ ghost var mKeysSet := mKeys;
122
126
123
127
ghost var inputConfigsModifies: set < object > := set
124
128
tableConfig < - config. tableEncryptionConfigs. Values,
@@ -130,8 +134,9 @@ module
130
134
:: o;
131
135
132
136
var allLogicalTableNames := {};
133
-
134
- while m'. Keys != {}
137
+ var i := 0;
138
+
139
+ while i < |tableNamesSeq|
135
140
invariant m'. Keys <= config. tableEncryptionConfigs. Keys
136
141
invariant forall k < - m' :: m'[k] == config. tableEncryptionConfigs[k]
137
142
invariant forall internalConfig < - internalConfigs. Values :: internalConfig. logicalTableName in allLogicalTableNames
@@ -140,10 +145,10 @@ module
140
145
invariant AllTableConfigsValid?(internalConfigs)
141
146
invariant ValidConfig?(Config (internalConfigs))
142
147
143
- decreases m'. Keys
144
148
modifies inputConfigsModifies
145
149
{
146
- var tableName: string :| tableName in m';
150
+ var tableName: string := tableNamesSeq[i];
151
+
147
152
var inputConfig := config. tableEncryptionConfigs[tableName];
148
153
:- Need (inputConfig.logicalTableName !in allLogicalTableNames, E("Duplicate logical table maped to multipule physical tables: " + inputConfig.logicalTableName));
149
154
@@ -223,8 +228,7 @@ module
223
228
assert ConfigsMatch (tableName, internalConfig, inputConfig);
224
229
}
225
230
226
- // Pop 'tableName' off the map, so that we may continue iterating
227
- m' := map k' | k' in m' && k' != tableName :: m'[k'];
231
+ i := i + 1;
228
232
}
229
233
assert SearchValidState (DdbMiddlewareConfig.Config(tableEncryptionConfigs := internalConfigs));
230
234
0 commit comments