Enum PrivateKeyDer

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: &Self) -> PrivateKeyDer<'static>

Clone the private key to a 'static value

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

Yield the DER-encoded bytes of the private key

impl PemObject for PrivateKeyDer<'static>

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

impl TryFrom for PrivateKeyDer<'_>

fn try_from(key: Vec<u8>) -> Result<Self, <Self as >::Error>

impl Zeroize for PrivateKeyDer<'static>

fn zeroize(self: &mut Self)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<'a> TryFrom for PrivateKeyDer<'a>

fn try_from(key: &'a [u8]) -> Result<Self, <Self as >::Error>

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

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

impl<T> Any for PrivateKeyDer<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PrivateKeyDer<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for PrivateKeyDer<'a>

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

impl<T> From for PrivateKeyDer<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for PrivateKeyDer<'a>

fn into(self: 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 for PrivateKeyDer<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for PrivateKeyDer<'a>

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