Skip to content

Commit 1628e66

Browse files
authored
feat(Rust): Add support for Rust Encryption SDK (#689)
1 parent a287d45 commit 1628e66

File tree

87 files changed

+6932
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+6932
-182
lines changed

.github/workflows/daily_ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
1212
uses: ./.github/workflows/library_codegen.yml
1313
with:
14-
dafny: '4.8.1'
14+
dafny: '4.9.0'
1515
daily-ci-verification:
1616
# Don't run the cron builds on forks
1717
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
1818
uses: ./.github/workflows/library_dafny_verification.yml
1919
with:
20-
dafny: '4.8.1'
20+
dafny: '4.9.0'
2121
# daily-ci-java:
2222
# if: github.event_name != 'schedule' || github.repository_owner == 'aws'
2323
# uses: ./.github/workflows/library_java_tests.yml
@@ -27,15 +27,15 @@ jobs:
2727
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
2828
uses: ./.github/workflows/library_net_tests.yml
2929
with:
30-
dafny: '4.8.1'
30+
dafny: '4.9.0'
3131
daily-ci-rust:
3232
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
3333
uses: ./.github/workflows/library_rust_tests.yml
3434
with:
35-
dafny: '4.8.1'
35+
dafny: '4.9.0'
3636

3737
daily-ci-interop-tests:
3838
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
3939
uses: ./.github/workflows/library_interop_tests.yml
4040
with:
41-
dafny: '4.8.1'
41+
dafny: '4.9.0'

.github/workflows/library_interop_test_vectors.yml

Lines changed: 107 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
ubuntu-latest,
2626
macos-13,
2727
]
28-
language: [java, net]
28+
language: [java, net, rust]
2929
# https://taskei.amazon.dev/tasks/CrypTool-5284
3030
dotnet-version: ["6.0.x"]
3131
runs-on: ${{ matrix.os }}
@@ -38,6 +38,14 @@ jobs:
3838
run: |
3939
git config --global core.longpaths true
4040
41+
# TestVectors will call KMS
42+
- name: Configure AWS Credentials
43+
uses: aws-actions/configure-aws-credentials@v2
44+
with:
45+
aws-region: us-west-2
46+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
47+
role-session-name: InterOpTests
48+
4149
- uses: actions/checkout@v3
4250
# Not all submodules are needed.
4351
# We manually pull the submodule we DO need.
@@ -51,15 +59,40 @@ jobs:
5159
with:
5260
dotnet-version: ${{ matrix.dotnet-version }}
5361

62+
# Setup Java in Rust is needed for running polymorph
5463
- name: Setup Java 17
55-
if: matrix.language == 'java'
64+
if: matrix.language == 'java' || matrix.language == 'rust'
5665
uses: actions/setup-java@v3
5766
with:
5867
distribution: "corretto"
5968
java-version: 17
6069

70+
- name: Setup Rust Toolchain for GitHub CI
71+
if: matrix.language == 'rust'
72+
uses: actions-rust-lang/[email protected]
73+
with:
74+
components: rustfmt
75+
# TODO - uncomment this after Rust formatter works
76+
# - name: Rustfmt Check
77+
# uses: actions-rust-lang/rustfmt@v1
78+
79+
# TODO: Remove this after the formatting in Rust starts working
80+
- name: smithy-dafny Rust hacks
81+
if: matrix.language == 'rust'
82+
shell: bash
83+
run: |
84+
if [ "$RUNNER_OS" == "macOS" ]; then
85+
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
86+
else
87+
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
88+
fi
89+
90+
- name: Setup NASM for Windows in Rust (aws-lc-sys)
91+
if: matrix.language == 'rust' && matrix.os == 'windows-latest'
92+
uses: ilammy/setup-nasm@v1
93+
6194
- name: Setup Dafny
62-
uses: dafny-lang/setup-dafny-action@v1.6.1
95+
uses: dafny-lang/setup-dafny-action@v1.7.0
6396
with:
6497
dafny-version: ${{ inputs.dafny }}
6598

@@ -89,21 +122,33 @@ jobs:
89122
# This works because `node` is installed by default on GHA runners
90123
CORES=$(node -e 'console.log(os.cpus().length)')
91124
make transpile_net
92-
125+
126+
- name: Install Smithy-Dafny codegen dependencies
127+
if: matrix.language == 'rust'
128+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
129+
130+
# TODO: Remove this after checking in Rust polymorph code
131+
- name: Run make polymorph_rust
132+
if: matrix.language == 'rust'
133+
shell: bash
134+
working-directory: ./${{ matrix.library }}
135+
run: |
136+
make polymorph_rust
137+
138+
- name: Build ${{ matrix.library }} implementation in Rust
139+
if: matrix.language == 'rust'
140+
shell: bash
141+
working-directory: ./${{ matrix.library }}
142+
run: |
143+
CORES=$(node -e 'console.log(os.cpus().length)')
144+
make transpile_rust CORES=$CORES
145+
93146
- name: Setup gradle
94147
if: matrix.language == 'java'
95148
uses: gradle/gradle-build-action@v2
96149
with:
97150
gradle-version: 7.2
98151

