Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TestVectors): Add Rust support #693

Merged
merged 125 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
1c4b133
feat(support Rust): Add Rust Encryption SDK
RitvikKapila Sep 27, 2024
983bff1
fix Makefile; update externs
RitvikKapila Oct 1, 2024
83592af
add kms rsa example
RitvikKapila Oct 7, 2024
f54add3
add examples dir
RitvikKapila Oct 7, 2024
2c6d90d
add kms, discovery keyring example
RitvikKapila Oct 7, 2024
4f26918
fix keyring examples
RitvikKapila Oct 8, 2024
0323ea6
Merge branch 'mainline' into rkapila/rust
RitvikKapila Oct 8, 2024
213fe56
add discovery examples
RitvikKapila Oct 8, 2024
380b161
add
RitvikKapila Oct 8, 2024
d1c1d88
add
RitvikKapila Oct 9, 2024
484adee
add raw rsa keyring
RitvikKapila Oct 9, 2024
d9fb8f5
add hkeyring examples
RitvikKapila Oct 10, 2024
baa3fbe
renaming
RitvikKapila Oct 10, 2024
e9f5ccf
add client supplier and custom cmm examples
RitvikKapila Oct 14, 2024
d6ea973
Merge branch 'mainline' into rkapila/rust
RitvikKapila Oct 14, 2024
e0f242f
minor fixes; add misc examples
RitvikKapila Oct 15, 2024
bfb7c0c
update examples/main.rs
RitvikKapila Oct 15, 2024
2c8e891
update dependencies
RitvikKapila Oct 15, 2024
bc4ced8
fix
RitvikKapila Oct 16, 2024
b103530
add daily ci
RitvikKapila Oct 16, 2024
ef20390
add ci
RitvikKapila Oct 16, 2024
9748fd9
fix
RitvikKapila Oct 16, 2024
6eceaee
try
RitvikKapila Oct 16, 2024
0deaad8
m
RitvikKapila Oct 16, 2024
77f1344
m
RitvikKapila Oct 16, 2024
ecd4d37
m
RitvikKapila Oct 16, 2024
7d9b007
m
RitvikKapila Oct 16, 2024
2727bb5
m
RitvikKapila Oct 16, 2024
6feecc5
m
RitvikKapila Oct 16, 2024
75bb9ac
m
RitvikKapila Oct 16, 2024
5d8c7a1
fix
RitvikKapila Oct 16, 2024
6085144
fix
RitvikKapila Oct 16, 2024
30c80fa
fix
RitvikKapila Oct 16, 2024
ca93d44
fix
RitvikKapila Oct 16, 2024
3d04d91
fix
RitvikKapila Oct 16, 2024
bea5e99
m
RitvikKapila Oct 16, 2024
2e4f666
m
RitvikKapila Oct 16, 2024
a37e746
fix
RitvikKapila Oct 16, 2024
3a05ca2
fix
RitvikKapila Oct 16, 2024
33b5cb0
fix
RitvikKapila Oct 16, 2024
7d012fd
fix
RitvikKapila Oct 16, 2024
eee329c
fix
RitvikKapila Oct 17, 2024
573f51d
update
RitvikKapila Oct 17, 2024
eb3bb32
update
RitvikKapila Oct 17, 2024
445a44a
update
RitvikKapila Oct 17, 2024
743753f
fix
RitvikKapila Oct 17, 2024
383cda8
fix
RitvikKapila Oct 17, 2024
3edc4fd
fix
RitvikKapila Oct 17, 2024
760aaef
fix
RitvikKapila Oct 17, 2024
b40f500
fix
RitvikKapila Oct 17, 2024
374cfd0
add dafny env var
RitvikKapila Oct 17, 2024
207234c
add dafny env var
RitvikKapila Oct 17, 2024
ba9161c
try
RitvikKapila Oct 17, 2024
39d710a
fix version
RitvikKapila Oct 17, 2024
9b73ded
separate windows and unix polymorph
RitvikKapila Oct 17, 2024
8b8890d
revert
RitvikKapila Oct 17, 2024
57b9f8c
add shared cache example
RitvikKapila Oct 18, 2024
83af517
m
RitvikKapila Oct 18, 2024
33b5e81
m
RitvikKapila Oct 20, 2024
4b01aa1
bump Dafny / Smithy Dafny / MPL to HEAD
RitvikKapila Oct 22, 2024
c034f7c
initial commit of ESDK TestVectors
seebees Nov 2, 2023
5a24dfe
chore: add dafny test vector framework
josecorella Aug 28, 2024
1a5bb94
repoly
josecorella Aug 30, 2024
ad0c7c3
add patch
josecorella Aug 30, 2024
b8a02f7
update
josecorella Aug 30, 2024
4a8f70b
update gha
josecorella Aug 30, 2024
1f5d2f0
m
josecorella Sep 20, 2024
bccbd12
m
josecorella Sep 30, 2024
6d704b5
update
josecorella Sep 30, 2024
979e869
manually fix patch
josecorella Sep 30, 2024
619b16d
progress
josecorella Sep 30, 2024
d2df52e
good progress
josecorella Oct 8, 2024
067dd2c
better progress
josecorella Oct 10, 2024
319df1d
update primitives dafny name
josecorella Oct 22, 2024
c636f6a
Merge branch 'mainline' into jocorell/dafny-test-vectors
RitvikKapila Oct 22, 2024
d52071c
remove smithy-dafny fetch from workflows; bump mpl to HEAD
RitvikKapila Oct 22, 2024
6782bc3
bump dafny in workflows to 4.8.1; minor fix
RitvikKapila Oct 22, 2024
aa36238
resolve conflicts
RitvikKapila Oct 22, 2024
16ccb4a
fix no ec in default cmm
josecorella Oct 22, 2024
a869fdf
regenerate code
josecorella Oct 22, 2024
d86bb32
patch
josecorella Oct 22, 2024
8b0d02b
f
josecorella Oct 22, 2024
c555231
update patch
josecorella Oct 22, 2024
078e1a6
successfully build esdk-dafny to java
josecorella Oct 22, 2024
b997aff
try
RitvikKapila Oct 22, 2024
95d0425
rename AtomicPrimitives
RitvikKapila Oct 22, 2024
135e6bc
fix
RitvikKapila Oct 22, 2024
c346e9e
fix
RitvikKapila Oct 22, 2024
2487f7f
resolve conflicts
RitvikKapila Oct 22, 2024
db291e2
bump mpl
RitvikKapila Oct 23, 2024
5fc0f8b
Merge branch 'rkapila/rust-reviewed' into jocorell/dafny-test-vectors
RitvikKapila Oct 29, 2024
fb3351b
more progress
josecorella Oct 22, 2024
553742f
rewrite manifest to play well with mpl test-vectors
josecorella Oct 25, 2024
5b38632
more updates
josecorella Oct 28, 2024
c3a0141
build decrypt vector from encrypt test success
josecorella Oct 28, 2024
402d4c7
start decrypt vectors
josecorella Oct 30, 2024
4cfd906
java roundtrip works
josecorella Oct 30, 2024
0c4c889
add generated python
josecorella Oct 31, 2024
80b76bd
fix net test vectors
josecorella Oct 31, 2024
3d9f7ce
update
josecorella Oct 31, 2024
8fbb846
polymorph fails; code works
RitvikKapila Nov 1, 2024
02be2aa
add MakeFile; prev commit holds
RitvikKapila Nov 1, 2024
809ae19
fix
RitvikKapila Nov 1, 2024
9d170f8
add TestVectorsDirectory extern
RitvikKapila Nov 2, 2024
4289b96
m
RitvikKapila Nov 5, 2024
875840d
manifest works; encrypt does not
RitvikKapila Nov 6, 2024
4f7e8df
update dafny_runtime_rust for AwsEncryptionSDK and TestVectors
RitvikKapila Nov 6, 2024
aacefdc
add directories for test vectors Rust
RitvikKapila Nov 8, 2024
b17a404
update makefile
RitvikKapila Nov 8, 2024
ee7405f
test vectors work in Rust
RitvikKapila Nov 11, 2024
ed96888
check in polymorph net code
RitvikKapila Nov 11, 2024
ac6d9f5
fix project properties
RitvikKapila Nov 11, 2024
26bec79
remove sed hacks and remove AES192 tests
RitvikKapila Nov 11, 2024
5f103c0
update interop yml file; add polymorph sed hack to makefile
RitvikKapila Nov 11, 2024
d16479c
update dafny version in CI
RitvikKapila Nov 12, 2024
6b661ea
try
RitvikKapila Nov 12, 2024
663d12d
try revert
RitvikKapila Nov 12, 2024
4c65679
fix
RitvikKapila Nov 12, 2024
6f5d628
m
RitvikKapila Nov 12, 2024
5d54c5c
m
RitvikKapila Nov 12, 2024
d91c26f
m
RitvikKapila Nov 12, 2024
478ec50
update Makefile
RitvikKapila Nov 12, 2024
0423b3d
chore(merge): rust tests (#694)
RitvikKapila Nov 13, 2024
49761b8
merge main into feature/rust-support
RitvikKapila Nov 13, 2024
468c9a2
merge main into feature/rust-support
RitvikKapila Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/daily_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
uses: ./.github/workflows/library_codegen.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
daily-ci-verification:
# Don't run the cron builds on forks
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
uses: ./.github/workflows/library_dafny_verification.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
# daily-ci-java:
# if: github.event_name != 'schedule' || github.repository_owner == 'aws'
# uses: ./.github/workflows/library_java_tests.yml
Expand All @@ -27,15 +27,15 @@ jobs:
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
uses: ./.github/workflows/library_net_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
daily-ci-rust:
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
uses: ./.github/workflows/library_rust_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'

daily-ci-interop-tests:
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
uses: ./.github/workflows/library_interop_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
122 changes: 107 additions & 15 deletions .github/workflows/library_interop_test_vectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
ubuntu-latest,
macos-13,
]
language: [java, net]
language: [java, net, rust]
# https://taskei.amazon.dev/tasks/CrypTool-5284
dotnet-version: ["6.0.x"]
runs-on: ${{ matrix.os }}
Expand All @@ -38,6 +38,14 @@ jobs:
run: |
git config --global core.longpaths true

