Struct openssl::encrypt::Decrypter[][src]

pub struct Decrypter<'a> { /* fields omitted */ }

A type which decrypts data.

Implementations

impl<'a> Decrypter<'a>[src]

pub fn new<T>(pkey: &'a PKeyRef<T>) -> Result<Decrypter<'a>, ErrorStack> where
    T: HasPrivate
[src]

Creates a new Decrypter.

OpenSSL documentation at EVP_PKEY_decrypt_init.

pub fn rsa_padding(&self) -> Result<Padding, ErrorStack>[src]

Returns the RSA padding mode in use.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_get_rsa_padding.

pub fn set_rsa_padding(&mut self, padding: Padding) -> Result<(), ErrorStack>[src]

Sets the RSA padding mode.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_padding.

pub fn set_rsa_mgf1_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack>[src]

Sets the RSA MGF1 algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_mgf1_md.

pub fn set_rsa_oaep_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack>[src]

Sets the RSA OAEP algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_oaep_md.

pub fn decrypt(&self, from: &[u8], to: &mut [u8]) -> Result<usize, ErrorStack>[src]

Performs public key decryption.

In order to know the size needed for the output buffer, use decrypt_len. Note that the length of the output buffer can be greater of the length of the decoded data.

let mut decrypter = Decrypter::new(&pkey).unwrap();
decrypter.set_rsa_padding(Padding::PKCS1).unwrap();

// Get the length of the output buffer
let buffer_len = decrypter.decrypt_len(&input).unwrap();
let mut decoded = vec![0u8; buffer_len];

// Decrypt the data and get its length
let decoded_len = decrypter.decrypt(&input, &mut decoded).unwrap();

// Use only the part of the buffer with the decrypted data
let decoded = &decoded[..decoded_len];

This corresponds to EVP_PKEY_decrypt.

pub fn decrypt_len(&self, from: &[u8]) -> Result<usize, ErrorStack>[src]

Gets the size of the buffer needed to decrypt the input data.

This corresponds to EVP_PKEY_decrypt called with a null pointer as output argument.

Trait Implementations

impl<'a> Drop for Decrypter<'a>[src]

impl<'a> Send for Decrypter<'a>[src]

impl<'a> Sync for Decrypter<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Decrypter<'a>

impl<'a> Unpin for Decrypter<'a>

impl<'a> UnwindSafe for Decrypter<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.