Skip to content

Commit de84af0

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 fb888f5 commit de84af0

File tree

9 files changed

+59
-13
lines changed

9 files changed

+59
-13
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
@@ -126,6 +127,7 @@ jobs:
126127
- features: --features=alloc
127128
- features: --no-default-features
128129
- features: --no-default-features --features alloc,std
130+
- features: --no-default-features --features alloc,std,aws_lc_rs
129131
- features: --all-features
130132
mode: --release
131133
- features: --all-features
@@ -185,6 +187,23 @@ jobs:
185187
mode: # debug
186188
rust_channel: stable
187189
host_os: ubuntu-latest
190+
191+
# check aws-lc-rs alone
192+
- features: --no-default-features --features alloc,std,aws_lc_rs
193+
mode: # debug
194+
rust_channel: stable
195+
host_os: macos-latest
196+
197+
- features: --no-default-features --features alloc,std,aws_lc_rs
198+
mode: # debug
199+
rust_channel: stable
200+
host_os: windows-latest
201+
202+
- features: --no-default-features --features alloc,std,aws_lc_rs
203+
mode: # debug
204+
rust_channel: stable
205+
host_os: ubuntu-latest
206+
188207
steps:
189208
- name: Checkout sources
190209
uses: actions/checkout@v4
@@ -196,6 +215,10 @@ jobs:
196215
with:
197216
toolchain: ${{ matrix.rust_channel }}
198217

218+
- name: Install NASM for aws-lc-rs on Windows
219+
if: runner.os == 'Windows'
220+
uses: ilammy/setup-nasm@v1
221+
199222
- name: cargo test (${{ matrix.mode }}, ${{ matrix.features }})
200223
run: cargo test -vv ${{ matrix.features }} ${{ matrix.mode }} -- --ignored
201224
env:

src/verify_cert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ enum Role {
495495
EndEntity,
496496
}
497497

498-
#[cfg(all(test, feature = "alloc", feature = "ring"))]
498+
#[cfg(all(test, feature = "alloc", any(feature = "ring", feature = "aws_lc_rs")))]
499499
mod tests {
500500
use super::*;
501501
use crate::test_utils::{make_end_entity, make_issuer};

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.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(all(feature = "alloc", feature = "ring"))]
15+
#![cfg(all(feature = "alloc", any(feature = "ring", feature = "aws_lc_rs")))]
1616

1717
use core::time::Duration;
1818
use pki_types::{CertificateDer, UnixTime};

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/custom_ekus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(feature = "alloc", feature = "ring"))]
1+
#![cfg(all(feature = "alloc", any(feature = "ring", feature = "aws_lc_rs")))]
22

33
use core::time::Duration;
44

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: 9 additions & 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 pki_types::{CertificateDer, SignatureVerificationAlgorithm};
1818
#[cfg(feature = "ring")]
@@ -26,6 +26,14 @@ use webpki::ring::{
2626
RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
2727
};
2828

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

tests/tls_server_certs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1212
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14-
#![cfg(all(feature = "alloc", feature = "ring"))]
14+
#![cfg(all(feature = "alloc", any(feature = "ring", feature = "aws_lc_rs")))]
1515

1616
use core::time::Duration;
1717

0 commit comments

Comments
 (0)