# TestVectors will call KMS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
role-session-name: InterOpTests

- uses: actions/checkout@v3
# Not all submodules are needed.
# We manually pull the submodule we DO need.
Expand All @@ -51,15 +59,40 @@ jobs:
with:
dotnet-version: ${{ matrix.dotnet-version }}

# Setup Java in Rust is needed for running polymorph
- name: Setup Java 17
if: matrix.language == 'java'
if: matrix.language == 'java' || matrix.language == 'rust'
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Setup Rust Toolchain for GitHub CI
if: matrix.language == 'rust'
uses: actions-rust-lang/[email protected]
with:
components: rustfmt
# TODO - uncomment this after Rust formatter works
# - name: Rustfmt Check
# uses: actions-rust-lang/rustfmt@v1

# TODO: Remove this after the formatting in Rust starts working
- name: smithy-dafny Rust hacks
if: matrix.language == 'rust'
shell: bash
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
else
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
fi

- name: Setup NASM for Windows in Rust (aws-lc-sys)
if: matrix.language == 'rust' && matrix.os == 'windows-latest'
uses: ilammy/setup-nasm@v1

- name: Setup Dafny
uses: dafny-lang/setup-dafny-action@v1.6.1
uses: dafny-lang/setup-dafny-action@v1.7.0
with:
dafny-version: ${{ inputs.dafny }}