99-
# TestVectors will call KMS
100-
- name: Configure AWS Credentials
101-
uses: aws-actions/configure-aws-credentials@v2
102-
with:
103-
aws-region: us-west-2
104-
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
105-
role-session-name: InterOpTests
106-
107152
- name: Create Manifests
108153
working-directory: ./${{ matrix.library }}
109154
run: make test_generate_vectors_${{ matrix.language }}
@@ -132,8 +177,8 @@ jobs:
132177
ubuntu-latest,
133178
macos-13,
134179
]
135-
encrypting_language: [java, net]
136-
decrypting_language: [java, net]
180+
encrypting_language: [java, net, rust]
181+
decrypting_language: [java, net, rust]
137182
# https://taskei.amazon.dev/tasks/CrypTool-5284
138183
dotnet-version: ["6.0.x"]
139184
runs-on: ${{ matrix.os }}
@@ -145,6 +190,7 @@ jobs:
145190
- name: Support longpaths on Git checkout
146191
run: |
147192
git config --global core.longpaths true
193+
148194
# TestVectors will call KMS
149195
- name: Configure AWS Credentials
150196
uses: aws-actions/configure-aws-credentials@v2
@@ -159,19 +205,45 @@ jobs:
159205
- run: git submodule update --init libraries
160206
- run: git submodule update --init --recursive mpl
161207

208+
# Set up runtimes
162209
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
163210
if: matrix.decrypting_language == 'net'
164211
uses: actions/setup-dotnet@v3
165212
with:
166213
dotnet-version: ${{ matrix.dotnet-version }}
167214

215+
# Setup Java in Rust is needed for running polymorph
168216
- name: Setup Java 17
169-
if: matrix.decrypting_language == 'java'
217+
if: matrix.decrypting_language == 'java' || matrix.decrypting_language == 'rust'
170218
uses: actions/setup-java@v3
171219
with:
172220
distribution: "corretto"
173221
java-version: 17
174222

223+
- name: Setup Rust Toolchain for GitHub CI
224+
if: matrix.decrypting_language == 'rust'
225+
uses: actions-rust-lang/[email protected]
226+
with:
227+
components: rustfmt
228+
# TODO - uncomment this after Rust formatter works
229+
# - name: Rustfmt Check
230+
# uses: actions-rust-lang/rustfmt@v1
231+
232+
# TODO: Remove this after the formatting in Rust starts working
233+
- name: smithy-dafny Rust hacks
234+
if: matrix.decrypting_language == 'rust'
235+
shell: bash
236+
run: |
237+
if [ "$RUNNER_OS" == "macOS" ]; then
238+
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
239+
else
240+
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
241+
fi
242+
243+
- name: Setup NASM for Windows in Rust (aws-lc-sys)
244+
if: matrix.decrypting_language == 'rust' && matrix.os == 'windows-latest'
245+
uses: ilammy/setup-nasm@v1
246+
175247
- name: Setup Dafny
176248
uses: dafny-lang/[email protected]
177249
with:
@@ -204,6 +276,26 @@ jobs:
204276
CORES=$(node -e 'console.log(os.cpus().length)')
205277
make transpile_net
206278
279+
- name: Install Smithy-Dafny codegen dependencies
280+
if: matrix.decrypting_language == 'rust'
281+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
282+
283+
# TODO: Remove this after checking in Rust polymorph code
284+
- name: Run make polymorph_rust
285+
if: matrix.decrypting_language == 'rust'
286+
shell: bash
287+
working-directory: ./${{ matrix.library }}
288+
run: |
289+
make polymorph_rust
290+
291+
- name: Build ${{ matrix.library }} implementation in Rust
292+
if: matrix.decrypting_language == 'rust'
293+
shell: bash
294+
working-directory: ./${{ matrix.library }}
295+
run: |
296+
CORES=$(node -e 'console.log(os.cpus().length)')
297+
make transpile_rust CORES=$CORES
298+
207299
- name: Download Encrypt Manifest Artifact
208300
uses: actions/download-artifact@v4
209301
with:

