Skip to content

Commit c977566

Browse files
committed
Merge branch 'main' into ajewell/bump-mpl2
2 parents 6d120f6 + ec22b7d commit c977566

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/src/DynamoToStruct.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ module DynamoToStruct {
596596
ensures ret.Success? ==> |ret.value| == LENGTH_LEN
597597
ensures ret == U32ToBigEndian(x as nat)
598598
{
599-
if x > 0xffff_ffff then
599+
if !HasUint32Size(x) then
600600
Failure("Length was too big")
601601
else
602602
Success(UInt32ToSeq(x as uint32))

DynamoDbEncryption/dafny/DynamoDbEncryption/src/TermLoc.dfy

+4-31
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,12 @@ module TermLoc {
3232
import Seq
3333
import DynamoToStruct
3434

35-
// function method {:tailrecursion} CountEven(x : seq<uint8>, pos : nat) : nat
36-
// requires pos <= |x|
37-
// decreases |x| - pos
38-
// {
39-
// if pos == |x| then
40-
// 0
41-
// else if x[0] % 2 == 0 then
42-
// 1 + CountEven(x, pos+1)
43-
// else
44-
// CountEven(x, pos+1)
45-
// }
46-
47-
function method {:tailrecursion} CountEven(x : seq<uint8>, pos : uint64 := 0) : (ret : uint64)
48-
requires pos as nat <= |x|
49-
ensures ret as nat <= |x| - pos as nat
50-
decreases |x| - pos as nat
51-
{
52-
SequenceIsSafeBecauseItIsInMemory(x);
53-
if pos == |x| as uint64 then
54-
0
55-
else if x[0] % 2 == 0 then
56-
1 + CountEven(x, pos+1)
57-
else
58-
CountEven(x, pos+1)
59-
}
60-
6135
datatype Selector =
6236
| List(pos : uint64)
6337
| Map(key : string)
6438

6539
type Bytes = seq<uint8>
66-
type SelectorList = x : seq<Selector> | HasUint64Len(x)
67-
40+
type SelectorList = seq<Selector>
6841
//= specification/searchable-encryption/virtual.md#terminal-location
6942
//= type=implication
7043
//# A Terminal Location specification MUST be a list of one more [Segments](#segments),
@@ -73,7 +46,6 @@ module TermLoc {
7346
predicate method ValidTermLoc(s : seq<Selector>)
7447
{
7548
&& 0 < |s|
76-
&& HasUint64Len(s)
7749
&& s[0].Map?
7850
}
7951

@@ -265,8 +237,9 @@ module TermLoc {
265237
if s[|s|-1] != ']' then
266238
Failure(E("List index must end with ]"))
267239
else
268-
var num : uint64 :- GetNumber(s[1..|s|-1]);
269-
Success(List(num))
240+
var num :- GetNumber(s[1..|s|-1]);
241+
:- Need(num < UINT64_LIMIT, E("Array selector exceeds maximum."));
242+
Success(List(num as uint64))
270243
}
271244

272245
// convert string to SelectorList

DynamoDbEncryption/dafny/StructuredEncryption/src/AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations.dfy

+2-2
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,8 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
824824
cmm,
825825
Some(encryptionContext),
826826
input.algorithmSuiteId,
827-
CountEncrypted(canonData),
828-
SumValueSize(canonData));
827+
CountEncrypted(canonData) as nat,
828+
SumValueSize(canonData) as nat);
829829

830830
var key : Key := mat.plaintextDataKey.value;
831831
var alg := mat.algorithmSuite;

DynamoDbEncryption/dafny/StructuredEncryption/src/Header.dfy

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module StructuredEncryptionHeader {
1414
import opened AwsCryptographyDbEncryptionSdkStructuredEncryptionTypes
1515
import opened StructuredEncryptionUtil
1616
import opened StandardLibrary.MemoryMath
17-
1817
import CMP = AwsCryptographyMaterialProvidersTypes
1918
import Prim = AwsCryptographyPrimitivesTypes
2019
import SortedSets
@@ -617,6 +616,7 @@ module StructuredEncryptionHeader {
617616
Success(deserialized)
618617
else
619618
:- Need(|deserialized.0| as uint64 + 1 < UINT16_LIMIT as uint64, E("Too much context"));
619+
620620
var kv :- GetOneKVPair(data, deserialized.1 as uint64);
621621
//= specification/structured-encryption/header.md#key-value-pair-entries
622622
//# This sequence MUST NOT contain duplicate entries.

0 commit comments

Comments
 (0)