pub struct PKey<T> { /* private fields */ }Expand description
This is a wrapper around an OpenSSL asymmetric key pair. Since openssl 0.10, the PKey is either
a public or private key so we have to differentiate that as well.
Implementations§
Source§impl PKey<Private>
impl PKey<Private>
pub fn new(bit_length: u32) -> PKey<Private>
pub fn wrap_private_key(pkey: PKey<Private>) -> PKey<Private>
pub fn from_pem(pem: &[u8]) -> Result<PKey<Private>, PKeyError>
pub fn private_key_to_pem(&self) -> Result<Vec<u8>, PKeyError>
Sourcepub fn sign_sha1(
&self,
data: &[u8],
signature: &mut [u8],
) -> Result<usize, StatusCode>
pub fn sign_sha1( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>
Signs the data using RSA-SHA1
Sourcepub fn sign_sha256(
&self,
data: &[u8],
signature: &mut [u8],
) -> Result<usize, StatusCode>
pub fn sign_sha256( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>
Signs the data using RSA-SHA256
Sourcepub fn sign_sha256_pss(
&self,
data: &[u8],
signature: &mut [u8],
) -> Result<usize, StatusCode>
pub fn sign_sha256_pss( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>
Signs the data using RSA-SHA256-PSS
Sourcepub fn private_decrypt(
&self,
src: &[u8],
dst: &mut [u8],
padding: RsaPadding,
) -> Result<usize, PKeyError>
pub fn private_decrypt( &self, src: &[u8], dst: &mut [u8], padding: RsaPadding, ) -> Result<usize, PKeyError>
Decrypts data in src to dst using the specified padding and returning the size of the decrypted data in bytes or an error.
Source§impl PKey<Public>
impl PKey<Public>
pub fn wrap_public_key(pkey: PKey<Public>) -> PKey<Public>
Sourcepub fn verify_sha1(
&self,
data: &[u8],
signature: &[u8],
) -> Result<bool, StatusCode>
pub fn verify_sha1( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>
Verifies the data using RSA-SHA1
Sourcepub fn verify_sha256(
&self,
data: &[u8],
signature: &[u8],
) -> Result<bool, StatusCode>
pub fn verify_sha256( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>
Verifies the data using RSA-SHA256
Sourcepub fn verify_sha256_pss(
&self,
data: &[u8],
signature: &[u8],
) -> Result<bool, StatusCode>
pub fn verify_sha256_pss( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>
Verifies the data using RSA-SHA256-PSS
Sourcepub fn public_encrypt(
&self,
src: &[u8],
dst: &mut [u8],
padding: RsaPadding,
) -> Result<usize, PKeyError>
pub fn public_encrypt( &self, src: &[u8], dst: &mut [u8], padding: RsaPadding, ) -> Result<usize, PKeyError>
Encrypts data from src to dst using the specified padding and returns the size of encrypted data in bytes or an error.
Trait Implementations§
Source§impl KeySize for PKey<Private>
impl KeySize for PKey<Private>
Source§fn bit_length(&self) -> usize
fn bit_length(&self) -> usize
Length in bits
fn size(&self) -> usize
fn calculate_cipher_text_size( &self, data_size: usize, padding: RsaPadding, ) -> usize
fn plain_text_block_size(&self, padding: RsaPadding) -> usize
fn cipher_text_block_size(&self) -> usize
Source§impl KeySize for PKey<Public>
impl KeySize for PKey<Public>
Source§fn bit_length(&self) -> usize
fn bit_length(&self) -> usize
Length in bits
fn size(&self) -> usize
fn calculate_cipher_text_size( &self, data_size: usize, padding: RsaPadding, ) -> usize
fn plain_text_block_size(&self, padding: RsaPadding) -> usize
fn cipher_text_block_size(&self) -> usize
Auto Trait Implementations§
impl<T> Freeze for PKey<T>
impl<T> RefUnwindSafe for PKey<T>where
T: RefUnwindSafe,
impl<T> Send for PKey<T>
impl<T> Sync for PKey<T>
impl<T> Unpin for PKey<T>where
T: Unpin,
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