@@ -154,7 +154,7 @@ module DynamoToStruct {
154
154
Success (SeqPosToUInt32(x, pos))
155
155
}
156
156
157
- // This is safe because are dealing with DynamoDB items, and so no numbers wil exceed 400K
157
+ // This is safe because are dealing with DynamoDB items, and so no numbers will exceed 400K
158
158
function method {:opaque} Add32 (x : uint32 , y : uint32 ) : (ret : uint32)
159
159
ensures x as uint64 + y as uint64 <= UINT32_MAX as uint64
160
160
ensures ret == x + y
@@ -999,7 +999,7 @@ module DynamoToStruct {
999
999
else
1000
1000
assert serialized_size == |serialized| as uint32;
1001
1001
var nval :- BytesToAttr (serialized, TerminalTypeId, Some(len), depth+ 1, new_pos);
1002
- var new_pos := new_pos + nval. len;
1002
+ var new_pos := Add32 ( new_pos, nval.len) ;
1003
1003
var nattr := AttributeValue. L (resultList.val.L + [nval.val]);
1004
1004
var nResultList := AttrValueAndLength (nattr, Add32(resultList.len, new_pos-pos));
1005
1005
Success ((nResultList, new_pos))
@@ -1121,7 +1121,7 @@ module DynamoToStruct {
1121
1121
1122
1122
// get value and construct result
1123
1123
var nval :- BytesToAttr (serialized, TerminalTypeId_value, None, depth+1, pos);
1124
- var pos := pos + nval. len;
1124
+ var pos := Add32 ( pos, nval.len) ;
1125
1125
1126
1126
// = specification/dynamodb-encryption-client/ddb-attribute-serialization.md#key-value-pair-entries
1127
1127
// # This sequence MUST NOT contain duplicate [Map Keys](#map-key).
@@ -1278,23 +1278,32 @@ module DynamoToStruct {
1278
1278
else
1279
1279
var len : uint32 :- BigEndianPosToU32 (value, pos);
1280
1280
var pos : uint32 := pos + LENGTH_LEN32;
1281
- DeserializeStringSet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.SS([]), LENGTH_LEN32+ lengthBytes))
1281
+ var retval :- DeserializeStringSet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.SS([]), LENGTH_LEN32+ lengthBytes));
1282
+ // this is not needed with Dafny 4.10
1283
+ assume {:axiom} Add32 (pos, retval.len) <= |value| as uint32;
1284
+ Success (retval)
1282
1285
1283
1286
else if typeId == SE. NUMBER_SET then
1284
1287
if value_size - pos < LENGTH_LEN32 then
1285
1288
Failure ("Number Set Structured Data has less than 4 bytes")
1286
1289
else
1287
1290
var len : uint32 :- BigEndianPosToU32 (value, pos);
1288
1291
var pos : uint32 := pos + LENGTH_LEN32;
1289
- DeserializeNumberSet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.NS([]), LENGTH_LEN32 + lengthBytes))
1292
+ var retval :- DeserializeNumberSet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.NS([]), LENGTH_LEN32 + lengthBytes));
1293
+ // this is not needed with Dafny 4.10
1294
+ assume {:axiom} Add32 (pos, retval.len) <= |value| as uint32;
1295
+ Success (retval)
1290
1296
1291
1297
else if typeId == SE. BINARY_SET then
1292
1298
if value_size - pos < LENGTH_LEN32 then
1293
1299
Failure ("Binary Set Structured Data has less than LENGTH_LEN bytes")
1294
1300
else
1295
1301
var len : uint32 :- BigEndianPosToU32 (value, pos);
1296
1302
var pos : uint32 := pos + LENGTH_LEN32;
1297
- DeserializeBinarySet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.BS([]), LENGTH_LEN32 + lengthBytes))
1303
+ var retval :- DeserializeBinarySet (value[pos..], len, Add32_3(value_size - pos, LENGTH_LEN32, lengthBytes), AttrValueAndLength (AttributeValue.BS([]), LENGTH_LEN32 + lengthBytes));
1304
+ // this is not needed with Dafny 4.10
1305
+ assume {:axiom} Add32 (pos, retval.len) <= |value| as uint32;
1306
+ Success (retval)
1298
1307
1299
1308
else if typeId == SE. MAP then
1300
1309
if value_size < Add32 (LENGTH_LEN32, pos) then
@@ -1303,7 +1312,10 @@ module DynamoToStruct {
1303
1312
var len : uint32 :- BigEndianPosToU32 (value, pos);
1304
1313
var pos : uint32 := pos + LENGTH_LEN32;
1305
1314
var resultMap := AttrValueAndLength (AttributeValue.M(map[]), LENGTH_LEN32 + lengthBytes);
1306
- DeserializeMap (value, pos, pos - resultMap.len, len, depth, resultMap)
1315
+ var retval :- DeserializeMap (value, pos, pos - resultMap.len, len, depth, resultMap);
1316
+ // this is not needed with Dafny 4.10
1317
+ assume {:axiom} Add32 (pos, retval.len) <= |value| as uint32;
1318
+ Success (retval)
1307
1319
1308
1320
else if typeId == SE. LIST then
1309
1321
if value_size < Add32 (LENGTH_LEN32, pos) then
@@ -1315,7 +1327,10 @@ module DynamoToStruct {
1315
1327
assert value_size == |value| as uint32;
1316
1328
assert pos <= |value| as uint32;
1317
1329
var resultList := AttrValueAndLength (AttributeValue.L([]), LENGTH_LEN32 + lengthBytes);
1318
- DeserializeList (value, pos, pos - resultList.len, len, depth, resultList)
1330
+ var retval :- DeserializeList (value, pos, pos - resultList.len, len, depth, resultList);
1331
+ // this is not needed with Dafny 4.10
1332
+ assume {:axiom} Add32 (pos, retval.len) <= |value| as uint32;
1333
+ Success (retval)
1319
1334
else
1320
1335
Failure ("Unsupported TerminalTypeId")
1321
1336
0 commit comments