.github/workflows/library_rust_tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@ jobs:
2222
os: [
2323
windows-latest,
2424
ubuntu-latest,
25-
macos-12,
25+
macos-13,
2626
]
2727
runs-on: ${{ matrix.os }}
2828
permissions:
2929
id-token: write
3030
contents: read
31-
env:
32-
# TODO: do we need this here?
33-
DOTNET_CLI_TELEMETRY_OPTOUT: 1
34-
DOTNET_NOLOGO: 1
3531
steps:
3632
- name: Support longpaths on Git checkout
3733
run: |
3834
git config --global core.longpaths true
39-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v3
4036
- name: Init Submodules
4137
shell: bash
4238
run: |
@@ -58,11 +54,10 @@ jobs:
5854
# - name: Rustfmt Check
5955
# uses: actions-rust-lang/rustfmt@v1
6056

61-
# TODO: Use setup-dafny-actions with correct version when Dafny releases 4.8.2
6257
- name: Setup Dafny
6358
uses: dafny-lang/[email protected]
6459
with:
65-
dafny-version: nightly-latest
60+
dafny-version: 4.9.0
6661

6762
# TODO: Remove this after the formatting in Rust starts working
6863
- name: smithy-dafny Rust hacks
@@ -81,6 +76,7 @@ jobs:
8176
java-version: "17"
8277

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

8682
- name: Install Smithy-Dafny codegen dependencies
@@ -108,7 +104,7 @@ jobs:
108104
run: |
109105
# This works because `node` is installed by default on GHA runners
110106
CORES=$(node -e 'console.log(os.cpus().length)')
111-
make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES
107+
make transpile_rust CORES=$CORES
112108
113109
# Remove Rust hacks once Dafny fixes this
114110
- name: Update implementation_from_dafny.rs to add deps
@@ -139,4 +135,4 @@ jobs:
139135
working-directory: ./AwsEncryptionSDK/runtimes/rust
140136
shell: bash
141137
run: |
142-
cargo test --examples
138+
cargo test --release --examples

.github/workflows/pull.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ jobs:
88
pr-ci-codegen:
99
uses: ./.github/workflows/library_codegen.yml
1010
with:
11-
dafny: '4.8.1'
11+
dafny: '4.9.0'
1212
pr-ci-verification:
1313
uses: ./.github/workflows/library_dafny_verification.yml
1414
with:
15-
dafny: '4.8.1'
15+
dafny: '4.9.0'
1616
# pr-ci-java:
1717
# uses: ./.github/workflows/library_java_tests.yml
1818
# with:
1919
# dafny: '4.2.0'
2020
pr-ci-net:
2121
uses: ./.github/workflows/library_net_tests.yml
2222
with:
23-
dafny: '4.8.1'
23+
dafny: '4.9.0'
24+
pr-ci-rust:
25+
uses: ./.github/workflows/library_rust_tests.yml
26+
with:
27+
dafny: '4.9.0'
2428
pr-test-vectors:
2529
uses: ./.github/workflows/library_interop_tests.yml
2630
with:
27-
dafny: '4.8.1'
31+
dafny: '4.9.0'
2832
pr-dafny-test-vectors:
2933
uses: ./.github/workflows/library_interop_test_vectors.yml
3034
with:
31-
dafny: '4.8.1'
35+
dafny: '4.9.0'
3236
pr-dafny-legacy-test-vectors:
3337
uses: ./.github/workflows/library_legacy_interop_test_vectors.yml
3438
with:
35-
dafny: '4.8.1'
39+
dafny: '4.9.0'

.github/workflows/push.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ jobs:
1010
pr-ci-codegen:
1111
uses: ./.github/workflows/library_codegen.yml
1212
with:
13-
dafny: '4.8.1'
13+
dafny: '4.9.0'
1414
push-ci-verification:
1515
uses: ./.github/workflows/library_dafny_verification.yml
1616
with:
17-
dafny: '4.8.1'
17+
dafny: '4.9.0'
1818
# push-ci-java:
1919
# uses: ./.github/workflows/library_java_tests.yml
2020
# with:
2121
# dafny: '4.2.0'
2222
push-ci-net:
2323
uses: ./.github/workflows/library_net_tests.yml
2424
with:
25-
dafny: '4.8.1'
25+
dafny: '4.9.0'
2626
push-ci-rust:
2727
uses: ./.github/workflows/library_rust_tests.yml
2828
with:
29-
dafny: '4.8.1'
29+
dafny: '4.9.0'
3030
pr-test-vectors:
3131
uses: ./.github/workflows/library_interop_tests.yml
3232
with:
33-
dafny: '4.8.1'
33+
dafny: '4.9.0'

0 commit comments

Comments
 (0)