Skip to content

Commit fbad38c

Browse files
committed
PR feedback
1 parent f69edbc commit fbad38c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

TestVectors/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ This validates the Database Encryption SDK's cross-version compatibility.
1818
1. Start in the root `./TestVectors` directory
1919
2. Run `make build_java`
2020
3. Run `make test_java`
21+
4. Run `make transpile_net`
22+
5. Run `cd runtimes/net`
23+
6. Run `dotnet run --framework net6.0`
24+
25+
### Saving results for later
26+
27+
Running the above commands will create `runtimes/java/decrypt.json` and `runtimes/net/decrypt.json`.
28+
29+
These files should be permanently saved before a release.
30+
31+
For example, if we're on version 3.4 and are getting close to a new release, we would
32+
33+
`cp runtimes/java/decrypt.json runtimes/java/decrypt_java_34.json`
34+
35+
`cp runtimes/net/decrypt.json runtimes/java/decrypt_dotnet_34.json`
36+
37+
and then modify `RunAllTests` in `dafny/DDBEncryption/src/TestVectors.dfy` to explicitly check these two files.
38+
39+
As other languages are supported, we will also deal with runtimes/XXX/decrypt.json and runtimes/java/decrypt_XXX_34.json
40+
in a simlar manner.
41+
42+
This ensures that records written in any version in any language can be read by the current version in any language.
2143

2244
## Security
2345

TestVectors/dafny/DDBEncryption/src/WriteManifest.dfy

+11
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ module {:options "-functionSyntax:4"} WriteManifest {
248248
[0, 0, 0, 0, 0, 0]
249249
}
250250

251+
// To be consistent :
252+
// 1) The primary key (actions[0]) must be sign_only or sign_and_include
253+
// 2) If anything is sign_and_include, then The primary key must be sign_and_include
251254
predicate IsConsistent(actions : CryptoActions)
252255
{
253256
if actions[0] in [DoNothing, Encrypt] then
@@ -258,6 +261,9 @@ module {:options "-functionSyntax:4"} WriteManifest {
258261
true
259262
}
260263

264+
// For a new config to be consistent with an old config:
265+
// 1) both configs must be individually consistent
266+
// 2) they must agree on which fields are do_nothing
261267
predicate IsConsistentWith(oldActions : CryptoActions, newActions : CryptoActions)
262268
{
263269
if !IsConsistent(oldActions) || !IsConsistent(newActions) then
@@ -267,6 +273,8 @@ module {:options "-functionSyntax:4"} WriteManifest {
267273
}
268274

269275
// make a test for every valid combination of Crypto Actions
276+
// 'actions' holds the crypto actions for each of six attributes
277+
// the loop iterates through all possible combinations of attributes by incrementing this list
270278
method MakeConfigTests() returns (output : seq<(string, JSON)>)
271279
{
272280
var actions : CryptoActions := [0,0,0,0,0,0];
@@ -289,6 +297,9 @@ module {:options "-functionSyntax:4"} WriteManifest {
289297

290298
// for a subset of these,
291299
// make a test to decrypt with every possible valid combination of Crypto Actions
300+
// testing all of them would take too much time and space,
301+
// so we select a sample to produce about 2000 more tests
302+
// every 100th seems as good as any other method to get a representative sample
292303
if (actionWrittenOuter % 100) == 0 {
293304
var otherActions : CryptoActions := [0,0,0,0,0,0];
294305
// 4096 == 4 ^ 6 == size of all possible values of `otherActions`

0 commit comments

Comments
 (0)