Enum PrivateKeyDer

#[non_exhaustive]
pub enum PrivateKeyDer<'a>

A DER-encoded X.509 private key, in one of several formats

See variant inner types for more detailed information.

This can load several types of PEM-encoded private key, and then reveal which types were found:

# #[cfg(all(feature = "alloc", feature = "std"))] {
use rustls_pki_types::{PrivateKeyDer, pem::PemObject};

// load from a PEM file
let pkcs8 = PrivateKeyDer::from_pem_file("tests/data/nistp256key.pkcs8.pem").unwrap();
let pkcs1 = PrivateKeyDer::from_pem_file("tests/data/rsa1024.pkcs1.pem").unwrap();
let sec1 = PrivateKeyDer::from_pem_file("tests/data/nistp256key.pem").unwrap();
assert!(matches!(pkcs8, PrivateKeyDer::Pkcs8(_)));
assert!(matches!(pkcs1, PrivateKeyDer::Pkcs1(_)));
assert!(matches!(sec1, PrivateKeyDer::Sec1(_)));
# }

Variants

Pkcs1(PrivatePkcs1KeyDer<'a>)

An RSA private key

Sec1(PrivateSec1KeyDer<'a>)

A Sec1 private key

Pkcs8(PrivatePkcs8KeyDer<'a>)

A PKCS#8 private key

Implementations

impl PrivateKeyDer<'_>

fn clone_key(&self) -> PrivateKeyDer<'static>

Clone the private key to a 'static value

fn secret_der(&self) -> &[u8]

Yield the DER-encoded bytes of the private key

Trait Implementations

impl PemObject for PrivateKeyDer<'static>

fn from_pem(kind: SectionKind, value: Vec<u8>) -> Option<Self>

impl TryFrom<Vec<u8>> for PrivateKeyDer<'_>

type Error = &'static str;
fn try_from(key: Vec<u8>) -> Result<Self, Self::Error>

impl Zeroize for PrivateKeyDer<'static>

fn zeroize(&mut self)

impl<'a> Debug for PrivateKeyDer<'a>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<'a> Eq for PrivateKeyDer<'a>

impl<'a> From<PrivatePkcs1KeyDer<'a>> for PrivateKeyDer<'a>

fn from(key: PrivatePkcs1KeyDer<'a>) -> Self

impl<'a> From<PrivatePkcs8KeyDer<'a>> for PrivateKeyDer<'a>

fn from(key: PrivatePkcs8KeyDer<'a>) -> Self

impl<'a> From<PrivateSec1KeyDer<'a>> for PrivateKeyDer<'a>

fn from(key: PrivateSec1KeyDer<'a>) -> Self

impl<'a> PartialEq for PrivateKeyDer<'a>

fn eq(&self, other: &PrivateKeyDer<'a>) -> bool

impl<'a> StructuralPartialEq for PrivateKeyDer<'a>

impl<'a> TryFrom<&'a [u8]> for PrivateKeyDer<'a>

type Error = &'static str;
fn try_from(key: &'a [u8]) -> Result<Self, Self::Error>

Auto Trait Implementations

impl<'a> Freeze for PrivateKeyDer<'a>

impl<'a> RefUnwindSafe for PrivateKeyDer<'a>

impl<'a> Send for PrivateKeyDer<'a>

impl<'a> Sync for PrivateKeyDer<'a>

impl<'a> Unpin for PrivateKeyDer<'a>

impl<'a> UnsafeUnpin for PrivateKeyDer<'a>

impl<'a> UnwindSafe for PrivateKeyDer<'a>

Blanket Implementations

impl<T> Any for PrivateKeyDer<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for PrivateKeyDer<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for PrivateKeyDer<'a> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for PrivateKeyDer<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for PrivateKeyDer<'a> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for PrivateKeyDer<'a> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for PrivateKeyDer<'a> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>