@@ -21,6 +21,7 @@ module {:options "-functionSyntax:4"} EncryptManifest {
2121 import opened JSONHelpers
2222 import JsonConfig
2323 import ENC = AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorTypes
24+ import KeyVectors
2425
2526 function Manifest () : (string , JSON)
2627 {
@@ -42,10 +43,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
4243 ("client", Object (result))
4344 }
4445
45- method OnePositiveTest (name : string , theType : string , desc : string , config : JSON , decryptConfig : Option <JSON >, record : JSON ) returns (output : Result< (string , JSON), string > )
46+ method OnePositiveTest (name : string , theType : string , desc : string , config : JSON , decryptConfig : Option <JSON >, record : JSON , keys: KeyVectors .KeyVectorsClient)
47+ returns (output : Result< (string , JSON), string > )
48+ requires keys. ValidState ()
49+ modifies keys. Modifies
50+ ensures keys. ValidState ()
4651 {
4752 var rec :- JsonConfig. GetRecord (record);
48- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
53+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
4954 var encrypted :- expect encryptor. EncryptItem (
5055 ENC.EncryptItemInput(
5156 plaintextItem:=rec.item
@@ -64,10 +69,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
6469 return Success ((name, Object(result)));
6570 }
6671
67- method OneNegativeTest (name : string , config : JSON , record : JSON ) returns (output : Result< bool , string > )
72+ method OneNegativeTest (name : string , config : JSON , record : JSON , keys: KeyVectors .KeyVectorsClient)
73+ returns (output : Result< bool , string > )
74+ requires keys. ValidState ()
75+ modifies keys. Modifies
76+ ensures keys. ValidState ()
6877 {
6978 var rec :- JsonConfig. GetRecord (record);
70- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
79+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
7180 var encrypted := encryptor. EncryptItem (
7281 ENC.EncryptItemInput(
7382 plaintextItem:=rec.item
@@ -80,7 +89,11 @@ module {:options "-functionSyntax:4"} EncryptManifest {
8089 }
8190
8291
83- method OneTest (name : string , value : JSON ) returns (output : Result< Option< (string , JSON)> , string > )
92+ method OneTest (name : string , value : JSON , keys: KeyVectors .KeyVectorsClient)
93+ returns (output : Result< Option< (string , JSON)> , string > )
94+ requires keys. ValidState ()
95+ modifies keys. Modifies
96+ ensures keys. ValidState ()
8497 {
8598 :- Need (value.Object?, "Test must be an object");
8699
@@ -117,20 +130,24 @@ module {:options "-functionSyntax:4"} EncryptManifest {
117130 :- Need (record.Some?, "Test requires a 'record' member.");
118131
119132 if types. value == "positive- encrypt" {
120- var x :- OnePositiveTest (name, "positive-decrypt", description.value, config.value, decryptConfig, record.value);
133+ var x :- OnePositiveTest (name, "positive-decrypt", description.value, config.value, decryptConfig, record.value, keys );
121134 return Success (Some(x));
122135 } else if types. value == "negative- decrypt" {
123- var x :- OnePositiveTest (name, "negative-decrypt", description.value, config.value, decryptConfig, record.value);
136+ var x :- OnePositiveTest (name, "negative-decrypt", description.value, config.value, decryptConfig, record.value, keys );
124137 return Success (Some(x));
125138 } else if types. value == "negative- encrypt" {
126- var _ := OneNegativeTest (name, config.value, record.value);
139+ var _ := OneNegativeTest (name, config.value, record.value, keys );
127140 return Success (None);
128141 } else {
129142 return Failure ("Invalid encrypt type : '" + types.value + "'.");
130143 }
131144 }
132145
133- method Encrypt (inFile : string , outFile : string , lang : string , version : string ) returns (output : Result< bool , string > )
146+ method Encrypt (inFile : string , outFile : string , lang : string , version : string , keyVectors: KeyVectors .KeyVectorsClient)
147+ returns (output : Result< bool , string > )
148+ requires keyVectors. ValidState ()
149+ modifies keyVectors. Modifies
150+ ensures keyVectors. ValidState ()
134151 {
135152 var timeStamp :- expect Time. GetCurrentTimeStamp ();
136153 print timeStamp + " Encrypt : ", inFile, "\n";
@@ -187,7 +204,7 @@ module {:options "-functionSyntax:4"} EncryptManifest {
187204 for i := 0 to |tests. value| {
188205 var obj := tests. value[i];
189206 :- Need (obj.1.Object?, "Value of test '" + obj.0 + "' must be an Object.");
190- var newTest :- OneTest (obj.0, obj.1);
207+ var newTest :- OneTest (obj.0, obj.1, keyVectors );
191208 if newTest. Some? {
192209 test := test + [newTest. value];
193210 }
0 commit comments