Skip to content

Commit 28ff3b3

Browse files
committed
Move verification tests into a separate crate
1 parent cfe8b2e commit 28ff3b3

File tree

9 files changed

+60
-35
lines changed

9 files changed

+60
-35
lines changed

Cargo.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["rcgen", "rustls-cert-gen"]
2+
members = ["verify-tests", "rcgen", "rustls-cert-gen"]
33
resolver = "2"
44

55
[workspace.package]

rcgen/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ x509-parser = { workspace = true, features = ["verify"], optional = true }
2727
yasna = { workspace = true }
2828
zeroize = { workspace = true, optional = true }
2929

30-
[dev-dependencies]
31-
botan = { workspace = true }
32-
pki-types = { workspace = true }
33-
ring = { workspace = true }
34-
rustls-webpki = { workspace = true }
35-
x509-parser = { workspace = true, features = ["verify"] }
36-
3730
[target."cfg(unix)".dev-dependencies]
3831
openssl = { workspace = true }
3932

verify-tests/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "verify-tests"
3+
version = "0.0.1"
4+
edition = { workspace = true }
5+
publish = false
6+
7+
[features]
8+
default = []
9+
aws_lc_rs = ["rcgen/aws_lc_rs"]
10+
fips = ["rcgen/fips"]
11+
pem = ["dep:pem", "rcgen/pem"]
12+
ring = ["rcgen/ring"]
13+
x509-parser = ["dep:x509-parser", "rcgen/x509-parser"]
14+
15+
[dependencies]
16+
aws-lc-rs = { workspace = true, optional = true }
17+
pem = { workspace = true, optional = true }
18+
rcgen = { path = "../rcgen", features = ["pem", "x509-parser"] }
19+
ring = { workspace = true }
20+
time = { workspace = true }
21+
x509-parser = { workspace = true, features = ["verify"], optional = true }
22+
yasna = { workspace = true }
23+
24+
[dev-dependencies]
25+
pki-types = { workspace = true }
26+
rustls-webpki = { workspace = true }
27+
botan = { workspace = true }
28+
ring = { workspace = true }
29+
30+
[target."cfg(unix)".dev-dependencies]
31+
openssl = { workspace = true }

rcgen/tests/util.rs renamed to verify-tests/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(feature = "crypto")]
2-
31
use time::{Duration, OffsetDateTime};
42

53
use rcgen::{BasicConstraints, Certificate, CertificateParams, Issuer, KeyPair};
@@ -13,7 +11,6 @@ use rcgen::{KeyUsagePurpose, RevocationReason, RevokedCertParams, SerialNumber};
1311
// to the test_webpki_25519 test and panicing explicitly.
1412
// This is a "v2" key containing the public key as well as the
1513
// private one.
16-
#[allow(unused)]
1714
pub const ED25519_TEST_KEY_PAIR_PEM_V2: &str = r#"
1815
-----BEGIN PRIVATE KEY-----
1916
MFMCAQEwBQYDK2VwBCIEIC2pHJYjFHhK8V7mj6BnHWUVMS4CRolUlDdRXKCtguDu
@@ -23,7 +20,6 @@ oSMDIQDrvH/x8Nx9untsuc6ET+ce3w7PSuLY8BLWcHdXDGvkQA==
2320
// Generated with `openssl genpkey -algorithm ED25519`
2421
// A "v1" key as it doesn't contain the public key (which can be
2522
// derived from the private one)
26-
#[allow(unused)]
2723
pub const ED25519_TEST_KEY_PAIR_PEM_V1: &str = r#"
2824
-----BEGIN PRIVATE KEY-----
2925
MC4CAQAwBQYDK2VwBCIEIDSat0MacDt2fokpnzuBaXvAQR6RJGS9rgIYOU2mZKld
@@ -36,8 +32,6 @@ Generated by: openssl genpkey -algorithm RSA \
3632
-pkeyopt rsa_keygen_pubexp:65537 | \
3733
openssl pkcs8 -topk8 -nocrypt -outform pem
3834
*/
39-
#[allow(dead_code)] // Used in some but not all test compilation units.
40-
#[cfg(feature = "pem")]
4135
pub const RSA_TEST_KEY_PAIR_PEM: &str = r#"
4236
-----BEGIN PRIVATE KEY-----
4337
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDYjmgyV3/LSizJ

rcgen/tests/botan.rs renamed to verify-tests/tests/botan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(feature = "crypto", feature = "x509-parser"))]
1+
#![cfg(feature = "x509-parser")]
22

33
use time::{Duration, OffsetDateTime};
44

