Skip to content

Commit a86cbb1

Browse files
committed
Enable test coverage with aws-lc-rs
When run with --feature aws_lc_rs but not --feature ring, use aws-lc-rs to run the same set of tests.
1 parent a864a5a commit a86cbb1

File tree

8 files changed

+35
-12
lines changed

8 files changed

+35
-12
lines changed

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::{issuer_params, 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)