@@ -21,6 +21,9 @@ module {:options "-functionSyntax:4"} EncryptManifest {
21
21
import opened JSONHelpers
22
22
import JsonConfig
23
23
import ENC = AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorTypes
24
+ import KeyVectors
25
+
26
+ const DEFAULT_KEYS : string := ".. / .. / .. / submodules/ MaterialProviders/ TestVectorsAwsCryptographicMaterialProviders/ dafny/ TestVectorsAwsCryptographicMaterialProviders/ test/ keys. json"
24
27
25
28
function Manifest () : (string , JSON)
26
29
{
@@ -42,10 +45,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
42
45
("client", Object (result))
43
46
}
44
47
45
- method OnePositiveTest (name : string , theType : string , desc : string , config : JSON , decryptConfig : Option <JSON >, record : JSON ) returns (output : Result< (string , JSON), string > )
48
+ method OnePositiveTest (name : string , theType : string , desc : string , config : JSON , decryptConfig : Option <JSON >, record : JSON , keys: KeyVectors .KeyVectorsClient)
49
+ returns (output : Result< (string , JSON), string > )
50
+ requires keys. ValidState ()
51
+ modifies keys. Modifies
52
+ ensures keys. ValidState ()
46
53
{
47
54
var rec :- JsonConfig. GetRecord (record);
48
- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
55
+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
49
56
var encrypted :- expect encryptor. EncryptItem (
50
57
ENC.EncryptItemInput(
51
58
plaintextItem:=rec.item
@@ -64,10 +71,14 @@ module {:options "-functionSyntax:4"} EncryptManifest {
64
71
return Success ((name, Object(result)));
65
72
}
66
73
67
- method OneNegativeTest (name : string , config : JSON , record : JSON ) returns (output : Result< bool , string > )
74
+ method OneNegativeTest (name : string , config : JSON , record : JSON , keys: KeyVectors .KeyVectorsClient)
75
+ returns (output : Result< bool , string > )
76
+ requires keys. ValidState ()
77
+ modifies keys. Modifies
78
+ ensures keys. ValidState ()
68
79
{
69
80
var rec :- JsonConfig. GetRecord (record);
70
- var encryptor :- JsonConfig. GetItemEncryptor (name, config);
81
+ var encryptor :- JsonConfig. GetItemEncryptor (name, config, keys );
71
82
var encrypted := encryptor. EncryptItem (
72
83
ENC.EncryptItemInput(
73
84
plaintextItem:=rec.item
@@ -80,7 +91,11 @@ module {:options "-functionSyntax:4"} EncryptManifest {
80
91
}
81
92
82
93
83
- method OneTest (name : string , value : JSON ) returns (output : Result< Option< (string , JSON)> , string > )
94
+ method OneTest (name : string , value : JSON , keys: KeyVectors .KeyVectorsClient)
95
+ returns (output : Result< Option< (string , JSON)> , string > )
96
+ requires keys. ValidState ()
97
+ modifies keys. Modifies
98
+ ensures keys. ValidState ()
84
99
{
85
100
:- Need (value.Object?, "Test must be an object");
86
101
@@ -117,20 +132,24 @@ module {:options "-functionSyntax:4"} EncryptManifest {
117
132
:- Need (record.Some?, "Test requires a 'record' member.");
118
133
119
134
if types. value == "positive- encrypt" {
120
- var x :- OnePositiveTest (name, "positive-decrypt", description.value, config.value, decryptConfig, record.value);
135
+ var x :- OnePositiveTest (name, "positive-decrypt", description.value, config.value, decryptConfig, record.value, keys );
121
136
return Success (Some(x));
122
137
} else if types. value == "negative- decrypt" {
123
- var x :- OnePositiveTest (name, "negative-decrypt", description.value, config.value, decryptConfig, record.value);
138
+ var x :- OnePositiveTest (name, "negative-decrypt", description.value, config.value, decryptConfig, record.value, keys );
124
139
return Success (Some(x));
125
140
} else if types. value == "negative- encrypt" {
126
- var _ := OneNegativeTest (name, config.value, record.value);
141
+ var _ := OneNegativeTest (name, config.value, record.value, keys );
127
142
return Success (None);
128
143
} else {
129
144
return Failure ("Invalid encrypt type : '" + types.value + "'.");
130
145
}
131
146
}
132
147
133
- method Encrypt (inFile : string , outFile : string , lang : string , version : string ) returns (output : Result< bool , string > )
148
+ method Encrypt (inFile : string , outFile : string , lang : string , version : string , keyVectors: KeyVectors .KeyVectorsClient)
149
+ returns (output : Result< bool , string > )
150
+ requires keyVectors. ValidState ()
151
+ modifies keyVectors. Modifies
152
+ ensures keyVectors. ValidState ()
134
153
{
135
154
var timeStamp :- expect Time. GetCurrentTimeStamp ();
136
155
print timeStamp + " Encrypt : ", inFile, "\n";
@@ -187,7 +206,7 @@ module {:options "-functionSyntax:4"} EncryptManifest {
187
206
for i := 0 to |tests. value| {
188
207
var obj := tests. value[i];
189
208
:- Need (obj.1.Object?, "Value of test '" + obj.0 + "' must be an Object.");
190
- var newTest :- OneTest (obj.0, obj.1);
209
+ var newTest :- OneTest (obj.0, obj.1, keyVectors );
191
210
if newTest. Some? {
192
211
test := test + [newTest. value];
193
212
}
0 commit comments