Expand Down Expand Up @@ -89,21 +122,33 @@ jobs:
# This works because `node` is installed by default on GHA runners
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_net


- name: Install Smithy-Dafny codegen dependencies
if: matrix.language == 'rust'
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies

# TODO: Remove this after checking in Rust polymorph code
- name: Run make polymorph_rust
if: matrix.language == 'rust'
shell: bash
working-directory: ./${{ matrix.library }}
run: |
make polymorph_rust

- name: Build ${{ matrix.library }} implementation in Rust
if: matrix.language == 'rust'
shell: bash
working-directory: ./${{ matrix.library }}
run: |
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES

- name: Setup gradle
if: matrix.language == 'java'
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.2

# TestVectors will call KMS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
role-session-name: InterOpTests

- name: Create Manifests
working-directory: ./${{ matrix.library }}
run: make test_generate_vectors_${{ matrix.language }}
Expand Down Expand Up @@ -132,8 +177,8 @@ jobs:
ubuntu-latest,
macos-13,
]
encrypting_language: [java, net]
decrypting_language: [java, net]
encrypting_language: [java, net, rust]
decrypting_language: [java, net, rust]
# https://taskei.amazon.dev/tasks/CrypTool-5284
dotnet-version: ["6.0.x"]
runs-on: ${{ matrix.os }}
Expand All @@ -145,6 +190,7 @@ jobs:
- name: Support longpaths on Git checkout
run: |
git config --global core.longpaths true

# TestVectors will call KMS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
Expand All @@ -159,19 +205,45 @@ jobs:
- run: git submodule update --init libraries
- run: git submodule update --init --recursive mpl

# Set up runtimes
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
if: matrix.decrypting_language == 'net'
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}

# Setup Java in Rust is needed for running polymorph
- name: Setup Java 17
if: matrix.decrypting_language == 'java'
if: matrix.decrypting_language == 'java' || matrix.decrypting_language == 'rust'
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17

- name: Setup Rust Toolchain for GitHub CI
if: matrix.decrypting_language == 'rust'
uses: actions-rust-lang/[email protected]
with:
components: rustfmt
# TODO - uncomment this after Rust formatter works
# - name: Rustfmt Check
# uses: actions-rust-lang/rustfmt@v1

# TODO: Remove this after the formatting in Rust starts working
- name: smithy-dafny Rust hacks
if: matrix.decrypting_language == 'rust'
shell: bash
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
else
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
fi

- name: Setup NASM for Windows in Rust (aws-lc-sys)
if: matrix.decrypting_language == 'rust' && matrix.os == 'windows-latest'
uses: ilammy/setup-nasm@v1

