Skip to content

Commit 9759e1a

Browse files
committed
Ensure cargo test passes with aws-lc-rs alone
Ensure `cargo package` works with --all-features, otherwise optional modules could be missing from the list in Cargo.toml!
1 parent 85d39bc commit 9759e1a

File tree

5 files changed

+57
-9
lines changed

5 files changed

+57
-9
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
- name: Install rust toolchain
100100
uses: dtolnay/rust-toolchain@stable
101101

102-
- run: cargo package
102+
- run: cargo package --all-features
103103

104104
test:
105105
name: Build+test
@@ -111,6 +111,7 @@ jobs:
111111
- --features=alloc
112112
- --all-features
113113
- --no-default-features
114+
- --no-default-features --features alloc,std,aws_lc_rs
114115

115116
mode:
116117
- # debug
@@ -125,6 +126,7 @@ jobs:
125126
- features: # Default
126127
- features: --features=alloc
127128
- features: --no-default-features
129+
- features: --no-default-features --features alloc,std,aws_lc_rs
128130
- features: --all-features
129131
mode: --release
130132
- features: --all-features
@@ -179,6 +181,23 @@ jobs:
179181
mode: # debug
180182
rust_channel: stable
181183
host_os: ubuntu-latest
184+
185+
# check aws-lc-rs alone
186+
- features: --no-default-features --features alloc,std,aws_lc_rs
187+
mode: # debug
188+
rust_channel: stable
189+
host_os: macos-latest
190+
191+
- features: --no-default-features --features alloc,std,aws_lc_rs
192+
mode: # debug
193+
rust_channel: stable
194+
host_os: windows-latest
195+
196+
- features: --no-default-features --features alloc,std,aws_lc_rs
197+
mode: # debug
198+
rust_channel: stable
199+
host_os: ubuntu-latest
200+
182201
steps:
183202
- name: Checkout sources
184203
uses: actions/checkout@v4
@@ -190,6 +209,10 @@ jobs:
190209
with:
191210
toolchain: ${{ matrix.rust_channel }}
192211

212+
- name: Install NASM for aws-lc-rs on Windows
213+
if: runner.os == 'Windows'
214+
uses: ilammy/setup-nasm@v1
215+
193216
- name: cargo test (${{ matrix.mode }}, ${{ matrix.features }})
194217
run: cargo test -vv ${{ matrix.features }} ${{ matrix.mode }} -- --ignored
195218
env:

tests/better_tls.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(feature = "ring")]
1+
#![cfg(any(feature = "ring", feature = "aws_lc_rs"))]
22

33
use core::time::Duration;
44
use std::collections::HashMap;
@@ -9,9 +9,17 @@ use bzip2::read::BzDecoder;
99
use pki_types::UnixTime;
1010
use serde::Deserialize;
1111

12-
use webpki::types::{CertificateDer, TrustAnchor};
12+
use webpki::types::{CertificateDer, SignatureVerificationAlgorithm, TrustAnchor};
1313
use webpki::{extract_trust_anchor, KeyUsage, SubjectNameRef};
1414

15+
// All of the BetterTLS testcases use P256 keys.
16+
static ALGS: &[&dyn SignatureVerificationAlgorithm] = &[
17+
#[cfg(feature = "ring")]
18+
webpki::ring::ECDSA_P256_SHA256,
19+
#[cfg(feature = "aws_lc_rs")]
20+
webpki::aws_lc_rs::ECDSA_P256_SHA256,
21+
];
22+
1523
#[ignore] // Runs slower than other unit tests - opt-in with `cargo test -- --ignored`
1624
#[test]
1725
fn path_building() {
@@ -69,7 +77,7 @@ fn run_testsuite(suite_name: &str, suite: &BetterTlsSuite, roots: &[TrustAnchor]
6977

7078
let result = ee_cert
7179
.verify_for_usage(
72-
&[webpki::ring::ECDSA_P256_SHA256], // All of the BetterTLS testcases use P256 keys.
80+
ALGS,
7381
roots,
7482
intermediates,
7583
now,

tests/client_auth_revocation.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@
1212
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

15-
#![cfg(feature = "ring")]
15+
#![cfg(any(feature = "ring", feature = "aws_lc_rs"))]
1616

1717
use core::time::Duration;
1818

19-
use pki_types::{CertificateDer, UnixTime};
19+
use pki_types::{CertificateDer, SignatureVerificationAlgorithm, UnixTime};
2020
use webpki::{
2121
extract_trust_anchor, KeyUsage, RevocationCheckDepth, RevocationOptions,
2222
RevocationOptionsBuilder,
2323
};
2424

25+
static ALGS: &[&dyn SignatureVerificationAlgorithm] = &[
26+
#[cfg(feature = "ring")]
27+
webpki::ring::ECDSA_P256_SHA256,
28+
#[cfg(feature = "aws_lc_rs")]
29+
webpki::aws_lc_rs::ECDSA_P256_SHA256,
30+
];
31+
2532
fn check_cert(
2633
ee: &[u8],
2734
intermediates: &[&[u8]],
@@ -39,7 +46,7 @@ fn check_cert(
3946
.collect::<Vec<_>>();
4047

4148
cert.verify_for_usage(
42-
&[webpki::ring::ECDSA_P256_SHA256],
49+
ALGS,
4350
anchors,
4451
&intermediates,
4552
time,

tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

15-
#![cfg(feature = "ring")]
15+
#![cfg(any(feature = "ring", feature = "aws_lc_rs"))]
1616

1717
use core::time::Duration;
1818

tests/signatures.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

15-
#![cfg(feature = "ring")]
15+
#![cfg(any(feature = "ring", feature = "aws_lc_rs"))]
1616

1717
use pki_types::{CertificateDer, SignatureVerificationAlgorithm};
18+
19+
#[cfg(feature = "ring")]
1820
use webpki::ring::{
1921
ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P384_SHA256, ECDSA_P384_SHA384, ED25519,
2022
};
@@ -25,6 +27,14 @@ use webpki::ring::{
2527
RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
2628
};
2729

30+
#[cfg(all(not(feature = "ring"), feature = "aws_lc_rs"))]
31+
use webpki::aws_lc_rs::{
32+
ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P384_SHA256, ECDSA_P384_SHA384, ED25519,
33+
RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_2048_8192_SHA384, RSA_PKCS1_2048_8192_SHA512,
34+
RSA_PKCS1_3072_8192_SHA384, RSA_PSS_2048_8192_SHA256_LEGACY_KEY,
35+
RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
36+
};
37+
2838
#[cfg(feature = "alloc")]
2939
fn check_sig(
3040
ee: &[u8],

0 commit comments

Comments
 (0)