pub struct PKey<T> { /* private fields */ }Expand description
This is a wrapper around an asymmetric key pair. Since the PKey is either a public or private key so we have to differentiate that as well.
Implementations§
Source§impl PKey<RsaPrivateKey>
impl PKey<RsaPrivateKey>
Sourcepub fn new(bit_length: u32) -> Result<PrivateKey, Error>
pub fn new(bit_length: u32) -> Result<PrivateKey, Error>
Generate a new private key with the given length in bits.
Sourcepub fn read_pem_file(path: &Path) -> Result<PrivateKey, PKeyError>
pub fn read_pem_file(path: &Path) -> Result<PrivateKey, PKeyError>
Read a private key from the given path.
Sourcepub fn from_pem(bytes: &[u8]) -> Result<PrivateKey, PKeyError>
pub fn from_pem(bytes: &[u8]) -> Result<PrivateKey, PKeyError>
Create a private key from a pem file loaded into a byte array.
Sourcepub fn to_der(&self) -> Result<SecretDocument>
pub fn to_der(&self) -> Result<SecretDocument>
Serialize the private key to a der file.
Sourcepub fn public_key_to_info(&self) -> Result<SubjectPublicKeyInfoOwned>
pub fn public_key_to_info(&self) -> Result<SubjectPublicKeyInfoOwned>
Get the public key info for this private key.
Sourcepub fn to_public_key(&self) -> PublicKey
pub fn to_public_key(&self) -> PublicKey
Create a public key based on this private key.
Sourcepub fn sign_sha1(
&self,
data: &[u8],
signature: &mut [u8],
) -> Result<usize, Error>
pub fn sign_sha1( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, Error>
Signs the data using RSA-SHA1
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PKey<T>where
T: Freeze,
impl<T> RefUnwindSafe for PKey<T>where
T: RefUnwindSafe,
impl<T> Send for PKey<T>where
T: Send,
impl<T> Sync for PKey<T>where
T: Sync,
impl<T> Unpin for PKey<T>where
T: Unpin,
impl<T> UnsafeUnpin for PKey<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for PKey<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more