Struct openssl::encrypt::Decrypter [−][src]
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]
T: HasPrivate,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,