@@ -89,6 +89,7 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
89
89
{
90
90
&& x. origKey == y. key
91
91
&& x. data == y. data
92
+ && x. action == y. action
92
93
}
93
94
94
95
function method UnCanon (input : CanonCryptoList ) : (ret : CryptoList)
@@ -810,21 +811,61 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
810
811
// this assert can be an implication, because it is explicitly ensuring an intermediate state.
811
812
assert forall i | 0 <= i < |encryptedItems| :: encryptedItems[i]. key == canonData[i]. key;
812
813
814
+ assert forall x | 0 <= x < |encryptedItems| :: (encryptedItems[x]. action == ENCRYPT_AND_SIGN ==> encryptedItems[x]. data. typeId == BYTES_TYPE_ID);
815
+ assert forall x | 0 <= x < |encryptedItems| :: (encryptedItems[x]. action == ENCRYPT_AND_SIGN || encryptedItems[x]. data == canonData[x]. data);
816
+
817
+ assume {:axiom} forall k < - input. plaintextStructure ::
818
+ (exists x ::
819
+ && x in encryptedItems
820
+ && x. origKey == k. key
821
+ && (
822
+ || k. action == ENCRYPT_AND_SIGN
823
+ || x. data == k. data
824
+ ));
825
+
813
826
var footer :- Footer. CreateFooter (config.primitives, mat, encryptedItems, headerSerialized);
814
827
var footerAttribute := footer. makeTerminal ();
815
828
816
829
assert forall k < - input. plaintextStructure :: (exists x :: x in encryptedItems && x. origKey == k. key);
817
830
var smallResult : CryptoList := UnCanon (encryptedItems);
818
831
assert forall k < - input. plaintextStructure :: (exists x :: x in smallResult && x. key == k. key);
832
+ assert forall x | 0 <= x < |smallResult| :: (smallResult[x]. action == ENCRYPT_AND_SIGN ==> smallResult[x]. data. typeId == BYTES_TYPE_ID) by {
833
+ assert |smallResult| == |encryptedItems|;
834
+ assert forall x | 0 <= x < |smallResult| :: SameUnCanon (encryptedItems[x], smallResult[x]);
835
+ assert forall x | 0 <= x < |smallResult| :: (smallResult[x]. action == encryptedItems[x]. action && smallResult[x]. data == encryptedItems[x]. data);
836
+ assert forall x | 0 <= x < |encryptedItems| :: (encryptedItems[x]. action == ENCRYPT_AND_SIGN || encryptedItems[x]. data == canonData[x]. data);
837
+ }
819
838
820
839
var headItem := CryptoItem (key := HeaderPath, data := headerAttribute, action := DO_NOTHING);
821
840
var footItem := CryptoItem (key := FooterPath, data := footerAttribute, action := DO_NOTHING);
822
841
var largeResult := smallResult + [headItem, footItem];
842
+ assert |largeResult| == |smallResult| + 2;
823
843
assert largeResult[|largeResult|- 2] == headItem;
824
844
assert largeResult[|largeResult|- 2]. key == HeaderPath;
825
845
assert largeResult[|largeResult|- 1] == footItem;
826
846
assert largeResult[|largeResult|- 1]. key == FooterPath;
827
847
assert forall k < - input. plaintextStructure :: (exists x :: x in largeResult && x. key == k. key);
848
+ assert forall x | 0 <= x < |largeResult| :: (largeResult[x]. action == ENCRYPT_AND_SIGN ==> largeResult[x]. data. typeId == BYTES_TYPE_ID) by {
849
+ assert forall x | 0 <= x < |smallResult| :: (smallResult[x]. action == ENCRYPT_AND_SIGN ==> smallResult[x]. data. typeId == BYTES_TYPE_ID);
850
+ assert forall x | 0 <= x < |smallResult| :: smallResult[x] == largeResult[x];
851
+ assert forall x | 0 <= x < |smallResult| :: (largeResult[x]. action == ENCRYPT_AND_SIGN ==> largeResult[x]. data. typeId == BYTES_TYPE_ID);
852
+ assert largeResult[|smallResult|] == headItem;
853
+ assert largeResult[|smallResult|]. key == HeaderPath;
854
+ assert largeResult[|smallResult|+ 1] == footItem;
855
+ assert largeResult[|smallResult|+ 1]. key == FooterPath;
856
+ assert largeResult[|smallResult|]. action == DO_NOTHING;
857
+ assert largeResult[|smallResult|+ 1]. action == DO_NOTHING;
858
+ assert forall x | |smallResult| <= x < |largeResult| :: largeResult[x]. action == DO_NOTHING;
859
+ }
860
+
861
+ assert forall k < - input. plaintextStructure ::
862
+ (exists x ::
863
+ && x in largeResult
864
+ && x. key == k. key
865
+ && (
866
+ || k. action == ENCRYPT_AND_SIGN
867
+ || x. data == k. data
868
+ ));
828
869
829
870
var headerAlgorithmSuite :- head. GetAlgorithmSuite (config.materialProviders);
830
871
var parsedHeader := ParsedHeader (
@@ -838,6 +879,7 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
838
879
encryptedStructure := largeResult,
839
880
parsedHeader := parsedHeader
840
881
);
882
+ assert encryptOutput. encryptedStructure[|encryptOutput. encryptedStructure|- 1]. key == FooterPath;
841
883
842
884
return Success (encryptOutput);
843
885
}
0 commit comments