Skip to content

Commit 3117b0c

Browse files
authored
chore(test-vectors): Decrypt .NET Retry flag manifests using Rust (#721)
1 parent bea3f29 commit 3117b0c

File tree

3 files changed

+123
-30
lines changed

3 files changed

+123
-30
lines changed

.github/workflows/library_net_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
with:
166166
aws-region: us-west-2
167167
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
168-
role-session-name: NetTests
168+
role-session-name: NetTestVectors
169169

170170
- name: Setup .NET Core SDK 6
171171
uses: actions/setup-dotnet@v3

.github/workflows/library_rust_tests.yml

Lines changed: 121 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22+
library: [AwsEncryptionSDK]
2223
os: [
2324
windows-latest,
2425
ubuntu-latest,
@@ -53,11 +54,11 @@ jobs:
5354
# TODO - uncomment this after Rust formatter works
5455
# - name: Rustfmt Check
5556
# uses: actions-rust-lang/rustfmt@v1
56-
57+
5758
- name: Setup Dafny
5859
uses: dafny-lang/[email protected]
5960
with:
60-
dafny-version: 4.9.0
61+
dafny-version: ${{ inputs.dafny }}
6162

6263
# TODO: Remove this after the formatting in Rust starts working
6364
- name: smithy-dafny Rust hacks
@@ -87,59 +88,151 @@ jobs:
8788
uses: ./.github/actions/polymorph_codegen
8889
with:
8990
dafny: ${{ env.DAFNY_VERSION }}
90-
library: AwsEncryptionSDK
91+
library: ${{ matrix.library }}
9192
diff-generated-code: false
9293
update-and-regenerate-mpl: true
9394

9495
# TODO: Remove this after checking in Rust polymorph code
96+
# Also uncomment rust check_polymorph_diff for Rust in .github/actions/polymorph_codegen/action.yml
9597
- name: Run make polymorph_rust
9698
shell: bash
97-
working-directory: ./AwsEncryptionSDK
99+
working-directory: ${{ matrix.library }}
98100
run: |
99101
make polymorph_rust
100102
101-
- name: Compile AwsEncryptionSDK implementation
103+
- name: Compile ${{ matrix.library }} implementation
102104
shell: bash
103-
working-directory: ./AwsEncryptionSDK
105+
working-directory: ${{ matrix.library }}
104106
run: |
105107
# This works because `node` is installed by default on GHA runners
106108
CORES=$(node -e 'console.log(os.cpus().length)')
107109
make transpile_rust CORES=$CORES
108110
109-
# Remove Rust hacks once Dafny fixes this
110-
- name: Update implementation_from_dafny.rs to add deps
111-
shell: bash
112-
working-directory: ./AwsEncryptionSDK/runtimes/rust/src
113-
run: |
114-
if [ "$RUNNER_OS" == "macOS" ]; then
115-
sed -i '' '/pub use types::aws_encryption_sdk_config::AwsEncryptionSdkConfig;/a\
116-
pub use crate::deps::aws_cryptography_materialProviders;\
117-
pub use crate::deps::aws_cryptography_keyStore;\
118-
pub use crate::deps::com_amazonaws_kms;
119-
' implementation_from_dafny.rs
120-
else
121-
sed -i '/pub use types::aws_encryption_sdk_config::AwsEncryptionSdkConfig;/a\
122-
pub use crate::deps::aws_cryptography_materialProviders;\
123-
pub use crate::deps::aws_cryptography_keyStore;\
124-
pub use crate::deps::com_amazonaws_kms;
125-
' implementation_from_dafny.rs
126-
fi
127-
128111
- name: Test Linter for Rust examples and implementation_from_dafny.rs
129-
working-directory: ./AwsEncryptionSDK/runtimes/rust
112+
working-directory: ${{ matrix.library }}/runtimes/rust
130113
shell: bash
131114
run: |
132115
cargo clippy
133116
cargo clippy --example main
134117
135118
- name: Test Rust
136-
working-directory: ./AwsEncryptionSDK
119+
working-directory: ${{ matrix.library }}
137120
shell: bash
138121
run: |
139122
make test_rust
140123
141124
- name: Test Examples for Rust
142-
working-directory: ./AwsEncryptionSDK/runtimes/rust
125+
working-directory: ${{ matrix.library }}/runtimes/rust
143126
shell: bash
144127
run: |
145128
cargo test --release --examples
129+
130+
testVectors:
131+
strategy:
132+
fail-fast: false
133+
matrix:
134+
library: [TestVectors]
135+
os: [
136+
# Sed script doesn't work properly on windows
137+
# windows-latest,
138+
ubuntu-latest,
139+
macos-13,
140+
]
141+
runs-on: ${{ matrix.os }}
142+
permissions:
143+
id-token: write
144+
contents: read
145+
steps:
146+
- name: Support longpaths on Git checkout
147+
run: |
148+
git config --global core.longpaths true
149+
- uses: actions/checkout@v3
150+
- name: Init Submodules
151+
shell: bash
152+
run: |
153+
git submodule update --init libraries
154+
git submodule update --init --recursive mpl
155+
156+
- name: Configure AWS Credentials
157+
uses: aws-actions/configure-aws-credentials@v2
158+
with:
159+
aws-region: us-west-2
160+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Dafny-Role-us-west-2
161+
role-session-name: RustTestVectors
162+
163+
- name: Setup Rust Toolchain for GitHub CI
164+
uses: actions-rust-lang/[email protected]
165+
with:
166+
components: rustfmt
167+
# TODO - uncomment this after Rust formatter works
168+
# - name: Rustfmt Check
169+
# uses: actions-rust-lang/rustfmt@v1
170+
171+
- name: Setup Dafny
172+
uses: dafny-lang/[email protected]
173+
with:
174+
dafny-version: ${{ inputs.dafny }}
175+
176+
# TODO: Remove this after the formatting in Rust starts working
177+
- name: smithy-dafny Rust hacks
178+
shell: bash
179+
run: |
180+
if [ "$RUNNER_OS" == "macOS" ]; then
181+
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
182+
else
183+
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' mpl/smithy-dafny/SmithyDafnyMakefile.mk
184+
fi
185+
186+
- name: Setup Java 17 for codegen
187+
uses: actions/setup-java@v3
188+
with:
189+
distribution: "corretto"
190+
java-version: "17"
191+
192+
- name: Setup NASM for Windows (aws-lc-sys)
193+
if: matrix.os == 'windows-latest'
194+
uses: ilammy/setup-nasm@v1
195+
196+
- name: Install Smithy-Dafny codegen dependencies
197+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
198+
199+
- name: Regenerate code using smithy-dafny if necessary
200+
if: ${{ inputs.regenerate-code }}
201+
uses: ./.github/actions/polymorph_codegen
202+
with:
203+
dafny: ${{ env.DAFNY_VERSION }}
204+
library: ${{ matrix.library }}
205+
diff-generated-code: false
206+
update-and-regenerate-mpl: true
207+
208+
# TODO: Remove this after checking in Rust polymorph code
209+
# Also uncomment rust check_polymorph_diff for Rust in .github/actions/polymorph_codegen/action.yml
210+
- name: Run make polymorph_rust
211+
shell: bash
212+
working-directory: ${{ matrix.library }}
213+
run: |
214+
make polymorph_rust
215+
216+
- name: Compile ${{ matrix.library }} implementation
217+
shell: bash
218+
working-directory: ${{ matrix.library }}
219+
run: |
220+
# This works because `node` is installed by default on GHA runners
221+
CORES=$(node -e 'console.log(os.cpus().length)')
222+
make transpile_rust CORES=$CORES
223+
224+
- name: Unzip .NET Retry Flag Manifests
225+
shell: bash
226+
working-directory: TestVectors/dafny/TestVectors/test/
227+
run: |
228+
unzip invalid-Net-4.0.0.zip -d invalid-Net-4.0.0
229+
unzip v4-Net-4.0.1.zip -d v4-Net-4.0.1
230+
unzip valid-Net-4.0.0.zip -d valid-Net-4.0.0
231+
232+
- name: Test Rust
233+
working-directory: ${{ matrix.library }}
234+
shell: bash
235+
run: |
236+
# Without this, running test vectors fails due to `fatal runtime error: stack overflow`
237+
export RUST_MIN_STACK=104857600
238+
make test_rust

TestVectors/dafny/TestVectors/test/RunMain.dfy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module {:extern} TestWrappedESDKMain {
6060
)
6161
);
6262
print "ONLY WORRY IF THE ABOVE TESTS PASSED!!! THESE TESTS ARE SUPPOSED TO FAIL!\n";
63-
print "IF THE TESTS FAIL OTHER THAN A AES GCM TAG VALIDATION EXCEPTION, CUT AN ISSUE.\n";
63+
print "IF THE TESTS FAIL OTHER THAN A `AES GCM TAG VALIDATION EXCEPTION` or `AES Decrypt : gather Unspecified`, CUT AN ISSUE.\n";
6464
print "IF THE TESTS ALL FAIL IT MEANS THE TEST PASSED!";
6565
expect result.Failure?;
6666
}

0 commit comments

Comments
 (0)