Skip to content

Commit bf20589

Browse files
committed
lib: rm alloc req. for dns_names and assoc types
With the update to the `dns_names` function in the previous commit we can now make `EndEntity.dns_names` work without requiring `alloc`. The associated `GeneralDnsNameRef` and `WildcardDnsNameRef` types get the same treatment.
1 parent 49e62bd commit bf20589

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

src/end_entity.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ use pki_types::{CertificateDer, SignatureVerificationAlgorithm, TrustAnchor, Uni
1616

1717
use crate::crl::RevocationOptions;
1818
use crate::error::Error;
19-
#[cfg(feature = "alloc")]
20-
use crate::subject_name::GeneralDnsNameRef;
21-
use crate::subject_name::{self, SubjectNameRef};
19+
use crate::subject_name::{self, GeneralDnsNameRef, SubjectNameRef};
2220
use crate::verify_cert::{self, KeyUsage};
2321
use crate::{cert, signed_data};
2422

@@ -156,7 +154,6 @@ impl<'a> EndEntityCert<'a> {
156154
/// This function must not be used to implement custom DNS name verification.
157155
/// Checking that a certificate is valid for a given subject name should always be done with
158156
/// [EndEntityCert::verify_is_valid_for_subject_name].
159-
#[cfg(feature = "alloc")]
160157
pub fn dns_names(&'a self) -> impl Iterator<Item = GeneralDnsNameRef<'a>> {
161158
subject_name::list_cert_dns_names(self)
162159
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub use {
7373
error::{DerTypeId, Error},
7474
signed_data::alg_id,
7575
subject_name::{
76-
AddrParseError, DnsNameRef, InvalidDnsNameError, InvalidSubjectNameError, IpAddrRef,
77-
SubjectNameRef,
76+
AddrParseError, DnsNameRef, GeneralDnsNameRef, InvalidDnsNameError,
77+
InvalidSubjectNameError, IpAddrRef, SubjectNameRef, WildcardDnsNameRef,
7878
},
7979
trust_anchor::extract_trust_anchor,
8080
verify_cert::KeyUsage,
@@ -85,7 +85,7 @@ pub use pki_types as types;
8585
#[cfg(feature = "alloc")]
8686
pub use {
8787
crl::{OwnedCertRevocationList, OwnedRevokedCert},
88-
subject_name::{DnsName, GeneralDnsNameRef, IpAddr, WildcardDnsNameRef},
88+
subject_name::{DnsName, IpAddr},
8989
};
9090

9191
#[cfg(feature = "ring")]

src/subject_name/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
mod dns_name;
16-
pub use dns_name::{DnsNameRef, InvalidDnsNameError};
16+
pub use dns_name::{DnsNameRef, GeneralDnsNameRef, InvalidDnsNameError, WildcardDnsNameRef};
1717

1818
#[cfg(feature = "alloc")]
19-
pub use dns_name::{DnsName, GeneralDnsNameRef, WildcardDnsNameRef};
19+
pub use dns_name::DnsName;
2020

2121
mod name;
2222
pub use name::{InvalidSubjectNameError, SubjectNameRef};
@@ -28,6 +28,6 @@ pub use ip_address::{AddrParseError, IpAddrRef};
2828
pub use ip_address::IpAddr;
2929

3030
mod verify;
31-
#[cfg(feature = "alloc")]
32-
pub(super) use verify::list_cert_dns_names;
33-
pub(super) use verify::{check_name_constraints, verify_cert_subject_name, GeneralName};
31+
pub(super) use verify::{
32+
check_name_constraints, list_cert_dns_names, verify_cert_subject_name, GeneralName,
33+
};

src/subject_name/verify.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +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 = "alloc")]
16-
use super::dns_name::GeneralDnsNameRef;
17-
use super::dns_name::{self, DnsNameRef};
15+
use super::dns_name::{self, DnsNameRef, GeneralDnsNameRef};
1816
use super::ip_address::{self, IpAddrRef};
1917
use super::name::SubjectNameRef;
2018
use crate::der::{self, FromDer};
@@ -314,7 +312,6 @@ impl<'a> Iterator for NameIterator<'a> {
314312
}
315313
}
316314

317-
#[cfg(feature = "alloc")]
318315
pub(crate) fn list_cert_dns_names<'names>(
319316
cert: &'names crate::EndEntityCert<'names>,
320317
) -> impl Iterator<Item = GeneralDnsNameRef<'names>> {

tests/integration.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ fn read_ee_with_large_pos_serial() {
255255
webpki::EndEntityCert::try_from(&ee).expect("should parse 20-octet positive serial number");
256256
}
257257

258-
#[cfg(feature = "alloc")]
259258
#[test]
260259
fn list_netflix_names() {
261260
expect_cert_dns_names(
@@ -277,7 +276,6 @@ fn list_netflix_names() {
277276
);
278277
}
279278

280-
#[cfg(feature = "alloc")]
281279
#[test]
282280
fn invalid_subject_alt_names() {
283281
expect_cert_dns_names(
@@ -301,7 +299,6 @@ fn invalid_subject_alt_names() {
301299
);
302300
}
303301

304-
#[cfg(feature = "alloc")]
305302
#[test]
306303
fn wildcard_subject_alternative_names() {
307304
expect_cert_dns_names(
@@ -325,13 +322,11 @@ fn wildcard_subject_alternative_names() {
325322
);
326323
}
327324

328-
#[cfg(feature = "alloc")]
329325
#[test]
330326
fn no_subject_alt_names() {
331327
expect_cert_dns_names(include_bytes!("misc/no_subject_alternative_name.der"), [])
332328
}
333329

334-
#[cfg(feature = "alloc")]
335330
fn expect_cert_dns_names<'name>(
336331
cert_der: &[u8],
337332
expected_names: impl IntoIterator<Item = &'name str>,

0 commit comments

Comments
 (0)