# 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]

#### `fn drop(&mut self)` [src]

Executes the destructor for this type. Read more

### `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]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

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

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

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

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

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

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

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

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `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.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `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.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.