Skip to content

Commit bc46d0f

Browse files
authored
chore(dafny-verification): fix timeout for Dafny 4.8.1 (#690)
1 parent 864c2e2 commit bc46d0f

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

AwsEncryptionSDK/dafny/AwsEncryptionSdk/src/MessageBody.dfy

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -964,17 +964,16 @@ module MessageBody {
964964
:(res: ReadCorrect<FramedMessage>)
965965
requires forall frame: Frames.Frame | frame in regularFrames :: frame.header == header
966966
requires buffer.bytes == continuation.bytes
967-
requires buffer.start <= continuation.start
967+
requires buffer.start <= continuation.start
968968
requires 0 <= continuation.start <= |buffer.bytes|
969969
requires CorrectlyReadRange(buffer, continuation, buffer.bytes[buffer.start..continuation.start])
970970
requires CorrectlyRead(buffer, Success(SuccessfulRead(regularFrames, continuation)), WriteMessageRegularFrames)
971971
decreases ENDFRAME_SEQUENCE_NUMBER as nat - |regularFrames|
972972
ensures CorrectlyRead(buffer, res, WriteFramedMessageBody)
973973
ensures res.Success?
974-
==>
975-
&& res.value.data.finalFrame.header == header
974+
==>
975+
&& res.value.data.finalFrame.header == header
976976
{
977-
reveal CorrectlyReadRange();
978977
var sequenceNumber :- ReadUInt32(continuation);
979978

980979
//= compliance/client-apis/decrypt.txt#2.7.4
@@ -984,19 +983,14 @@ module MessageBody {
984983
//# (../data-format/message-body.md#final-frame) or regular frame
985984
//# (../fata-format/message-body/md#regular-frame).
986985
if (sequenceNumber.data != ENDFRAME_SEQUENCE_NUMBER) then
987-
988-
assert {:split_here} true;
989986

990987
//= compliance/client-apis/decrypt.txt#2.7.4
991988
//# Otherwise, this MUST
992989
//# be deserialized as the sequence number (../data-format/message-
993990
//# header.md#sequence-number) and the following bytes according to the
994991
//# regular frame spec (../data-format/message-body.md#regular-frame).
995992
var regularFrame :- Frames.ReadRegularFrame(continuation, header);
996-
assert buffer.bytes == continuation.bytes;
997-
assert buffer.bytes == regularFrame.tail.bytes by {
998-
reveal CorrectlyReadRange();
999-
}
993+
1000994
//= compliance/client-apis/decrypt.txt#2.7.4
1001995
//# If this is framed data and the first
1002996
//# frame sequentially, this value MUST be 1.
@@ -1008,19 +1002,15 @@ module MessageBody {
10081002
//# of the previous frame.
10091003
:- Need(regularFrame.data.seqNum as nat == |regularFrames| + 1, Error("Sequence number out of order."));
10101004

1011-
assert {:split_here} true;
10121005
LemmaAddingNextRegularFrame(regularFrames, regularFrame.data);
10131006

10141007
var nextRegularFrames: MessageRegularFrames := regularFrames + [regularFrame.data];
10151008

1016-
assert {:split_here} true;
1017-
assert CorrectlyRead(continuation, Success(regularFrame), Frames.WriteRegularFrame);
1018-
assert continuation.bytes == regularFrame.tail.bytes by {
1009+
CorrectlyReadByteRange(buffer, continuation, WriteMessageRegularFrames(regularFrames));
1010+
AppendToCorrectlyReadByteRange(buffer, continuation, regularFrame.tail, Frames.WriteRegularFrame(regularFrame.data));
1011+
assert buffer.bytes == continuation.bytes == regularFrame.tail.bytes by {
10191012
reveal CorrectlyReadRange();
10201013
}
1021-
1022-
assert {:split_here} true;
1023-
10241014
// This method recursively reads all the frames in the buffer,
10251015
// instead of reading one frame a time, so this requirement cannot be met
10261016
//= compliance/client-apis/decrypt.txt#2.7.4
@@ -1031,17 +1021,20 @@ module MessageBody {
10311021
//# (../framework/algorithm-suites.md#encryption-algorithm) specified by
10321022
//# the algorithm suite (../framework/algorithm-suites.md), with the
10331023
//# following inputs:
1034-
var res := Success(SuccessfulRead(nextRegularFrames, regularFrame.tail));
1035-
assert CorrectlyRead(buffer, res, WriteMessageRegularFrames) by {
1036-
reveal CorrectlyReadRange();
1037-
1038-
var tail := res.value.tail;
1039-
var readRange := WriteMessageRegularFrames(res.value.data);
1040-
assert buffer.bytes == tail.bytes;
1041-
assert buffer.start <= tail.start <= |buffer.bytes|;
1042-
assert buffer.bytes[buffer.start..] == tail.bytes[buffer.start..];
1043-
assert readRange <= buffer.bytes[buffer.start..];
1044-
assert tail.start == buffer.start + |readRange|;
1024+
assert CorrectlyRead(
1025+
buffer,
1026+
Success(SuccessfulRead(nextRegularFrames, regularFrame.tail)),
1027+
WriteMessageRegularFrames
1028+
) by {
1029+
calc {
1030+
buffer.bytes[buffer.start..continuation.start] + Frames.WriteRegularFrame(regularFrame.data);
1031+
== {CorrectlyReadByteRange(buffer, continuation, WriteMessageRegularFrames(regularFrames));}
1032+
WriteMessageRegularFrames(regularFrames) + Frames.WriteRegularFrame(regularFrame.data);
1033+
== // By definition of WriteMessageRegularFrames
1034+
WriteMessageRegularFrames(regularFrames + [regularFrame.data]);
1035+
== {assert nextRegularFrames == regularFrames + [regularFrame.data];}
1036+
WriteMessageRegularFrames(nextRegularFrames);
1037+
}
10451038
}
10461039

10471040
ReadFramedMessageBody(
@@ -1058,26 +1051,34 @@ module MessageBody {
10581051
//# number-end) and the following bytes according to the final frame spec
10591052
//# (../data-format/message-body.md#final-frame).
10601053
assert sequenceNumber.data == ENDFRAME_SEQUENCE_NUMBER;
1061-
1062-
assert {:split_here} true;
1054+
10631055
var finalFrame :- Frames.ReadFinalFrame(continuation, header);
10641056
:- Need(
1065-
finalFrame.data.seqNum as nat == |regularFrames| + 1,
1066-
Error("Sequence number out of order.")
1067-
);
1057+
finalFrame.data.seqNum as nat == |regularFrames| + 1,
1058+
Error("Sequence number out of order.")
1059+
);
10681060

1069-
assert {:split_here} true;
10701061
assert MessageFramesAreMonotonic(regularFrames + [finalFrame.data]);
10711062
assert MessageFramesAreForTheSameMessage(regularFrames + [finalFrame.data]);
10721063

10731064
var body: FramedMessage := FramedMessageBody(
1074-
regularFrames := regularFrames,
1075-
finalFrame := finalFrame.data
1076-
);
1065+
regularFrames := regularFrames,
1066+
finalFrame := finalFrame.data
1067+
);
1068+
1069+
assert CorrectlyRead(buffer, Success(SuccessfulRead(body, finalFrame.tail)), WriteFramedMessageBody) by {
1070+
AppendToCorrectlyReadByteRange(buffer, continuation, finalFrame.tail, Frames.WriteFinalFrame(finalFrame.data));
1071+
calc {
1072+
buffer.bytes[buffer.start..finalFrame.tail.start];
1073+
==
1074+
buffer.bytes[buffer.start..continuation.start] + Frames.WriteFinalFrame(finalFrame.data);
1075+
== {CorrectlyReadByteRange(buffer, continuation, WriteMessageRegularFrames(regularFrames));}
1076+
WriteMessageRegularFrames(regularFrames) + Frames.WriteFinalFrame(finalFrame.data);
1077+
== // By definition of WriteMessageRegularFrames
1078+
WriteFramedMessageBody(body);
1079+
}
1080+
}
10771081

1078-
assert {:split_here} true;
1079-
assert CorrectlyRead(continuation, Success(finalFrame), Frames.WriteFinalFrame);
1080-
assert {:split_here} true;
10811082
Success(SuccessfulRead(body, finalFrame.tail))
10821083
}
10831084

0 commit comments

Comments
 (0)