PKey

Struct PKey 

Source
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>

Source

pub fn new(bit_length: u32) -> PKey<Private>

Source

pub fn wrap_private_key(pkey: PKey<Private>) -> PKey<Private>

Source

pub fn from_pem(pem: &[u8]) -> Result<PKey<Private>, PKeyError>

Source

pub fn private_key_to_pem(&self) -> Result<Vec<u8>, PKeyError>

Source

pub fn sign_sha1( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>

Signs the data using RSA-SHA1

Source

pub fn sign_sha256( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>

Signs the data using RSA-SHA256

Source

pub fn sign_sha256_pss( &self, data: &[u8], signature: &mut [u8], ) -> Result<usize, StatusCode>

Signs the data using RSA-SHA256-PSS

Source

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>

Source

pub fn wrap_public_key(pkey: PKey<Public>) -> PKey<Public>

Source

pub fn verify_sha1( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>

Verifies the data using RSA-SHA1

Source

pub fn verify_sha256( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>

Verifies the data using RSA-SHA256

Source

pub fn verify_sha256_pss( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatusCode>

Verifies the data using RSA-SHA256-PSS

Source

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<T> Debug for PKey<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl KeySize for PKey<Private>

Source§

fn bit_length(&self) -> usize

Length in bits

Source§

fn size(&self) -> usize

Source§

fn calculate_cipher_text_size( &self, data_size: usize, padding: RsaPadding, ) -> usize

Source§

fn plain_text_block_size(&self, padding: RsaPadding) -> usize

Source§

fn cipher_text_block_size(&self) -> usize

Source§

impl KeySize for PKey<Public>

Source§

fn bit_length(&self) -> usize

Length in bits

Source§

fn size(&self) -> usize

Source§

fn calculate_cipher_text_size( &self, data_size: usize, padding: RsaPadding, ) -> usize

Source§

fn plain_text_block_size(&self, padding: RsaPadding) -> usize

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.