From 6991b277071b2cb27f113eea54fc6c88c41b2856 Mon Sep 17 00:00:00 2001 From: Lukas Velikov Date: Sun, 5 May 2024 17:29:46 -0400 Subject: [PATCH 1/2] Add SubjectPublicKeyInfo DER newtype --- src/lib.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3600edd..ec92e6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -500,6 +500,45 @@ impl CertificateDer<'_> { } } +/// A DER-encoded SubjectPublicKeyInfo (SPKI), as specified in RFC 5280. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct SubjectPublicKeyInfo<'a>(Der<'a>); + +impl AsRef<[u8]> for SubjectPublicKeyInfo<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for SubjectPublicKeyInfo<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for SubjectPublicKeyInfo<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der::from(slice)) + } +} + +#[cfg(feature = "alloc")] +impl<'a> From> for SubjectPublicKeyInfo<'a> { + fn from(vec: Vec) -> Self { + Self(Der::from(vec)) + } +} + +impl SubjectPublicKeyInfo<'_> { + /// Converts this SubjectPublicKeyInfo into its owned variant, unfreezing borrowed content (if any) + #[cfg(feature = "alloc")] + pub fn into_owned(self) -> SubjectPublicKeyInfo<'static> { + SubjectPublicKeyInfo(Der(self.0 .0.into_owned())) + } +} + /// A TLS-encoded Encrypted Client Hello (ECH) configuration list (`ECHConfigList`); as specified in /// [draft-ietf-tls-esni-18 ยง4](https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-4) #[derive(Clone, Eq, PartialEq)] From 1d38558df581b73655ac70103ee42379ecfa4707 Mon Sep 17 00:00:00 2001 From: Lukas Velikov Date: Mon, 6 May 2024 10:17:24 -0400 Subject: [PATCH 2/2] Cargo: v1.5.0 -> v1.6.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 130a0f0..6a3894f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustls-pki-types" -version = "1.5.0" +version = "1.6.0" edition = "2021" rust-version = "1.60" license = "MIT OR Apache-2.0"