- name: Setup Dafny
uses: dafny-lang/[email protected]
with:
Expand Down Expand Up @@ -204,6 +276,26 @@ jobs:
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_net

- name: Install Smithy-Dafny codegen dependencies
if: matrix.decrypting_language == 'rust'
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies

# TODO: Remove this after checking in Rust polymorph code
- name: Run make polymorph_rust
if: matrix.decrypting_language == 'rust'
shell: bash
working-directory: ./${{ matrix.library }}
run: |
make polymorph_rust

- name: Build ${{ matrix.library }} implementation in Rust
if: matrix.decrypting_language == 'rust'
shell: bash
working-directory: ./${{ matrix.library }}
run: |
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES

- name: Download Encrypt Manifest Artifact
uses: actions/download-artifact@v4
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/library_rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,17 @@ jobs:
os: [
windows-latest,
ubuntu-latest,
macos-12,
macos-13,
]
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
env:
# TODO: do we need this here?
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
steps:
- name: Support longpaths on Git checkout
run: |
git config --global core.longpaths true
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Init Submodules
shell: bash
run: |
Expand Down Expand Up @@ -81,6 +77,7 @@ jobs:
java-version: "17"

- name: Setup NASM for Windows (aws-lc-sys)
if: matrix.os == 'windows-latest'
uses: ilammy/setup-nasm@v1

- name: Install Smithy-Dafny codegen dependencies
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ jobs:
pr-ci-codegen:
uses: ./.github/workflows/library_codegen.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
pr-ci-verification:
uses: ./.github/workflows/library_dafny_verification.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
# pr-ci-java:
# uses: ./.github/workflows/library_java_tests.yml
# with:
# dafny: '4.2.0'
pr-ci-net:
uses: ./.github/workflows/library_net_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
pr-ci-rust:
uses: ./.github/workflows/library_rust_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
pr-test-vectors:
uses: ./.github/workflows/library_interop_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
pr-dafny-test-vectors:
uses: ./.github/workflows/library_interop_test_vectors.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
10 changes: 5 additions & 5 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ jobs:
pr-ci-codegen:
uses: ./.github/workflows/library_codegen.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
push-ci-verification:
uses: ./.github/workflows/library_dafny_verification.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
# push-ci-java:
# uses: ./.github/workflows/library_java_tests.yml
# with:
# dafny: '4.2.0'
push-ci-net:
uses: ./.github/workflows/library_net_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
push-ci-rust:
uses: ./.github/workflows/library_rust_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
pr-test-vectors:
uses: ./.github/workflows/library_interop_tests.yml
with:
dafny: '4.8.1'
dafny: '4.9.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/AwsEncryptionSDK/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/encryptionsdk/model/EncryptInput.java b/AwsEncryptionSDK/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/encryptionsdk/model/EncryptInput.java
index 67ac1304..7282539c 100644
--- a/AwsEncryptionSDK/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/encryptionsdk/model/EncryptInput.java
+++ b/AwsEncryptionSDK/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/encryptionsdk/model/EncryptInput.java
@@ -192,7 +192,7 @@ public class EncryptInput {
"`frameLength` must be greater than or equal to 1"
);
}
- if (this._frameLengthSet && this.frameLength() > 4294967296) {
+ if (this._frameLengthSet && this.frameLength() > 4294967296L) {
throw new IllegalArgumentException(
"`frameLength` must be less than or equal to 4294967296."
);
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,17 @@ module {:extern "software.amazon.cryptography.encryptionsdk.internaldafny.types"
// || (!exit(A(I)) && !access(B(I)))
| CollectionOfErrors(list: seq<Error>, nameonly message: string)
// The Opaque error, used for native, extern, wrapped or unknown errors
| Opaque(obj: object, alt_text : string)
type OpaqueError = e: Error | e.Opaque? witness *
| Opaque(obj: object)
// A better Opaque, with a visible string representation.
| OpaqueWithText(obj: object, objMessage : string)
type OpaqueError = e: Error | e.Opaque? || e.OpaqueWithText? witness *
// This dummy subset type is included to make sure Dafny
// always generates a _ExternBase___default.java class.
type DummySubsetType = x: int | IsDummySubsetType(x) witness 1
predicate method IsDummySubsetType(x: int) {
0 < x
}

}
abstract module AbstractAwsCryptographyEncryptionSdkService
{
Expand Down
4 changes: 2 additions & 2 deletions AwsEncryptionSDK/project.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file stores the top level dafny version information.
# All elements of the project need to agree on this version.
dafnyVersion=4.8.1
dafnyRuntimeJavaVersion=4.8.1
dafnyVersion=4.9.0
dafnyRuntimeJavaVersion=4.9.0
Loading
Loading