@@ -964,17 +964,16 @@ module MessageBody {
964
964
:(res: ReadCorrect< FramedMessage> )
965
965
requires forall frame: Frames. Frame | frame in regularFrames :: frame. header == header
966
966
requires buffer. bytes == continuation. bytes
967
- requires buffer. start <= continuation. start
967
+ requires buffer. start <= continuation. start
968
968
requires 0 <= continuation. start <= |buffer. bytes|
969
969
requires CorrectlyReadRange (buffer, continuation, buffer.bytes[buffer.start..continuation.start])
970
970
requires CorrectlyRead (buffer, Success(SuccessfulRead(regularFrames, continuation)), WriteMessageRegularFrames)
971
971
decreases ENDFRAME_SEQUENCE_NUMBER as nat - |regularFrames|
972
972
ensures CorrectlyRead (buffer, res, WriteFramedMessageBody)
973
973
ensures res. Success?
974
- ==>
975
- && res. value. data. finalFrame. header == header
974
+ ==>
975
+ && res. value. data. finalFrame. header == header
976
976
{
977
- reveal CorrectlyReadRange ();
978
977
var sequenceNumber :- ReadUInt32 (continuation);
979
978
980
979
// = compliance/client-apis/decrypt.txt#2.7.4
@@ -984,19 +983,14 @@ module MessageBody {
984
983
// # (../data-format/message-body.md#final-frame) or regular frame
985
984
// # (../fata-format/message-body/md#regular-frame).
986
985
if (sequenceNumber. data != ENDFRAME_SEQUENCE_NUMBER) then
987
-
988
- assert {:split_here} true ;
989
986
990
987
// = compliance/client-apis/decrypt.txt#2.7.4
991
988
// # Otherwise, this MUST
992
989
// # be deserialized as the sequence number (../data-format/message-
993
990
// # header.md#sequence-number) and the following bytes according to the
994
991
// # regular frame spec (../data-format/message-body.md#regular-frame).
995
992
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
+
1000
994
// = compliance/client-apis/decrypt.txt#2.7.4
1001
995
// # If this is framed data and the first
1002
996
// # frame sequentially, this value MUST be 1.
@@ -1008,19 +1002,15 @@ module MessageBody {
1008
1002
// # of the previous frame.
1009
1003
:- Need (regularFrame.data.seqNum as nat == |regularFrames| + 1, Error("Sequence number out of order."));
1010
1004
1011
- assert {:split_here} true ;
1012
1005
LemmaAddingNextRegularFrame (regularFrames, regularFrame.data);
1013
1006
1014
1007
var nextRegularFrames: MessageRegularFrames := regularFrames + [regularFrame. data];
1015
1008
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 {
1019
1012
reveal CorrectlyReadRange ();
1020
1013
}
1021
-
1022
- assert {:split_here} true ;
1023
-
1024
1014
// This method recursively reads all the frames in the buffer,
1025
1015
// instead of reading one frame a time, so this requirement cannot be met
1026
1016
// = compliance/client-apis/decrypt.txt#2.7.4
@@ -1031,17 +1021,20 @@ module MessageBody {
1031
1021
// # (../framework/algorithm-suites.md#encryption-algorithm) specified by
1032
1022
// # the algorithm suite (../framework/algorithm-suites.md), with the
1033
1023
// # 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
+ }
1045
1038
}
1046
1039
1047
1040
ReadFramedMessageBody (
@@ -1058,26 +1051,34 @@ module MessageBody {
1058
1051
// # number-end) and the following bytes according to the final frame spec
1059
1052
// # (../data-format/message-body.md#final-frame).
1060
1053
assert sequenceNumber. data == ENDFRAME_SEQUENCE_NUMBER;
1061
-
1062
- assert {:split_here} true ;
1054
+
1063
1055
var finalFrame :- Frames. ReadFinalFrame (continuation, header);
1064
1056
:- 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
+ );
1068
1060
1069
- assert {:split_here} true ;
1070
1061
assert MessageFramesAreMonotonic (regularFrames + [finalFrame.data]);
1071
1062
assert MessageFramesAreForTheSameMessage (regularFrames + [finalFrame.data]);
1072
1063
1073
1064
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
+ }
1077
1081
1078
- assert {:split_here} true ;
1079
- assert CorrectlyRead (continuation, Success(finalFrame), Frames. WriteFinalFrame);
1080
- assert {:split_here} true ;
1081
1082
Success (SuccessfulRead(body, finalFrame.tail))
1082
1083
}
1083
1084
0 commit comments