pub struct PrivateKeyRef<'a> { /* private fields */ }Expand description
A borrowed private key reference. Zero-copy over input data.
Implementations§
Source§impl<'a> PrivateKeyRef<'a>
impl<'a> PrivateKeyRef<'a>
Sourcepub fn new(algorithm: Algorithm, bytes: &'a [u8]) -> Result<Self>
pub fn new(algorithm: Algorithm, bytes: &'a [u8]) -> Result<Self>
Creates a new PrivateKeyRef after validating key size.
Sourcepub fn from_pkcs8(der: &'a [u8]) -> Result<Self>
pub fn from_pkcs8(der: &'a [u8]) -> Result<Self>
Decode a PKCS8 DER-encoded private key (zero-copy).
Sourcepub fn encode_pkcs8_to(&self, out: &mut Vec<u8>)
pub fn encode_pkcs8_to(&self, out: &mut Vec<u8>)
Encode this private key as PKCS8 DER into the given buffer.
Sourcepub fn encode_der_to(&self, out: &mut Vec<u8>)
pub fn encode_der_to(&self, out: &mut Vec<u8>)
Encode this private key as DER into the given buffer (alias for encode_pkcs8_to).
Sourcepub fn to_pkcs8(&self) -> Zeroizing<Vec<u8>>
pub fn to_pkcs8(&self) -> Zeroizing<Vec<u8>>
Encode this private key as PKCS8 DER, returning a Zeroizing<Vec<u8>>.
The returned wrapper automatically zeroizes the DER bytes on drop.
Sourcepub fn to_der(&self) -> Zeroizing<Vec<u8>>
pub fn to_der(&self) -> Zeroizing<Vec<u8>>
Encode this private key as DER, returning a Zeroizing<Vec<u8>> (alias for to_pkcs8).
The returned wrapper automatically zeroizes the DER bytes on drop.
Sourcepub fn encode_pem_to(&self, out: &mut String)
pub fn encode_pem_to(&self, out: &mut String)
Encode this private key as PEM, appending directly to out.
Sourcepub fn to_pem(&self) -> Zeroizing<String>
pub fn to_pem(&self) -> Zeroizing<String>
Encode this private key as PEM, returning a Zeroizing<String>.
The returned wrapper automatically zeroizes the PEM string on drop.
Sourcepub fn to_owned(&self) -> PrivateKey
pub fn to_owned(&self) -> PrivateKey
Converts to an owned PrivateKey.
Trait Implementations§
Source§impl<'a> Clone for PrivateKeyRef<'a>
impl<'a> Clone for PrivateKeyRef<'a>
Source§fn clone(&self) -> PrivateKeyRef<'a>
fn clone(&self) -> PrivateKeyRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more