@@ -21,6 +21,7 @@ module {:options "-functionSyntax:4"} EncryptManifest {
21
21
import opened JSONHelpers
22
22
import JsonConfig
23
23
import ENC = AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorTypes
24
+ import KeyVectors
24
25
25
26
function Manifest () : (string , JSON)
26
27
{
@@ -42,10 +43,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
42
43
("client", Object (result))
43
44
}
44
45
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 ()
46
51
{
47
52
var rec :- JsonConfig. GetRecord (record);
48
- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
53
+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
49
54
var encrypted :- expect encryptor. EncryptItem (
50
55
ENC.EncryptItemInput(
51
56
plaintextItem:=rec.item
@@ -64,10 +69,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
64
69
return Success ((name, Object(result)));
65
70
}
66
71
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 ()
68
77
{
69
78
var rec :- JsonConfig. GetRecord (record);
70
- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
79
+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
71
80
var encrypted := encryptor. EncryptItem (
72
81
ENC.EncryptItemInput(
73
82
plaintextItem:=rec.item
@@ -80,7 +89,11 @@ module {:options "-functionSyntax:4"} EncryptManifest {
80
89
}
81
90
82
91
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 ()
84
97
{
85
98
:- Need (value.Object?, "Test must be an object");
86
99
@@ -117,20 +130,24 @@ module {:options "-functionSyntax:4"} EncryptManifest {
117
130
:- Need (record.Some?, "Test requires a 'record' member.");
118
131
119
132
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 );
121
134
return Success (Some(x));
122
135
} 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 );
124
137
return Success (Some(x));
125
138
} else if types. value == "negative- encrypt" {
126
- var _ := OneNegativeTest (name, config.value, record.value);
139
+ var _ := OneNegativeTest (name, config.value, record.value, keys );
127
140
return Success (None);
128
141
} else {
129
142
return Failure ("Invalid encrypt type : '" + types.value + "'.");
130
143
}
131
144
}
132
145
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 ()
134
151
{
135
152
var timeStamp :- expect Time. GetCurrentTimeStamp ();
136
153
print timeStamp + " Encrypt : ", inFile, "\n";
@@ -187,7 +204,7 @@ module {:options "-functionSyntax:4"} EncryptManifest {
187
204
for i := 0 to |tests. value| {
188
205
var obj := tests. value[i];
189
206
:- 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 );
191
208
if newTest. Some? {
192
209
test := test + [newTest. value];
193
210
}
0 commit comments