Skip to content

Commit c5993ef

Browse files
m
1 parent b2d5c16 commit c5993ef

29 files changed

Lines changed: 832773 additions & 0 deletions

File tree

.github/workflows/test-vectors.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Test Vectors
2+
3+
on:
4+
push:
5+
branches: [main, dbesdk-java]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test-vectors:
11+
strategy:
12+
matrix:
13+
java-version: [8, 11, 17]
14+
os: [ubuntu-22.04]
15+
runs-on: ${{ matrix.os }}
16+
permissions:
17+
id-token: write
18+
contents: read
19+
steps:
20+
- name: Setup DynamoDB Local
21+
uses: rrainn/dynamodb-action@v4.0.0
22+
with:
23+
port: 8000
24+
cors: "*"
25+
26+
- name: Configure AWS Credentials
27+
uses: aws-actions/configure-aws-credentials@v6
28+
with:
29+
aws-region: us-west-2
30+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
31+
role-session-name: DBESDK-Native-Java-TestVectors
32+
special-characters-workaround: "true"
33+
34+
- uses: actions/checkout@v6
35+
with:
36+
submodules: recursive
37+
38+
- name: Setup Java ${{ matrix.java-version }}
39+
uses: actions/setup-java@v5
40+
with:
41+
distribution: "corretto"
42+
java-version: ${{ matrix.java-version }}
43+
44+
- name: Build and publish native SDK locally
45+
run: ./gradlew publishToMavenLocal
46+
47+
- name: Run Test Vectors
48+
working-directory: TestVectors
49+
run: ../gradlew runTests

