Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CRL ergonomics, replace trait with enum #203

Merged
merged 7 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ license = "ISC"
name = "rustls-webpki"
readme = "README.md"
repository = "https:/rustls/webpki"
version = "0.102.0-alpha.5"
version = "0.102.0-alpha.6"

include = [
"Cargo.toml",
Expand Down
50 changes: 19 additions & 31 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{ErrorKind, Read, Write};
use std::path::Path;
use std::sync::Mutex;

use webpki::{BorrowedCertRevocationList, CertRevocationList};
use webpki::{BorrowedCertRevocationList, CertRevocationList, OwnedCertRevocationList};

/// Lazy initialized CRL issuer to be used when generating CRL data. Includes
/// `KeyUsagePurpose::CrlSign` key usage bit.
Expand Down Expand Up @@ -104,12 +104,7 @@ fn bench_parse_borrowed_crl_small(c: &mut Bencher) {
fn bench_parse_owned_crl_small(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/small.crl.der", SMALL_CRL_CERT_COUNT);

c.iter(|| {
BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap()
});
c.iter(|| OwnedCertRevocationList::from_der(&crl_bytes).unwrap());
}

/// Benchmark parsing a medium CRL file into a borrowed representation..
Expand All @@ -123,12 +118,7 @@ fn bench_parse_borrowed_crl_medium(c: &mut Bencher) {
fn bench_parse_owned_crl_medium(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/medium.crl.der", MEDIUM_CRL_CERT_COUNT);

c.iter(|| {
BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap()
});
c.iter(|| OwnedCertRevocationList::from_der(&crl_bytes).unwrap());
}

/// Benchmark parsing a large CRL file into a borrowed representation..
Expand All @@ -142,19 +132,16 @@ fn bench_parse_borrowed_crl_large(c: &mut Bencher) {
fn bench_parse_owned_crl_large(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/large.crl.der", LARGE_CRL_CERT_COUNT);

c.iter(|| {
BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap()
});
c.iter(|| BorrowedCertRevocationList::from_der(&crl_bytes).unwrap());
}

/// Benchmark searching a small CRL file in borrowed representation for a serial that does not
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_borrowed_crl_small(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/small.crl.der", SMALL_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes).unwrap();
let crl: CertRevocationList = BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand All @@ -163,10 +150,9 @@ fn bench_search_borrowed_crl_small(c: &mut Bencher) {
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_owned_crl_small(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/small.crl.der", SMALL_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes)
let crl: CertRevocationList = OwnedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap();
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand All @@ -175,7 +161,9 @@ fn bench_search_owned_crl_small(c: &mut Bencher) {
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_borrowed_crl_medium(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/medium.crl.der", MEDIUM_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes).unwrap();
let crl: CertRevocationList = BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand All @@ -184,10 +172,9 @@ fn bench_search_borrowed_crl_medium(c: &mut Bencher) {
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_owned_crl_medium(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/medium.crl.der", MEDIUM_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes)
let crl: CertRevocationList = OwnedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap();
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand All @@ -196,7 +183,9 @@ fn bench_search_owned_crl_medium(c: &mut Bencher) {
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_borrowed_crl_large(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/large.crl.der", LARGE_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes).unwrap();
let crl: CertRevocationList = BorrowedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand All @@ -205,10 +194,9 @@ fn bench_search_borrowed_crl_large(c: &mut Bencher) {
/// appear. Doesn't include the time it takes to parse the CRL in the benchmark task.
fn bench_search_owned_crl_large(c: &mut Bencher) {
let crl_bytes = load_or_generate("./benches/large.crl.der", LARGE_CRL_CERT_COUNT);
let crl = BorrowedCertRevocationList::from_der(&crl_bytes)
let crl: CertRevocationList = OwnedCertRevocationList::from_der(&crl_bytes)
.unwrap()
.to_owned()
.unwrap();
.into();

c.iter(|| black_box(assert!(matches!(crl.find_serial(FAKE_SERIAL), Ok(None)))));
}
Expand Down
Loading