@@ -7,7 +7,7 @@ use rcgen::{CertificateRevocationListParams, RevocationReason, RevokedCertParams
77
use rcgen::{DnValue, KeyPair};
88
use rcgen::{KeyUsagePurpose, SerialNumber};
99

10-
mod util;
10+
use verify_tests as util;
1111

1212
fn default_params() -> (CertificateParams, KeyPair) {
1313
let (mut params, key_pair) = util::default_params();

rcgen/tests/generic.rs renamed to verify-tests/tests/generic.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#![cfg(feature = "crypto")]
2-
3-
mod util;
4-
51
#[cfg(feature = "pem")]
62
mod test_key_params_mismatch {
73
use std::collections::hash_map::DefaultHasher;
@@ -40,9 +36,8 @@ mod test_key_params_mismatch {
4036

4137
#[cfg(feature = "x509-parser")]
4238
mod test_x509_custom_ext {
43-
use crate::util;
44-
4539
use rcgen::CustomExtension;
40+
use verify_tests as util;
4641
use x509_parser::oid_registry::asn1_rs;
4742
use x509_parser::prelude::{
4843
FromDer, ParsedCriAttribute, X509Certificate, X509CertificationRequest,
@@ -166,7 +161,7 @@ mod test_csr_custom_attributes {
166161

167162
#[cfg(feature = "x509-parser")]
168163
mod test_x509_parser_crl {
169-
use crate::util;
164+
use verify_tests as util;
170165
use x509_parser::extensions::{DistributionPointName, ParsedExtension};
171166
use x509_parser::num_bigint::BigUint;
172167
use x509_parser::prelude::{FromDer, GeneralName, IssuingDistributionPoint, X509Certificate};
@@ -248,7 +243,7 @@ mod test_x509_parser_crl {
248243

249244
#[cfg(feature = "x509-parser")]
250245
mod test_parse_crl_dps {
251-
use crate::util;
246+
use verify_tests as util;
252247
use x509_parser::extensions::{DistributionPointName, ParsedExtension};
253248

254249
#[test]
@@ -425,12 +420,11 @@ mod test_csr {
425420

426421
#[cfg(feature = "x509-parser")]
427422
mod test_subject_alternative_name_criticality {
423+
use verify_tests::default_params;
428424
use x509_parser::certificate::X509Certificate;
429425
use x509_parser::extensions::X509Extension;
430426
use x509_parser::{oid_registry, parse_x509_certificate};
431427

432-
use crate::util::default_params;
433-
434428
#[test]
435429
fn with_subject_sans_not_critical() {
436430
let (params, keypair) = default_params();

rcgen/tests/openssl.rs renamed to verify-tests/tests/openssl.rs

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

33
use std::cell::RefCell;
44
use std::io::{Error, ErrorKind, Read, Result as ioResult, Write};
@@ -16,8 +16,7 @@ use rcgen::{
1616
BasicConstraints, Certificate, CertificateParams, DnType, DnValue, GeneralSubtree, IsCa,
1717
Issuer, KeyPair, NameConstraints,
1818
};
19-
20-
mod util;
19+
use verify_tests as util;
2120

2221
fn verify_cert_basic(cert: &Certificate) {
2322
let cert_pem = cert.pem();
@@ -502,7 +501,7 @@ fn test_openssl_crl_dps_parse() {
502501
}
503502

504503
#[test]
505-
#[cfg(all(feature = "crypto", feature = "aws_lc_rs"))]
504+
#[cfg(feature = "aws_lc_rs")]
506505
fn test_openssl_pkcs1_and_sec1_keys() {
507506
use openssl::ec::{EcGroup, EcKey};
508507
use openssl::nid::Nid;

rcgen/tests/webpki.rs renamed to verify-tests/tests/webpki.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(feature = "crypto")]
2-
31
use std::time::Duration as StdDuration;
42

53
use pki_types::{CertificateDer, ServerName, SignatureVerificationAlgorithm, UnixTime};
@@ -22,7 +20,7 @@ use rcgen::{CertificateRevocationListParams, RevocationReason, RevokedCertParams
2220
use rcgen::{CertificateSigningRequestParams, DnValue};
2321
use rcgen::{ExtendedKeyUsagePurpose, KeyUsagePurpose, SerialNumber};
2422

25-
mod util;
23+
use verify_tests as util;
2624

2725
fn sign_msg_ecdsa(key_pair: &KeyPair, msg: &[u8], alg: &'static EcdsaSigningAlgorithm) -> Vec<u8> {
2826
let pk_der = key_pair.serialize_der();
@@ -52,6 +50,7 @@ fn sign_msg_rsa(key_pair: &KeyPair, msg: &[u8], encoding: &'static dyn RsaEncodi
5250
signature
5351
}
5452

53+
#[cfg_attr(not(feature = "pem"), allow(unused))]
5554
fn check_cert<'a, 'b, S: SigningKey + 'a>(
5655
cert_der: &CertificateDer<'_>,
5756
cert: &'a Certificate,

0 commit comments

Comments
 (0)