TestVectors/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
# For TestMPL, the build.gradle.kts define's the gradle wrapper version.
4+
# This prevents having ANOTHER copy of gradle in the repo
5+
gradlew
6+
gradlew.bat
7+
gradle/wrapper/gradle-wrapper.jar
8+
9+
# Ignore Gradle build output directory
10+
build
11+
12+
# JetBrains
13+
.idea/*
14+
*.iml
15+
16+
# Mac OS X
17+
.DS_Store
18+
19+
# Dafny Generated Java
20+
src/main/dafny-generated/
21+
src/test/dafny-generated/

TestVectors/PermTest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"RoundTripTest":{"Records":[{"RecNum":{"N":"200"},"StringSet":{"SS":["aaa"]},"NumberSet":{"NS":["111"]},"BinarySet":{"BS":["AQID"]}},{"RecNum":{"N":"201"},"StringSet":{"SS":["aaa","bbb"]},"NumberSet":{"NS":["111","222"]},"BinarySet":{"BS":["AQID","AgME"]}},{"RecNum":{"N":"202"},"StringSet":{"SS":["bbb","aaa"]},"NumberSet":{"NS":["222","111"]},"BinarySet":{"BS":["AgME","AQID"]}},{"RecNum":{"N":"203"},"StringSet":{"SS":["aaa","bbb","ccc"]},"NumberSet":{"NS":["111","222","333"]},"BinarySet":{"BS":["AQID","AgME","AwQF"]}},{"RecNum":{"N":"204"},"StringSet":{"SS":["bbb","aaa","ccc"]},"NumberSet":{"NS":["222","111","333"]},"BinarySet":{"BS":["AgME","AQID","AwQF"]}},{"RecNum":{"N":"205"},"StringSet":{"SS":["ccc","aaa","bbb"]},"NumberSet":{"NS":["333","111","222"]},"BinarySet":{"BS":["AwQF","AQID","AgME"]}},{"RecNum":{"N":"206"},"StringSet":{"SS":["aaa","ccc","bbb"]},"NumberSet":{"NS":["111","333","222"]},"BinarySet":{"BS":["AQID","AwQF","AgME"]}},{"RecNum":{"N":"207"},"StringSet":{"SS":["aaa","bbb","ccc"]},"NumberSet":{"NS":["111","222","333"]},"BinarySet":{"BS":["AQID","AgME","AwQF"]}},{"RecNum":{"N":"208"},"StringSet":{"SS":["bbb","aaa","ccc"]},"NumberSet":{"NS":["222","111","333"]},"BinarySet":{"BS":["AgME","AQID","AwQF"]}},{"RecNum":{"N":"209"},"StringSet":{"SS":["aaa","bbb","ccc","ddd"]},"NumberSet":{"NS":["111","222","333","444"]},"BinarySet":{"BS":["AQID","AgME","AwQF","BAUG"]}},{"RecNum":{"N":"210"},"StringSet":{"SS":["bbb","aaa","ccc","ddd"]},"NumberSet":{"NS":["222","111","333","444"]},"BinarySet":{"BS":["AgME","AQID","AwQF","BAUG"]}},{"RecNum":{"N":"211"},"StringSet":{"SS":["ccc","aaa","bbb","ddd"]},"NumberSet":{"NS":["333","111","222","444"]},"BinarySet":{"BS":["AwQF","AQID","AgME","BAUG"]}},{"RecNum":{"N":"212"},"StringSet":{"SS":["aaa","ccc","bbb","ddd"]},"NumberSet":{"NS":["111","333","222","444"]},"BinarySet":{"BS":["AQID","AwQF","AgME","BAUG"]}},{"RecNum":{"N":"213"},"StringSet":{"SS":["aaa","bbb","ccc","ddd"]},"NumberSet":{"NS":["111","222","333","444"]},"BinarySet":{"BS":["AQID","AgME","AwQF","BAUG"]}},{"RecNum":{"N":"214"},"StringSet":{"SS":["bbb","aaa","ccc","ddd"]},"NumberSet":{"NS":["222","111","333","444"]},"BinarySet":{"BS":["AgME","AQID","AwQF","BAUG"]}},{"RecNum":{"N":"215"},"StringSet":{"SS":["ddd","aaa","ccc","bbb"]},"NumberSet":{"NS":["444","111","333","222"]},"BinarySet":{"BS":["BAUG","AQID","AwQF","AgME"]}},{"RecNum":{"N":"216"},"StringSet":{"SS":["aaa","ddd","ccc","bbb"]},"NumberSet":{"NS":["111","444","333","222"]},"BinarySet":{"BS":["AQID","BAUG","AwQF","AgME"]}},{"RecNum":{"N":"217"},"StringSet":{"SS":["ccc","ddd","aaa","bbb"]},"NumberSet":{"NS":["333","444","111","222"]},"BinarySet":{"BS":["AwQF","BAUG","AQID","AgME"]}},{"RecNum":{"N":"218"},"StringSet":{"SS":["ddd","ccc","aaa","bbb"]},"NumberSet":{"NS":["444","333","111","222"]},"BinarySet":{"BS":["BAUG","AwQF","AQID","AgME"]}},{"RecNum":{"N":"219"},"StringSet":{"SS":["ddd","aaa","ccc","bbb"]},"NumberSet":{"NS":["444","111","333","222"]},"BinarySet":{"BS":["BAUG","AQID","AwQF","AgME"]}},{"RecNum":{"N":"220"},"StringSet":{"SS":["aaa","ddd","ccc","bbb"]},"NumberSet":{"NS":["111","444","333","222"]},"BinarySet":{"BS":["AQID","BAUG","AwQF","AgME"]}},{"RecNum":{"N":"221"},"StringSet":{"SS":["aaa","bbb","ccc","ddd"]},"NumberSet":{"NS":["111","222","333","444"]},"BinarySet":{"BS":["AQID","AgME","AwQF","BAUG"]}},{"RecNum":{"N":"222"},"StringSet":{"SS":["bbb","aaa","ccc","ddd"]},"NumberSet":{"NS":["222","111","333","444"]},"BinarySet":{"BS":["AgME","AQID","AwQF","BAUG"]}},{"RecNum":{"N":"223"},"StringSet":{"SS":["ccc","aaa","bbb","ddd"]},"NumberSet":{"NS":["333","111","222","444"]},"BinarySet":{"BS":["AwQF","AQID","AgME","BAUG"]}},{"RecNum":{"N":"224"},"StringSet":{"SS":["aaa","ccc","bbb","ddd"]},"NumberSet":{"NS":["111","333","222","444"]},"BinarySet":{"BS":["AQID","AwQF","AgME","BAUG"]}},{"RecNum":{"N":"225"},"StringSet":{"SS":["aaa","bbb","ccc","ddd"]},"NumberSet":{"NS":["111","222","333","444"]},"BinarySet":{"BS":["AQID","AgME","AwQF","BAUG"]}},{"RecNum":{"N":"226"},"StringSet":{"SS":["bbb","aaa","ccc","ddd"]},"NumberSet":{"NS":["222","111","333","444"]},"BinarySet":{"BS":["AgME","AQID","AwQF","BAUG"]}},{"RecNum":{"N":"227"},"StringSet":{"SS":["bbb","aaa","ddd","ccc"]},"NumberSet":{"NS":["222","111","444","333"]},"BinarySet":{"BS":["AgME","AQID","BAUG","AwQF"]}},{"RecNum":{"N":"228"},"StringSet":{"SS":["aaa","bbb","ddd","ccc"]},"NumberSet":{"NS":["111","222","444","333"]},"BinarySet":{"BS":["AQID","AgME","BAUG","AwQF"]}},{"RecNum":{"N":"229"},"StringSet":{"SS":["ddd","bbb","aaa","ccc"]},"NumberSet":{"NS":["444","222","111","333"]},"BinarySet":{"BS":["BAUG","AgME","AQID","AwQF"]}},{"RecNum":{"N":"230"},"StringSet":{"SS":["bbb","ddd","aaa","ccc"]},"NumberSet":{"NS":["222","444","111","333"]},"BinarySet":{"BS":["AgME","BAUG","AQID","AwQF"]}},{"RecNum":{"N":"231"},"StringSet":{"SS":["bbb","aaa","ddd","ccc"]},"NumberSet":{"NS":["222","111","444","333"]},"BinarySet":{"BS":["AgME","AQID","BAUG","AwQF"]}},{"RecNum":{"N":"232"},"StringSet":{"SS":["aaa","bbb","ddd","ccc"]},"NumberSet":{"NS":["111","222","444","333"]},"BinarySet":{"BS":["AQID","AgME","BAUG","AwQF"]}}],"Configs":{"AllSign":{"attributeActionsOnEncrypt":{"RecNum":"SIGN_ONLY","StringSet":"SIGN_ONLY","NumberSet":"SIGN_ONLY","BinarySet":"SIGN_ONLY"}},"AllEncrypt":{"attributeActionsOnEncrypt":{"RecNum":"SIGN_ONLY","StringSet":"ENCRYPT_AND_SIGN","NumberSet":"ENCRYPT_AND_SIGN","BinarySet":"ENCRYPT_AND_SIGN"}}}}}

TestVectors/build.gradle.kts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import java.io.File
5+
import java.io.FileInputStream
6+
import java.util.Properties
7+
import java.net.URI
8+
9+
plugins {
10+
`java-library`
11+
}
12+
13+
var props = Properties().apply {
14+
load(FileInputStream(File(rootProject.rootDir, "project.properties")))
15+
}
16+
17+
group = "software.amazon.cryptography"
18+
version = props.getProperty("projectJavaVersion")
19+
description = "TestVectorsDynamoDbEncryption"
20+
21+
java {
22+
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
23+
sourceSets["main"].java {
24+
srcDir("src/main/java")
25+
srcDir("src/main/dafny-generated")
26+
srcDir("src/main/smithy-generated")
27+
}
28+
sourceSets["test"].java {
29+
srcDir("src/test/dafny-generated")
30+
}
31+
}
32+
33+
tasks.withType<JavaCompile>() {
34+
options.encoding = "UTF-8"
35+
}
36+
37+
repositories {
38+
mavenLocal()
39+
maven {
40+
name = "DynamoDB Local Release Repository - US West (Oregon) Region"
41+
url = URI.create("https://s3-us-west-2.amazonaws.com/dynamodb-local/release")
42+
}
43+
mavenCentral()
44+
}
45+
46+
// Configuration to hold SQLLite information.
47+
val dynamodb by configurations.creating
48+
49+
dependencies {
50+
implementation("org.dafny:DafnyRuntime:4.9.0")
51+
implementation("software.amazon.smithy.dafny:conversion:0.1.1")
52+
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${props.getProperty("mplDependencyJavaVersion")}")
53+
implementation("software.amazon.cryptography:TestAwsCryptographicMaterialProviders:${props.getProperty("mplDependencyJavaVersion")}-SNAPSHOT")
54+
implementation(project(":")) // Native DB-ESDK business logic
55+
implementation(files("libs/dafny-bridge-DELETE-ME.jar")) // Dafny bridge: ToDafny/ToNative/internaldafny (stripped of business logic)
56+
57+
implementation(platform("software.amazon.awssdk:bom:${props.getProperty("awsSdkVersion")}"))
58+
implementation("software.amazon.awssdk:dynamodb")
59+
implementation("software.amazon.awssdk:dynamodb-enhanced")
60+
implementation("software.amazon.awssdk:kms")
61+
testImplementation("com.amazonaws:DynamoDBLocal:2.+")
62+
dynamodb("com.amazonaws:DynamoDBLocal:2.+")
63+
if (org.apache.tools.ant.taskdefs.condition.Os.isArch("aarch64")) {
64+
testImplementation("io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392")
65+
dynamodb("io.github.ganadist.sqlite4java:libsqlite4java-osx-aarch64:1.0.392")
66+
}
67+
}
68+
69+
tasks.register<Copy>("copyKeysJSON") {
70+
from(layout.projectDirectory.file("../submodules/aws-cryptographic-material-providers-library/TestVectorsAwsCryptographicMaterialProviders/dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json"))
71+
into(layout.projectDirectory)
72+
}
73+
74+
tasks.register<Copy>("CopyDynamoDb") {
75+
from(dynamodb) {
76+
include("*.dll")
77+
include("*.dylib")
78+
include("*.so")
79+
}
80+
into("build/libs")
81+
}
82+
83+
tasks.register<JavaExec>("runTests") {
84+
dependsOn("CopyDynamoDb")
85+
systemProperty("java.library.path", "build/libs")
86+
workingDir = projectDir
87+
mainClass.set("TestsFromDafny")
88+
classpath = sourceSets["test"].runtimeClasspath
89+
}

TestVectors/configs.json

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
{
2+
"tableEncryptionConfigs": {
3+
"0": {},
4+
"1": {
5+
"attributeActionsOnEncrypt": {
6+
"RecNum": "SIGN_ONLY",
7+
"Stuff": "ENCRYPT_AND_SIGN",
8+
"Two": "ENCRYPT_AND_SIGN",
9+
"Three": "ENCRYPT_AND_SIGN",
10+
"Four": "SIGN_ONLY",
11+
"Five": "SIGN_ONLY",
12+
"Six": "SIGN_ONLY",
13+
"One": "DO_NOTHING",
14+
"Seven": "DO_NOTHING",
15+
"Eight": "DO_NOTHING",
16+
"Nine": "DO_NOTHING",
17+
"NumberTest": "ENCRYPT_AND_SIGN"
18+
},
19+
"allowedUnsignedAttributes": ["One", "Seven", "Eight", "Nine"],
20+
"search": {
21+
"versions": [
22+
{
23+
"standardBeacons": [
24+
{
25+
"Name": "Stuff",
26+
"Length": 32
27+
},
28+
{
29+
"Name": "Two",
30+
"Length": 32
31+
},
32+
{
33+
"Name": "Three",
34+
"Length": 32
35+
},
36+
{
37+
"Name": "NumberTest",
38+
"Length": 32
39+
}
40+
]
41+
}
42+
]
43+
}
44+
},
45+
"2": {
46+
"attributeActionsOnEncrypt": {
47+
"RecNum": "SIGN_ONLY",
48+
"Stuff": "ENCRYPT_AND_SIGN",
49+
"Four": "ENCRYPT_AND_SIGN",
50+
"Five": "ENCRYPT_AND_SIGN",
51+
"Six": "ENCRYPT_AND_SIGN",
52+
"Two": "SIGN_ONLY",
53+
"Three": "SIGN_ONLY",
54+
"One": "DO_NOTHING",
55+
"Seven": "DO_NOTHING",
56+
"Eight": "DO_NOTHING",
57+
"Nine": "DO_NOTHING",
58+
"NumberTest": "SIGN_ONLY"
59+
},
60+
"allowedUnsignedAttributes": ["One", "Seven", "Eight", "Nine"],
61+
"search": {
62+
"versions": [
63+
{
64+
"standardBeacons": [
65+
{
66+
"Name": "Stuff",
67+
"Length": 32
68+
},
69+
{
70+
"Name": "Four",
71+
"Length": 32
72+
},
73+
{
74+
"Name": "Five",
75+
"Length": 32
76+
},
77+
{
78+
"Name": "Six",
79+
"Length": 32
80+
}
81+
]
82+
}
83+
]
84+
}
85+
},
86+
"3": {
87+
"attributeActionsOnEncrypt": {
88+
"RecNum": "SIGN_ONLY",
89+
"Stuff": "SIGN_ONLY",
90+
"Four": "SIGN_ONLY",
91+
"Five": "SIGN_ONLY",
92+
"Six": "SIGN_ONLY",
93+
"Two": "SIGN_ONLY",
94+
"Three": "SIGN_ONLY",
95+
"One": "DO_NOTHING",
96+
"Seven": "DO_NOTHING",
97+
"Eight": "DO_NOTHING",
98+
"Nine": "DO_NOTHING",
99+
"NumberTest": "SIGN_ONLY"
100+
},
101+
"allowedUnsignedAttributes": ["One", "Seven", "Eight", "Nine"]
102+
},
103+
"4": {
104+
"attributeActionsOnEncrypt": {
105+
"RecNum": "SIGN_ONLY",
106+
"Stuff": "ENCRYPT_AND_SIGN",
107+
"Two": "ENCRYPT_AND_SIGN",
108+
"Three": "ENCRYPT_AND_SIGN",
109+
"Four": "ENCRYPT_AND_SIGN",
110+
"Five": "ENCRYPT_AND_SIGN",
111+
"Six": "ENCRYPT_AND_SIGN",
112+
"One": "DO_NOTHING",
113+
"Seven": "DO_NOTHING",
114+
"Eight": "DO_NOTHING",
115+
"Nine": "DO_NOTHING",
116+
"NumberTest": "SIGN_ONLY"
117+
},
118+
"allowedUnsignedAttributes": ["One", "Seven", "Eight", "Nine"]
119+
},
120+
"5": {
121+
"attributeActionsOnEncrypt": {
122+
"RecNum": "SIGN_ONLY",
123+
"Stuff": "ENCRYPT_AND_SIGN",
124+
"Two": "ENCRYPT_AND_SIGN",
125+
"Three": "ENCRYPT_AND_SIGN",
126+
"Four": "SIGN_ONLY",
127+
"Five": "SIGN_ONLY",
128+
"Six": "SIGN_ONLY",
129+
"One": "DO_NOTHING",
130+
"Seven": "DO_NOTHING",
131+
"Eight": "DO_NOTHING",
132+
"Nine": "DO_NOTHING",
133+
"NumberTest": "SIGN_ONLY"
134+
},
135+
"allowedUnsignedAttributes": ["One", "Seven", "Eight", "Nine"],
136+
"search": {
137+
"versions": [
138+
{
139+
"standardBeacons": [
140+
{
141+
"Name": "Stuff",
142+
"Length": 32
143+
},
144+
{
145+
"Name": "Two",
146+
"Length": 32
147+
},
148+
{
149+
"Name": "Three",
150+
"Length": 32
151+
}
152+
],
153+
"compoundBeacons": [
154+
{
155+
"Name": "Comp1",
156+
"Split": ".",
157+
"Encrypted": [
158+
{
159+
"Name": "Stuff",
160+
"Prefix": "S_"
161+
}
162+
],
163+
"Signed": [
164+
{
165+
"Name": "Four",
166+
"Prefix": "F_"
167+
}
168+
]
169+
}
170+
]
171+
}
172+
]
173+
}
174+
}
175+
}
176+
}

0 commit comments

Comments
 (0)