Struct openssl::encrypt::Encrypter [−][src]
A type which encrypts data.
Implementations
impl<'a> Encrypter<'a>
[src]
pub fn new<T>(pkey: &'a PKeyRef<T>) -> Result<Encrypter<'a>, ErrorStack> where
T: HasPublic,
[src]
T: HasPublic,
Creates a new Encrypter
.
OpenSSL documentation at EVP_PKEY_encrypt_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 set_rsa_oaep_label(&mut self, label: &[u8]) -> Result<(), ErrorStack>
[src]
Sets the RSA OAEP label.
This is only useful for RSA keys.
This corresponds to EVP_PKEY_CTX_set0_rsa_oaep_label
.
pub fn encrypt(&self, from: &[u8], to: &mut [u8]) -> Result<usize, ErrorStack>
[src]
Performs public key encryption.
In order to know the size needed for the output buffer, use encrypt_len
.
Note that the length of the output buffer can be greater of the length of the encoded data.
let mut encrypter = Encrypter::new(&pkey).unwrap(); encrypter.set_rsa_padding(Padding::PKCS1).unwrap(); // Get the length of the output buffer let buffer_len = encrypter.encrypt_len(&input).unwrap(); let mut encoded = vec![0u8; buffer_len]; // Encode the data and get its length let encoded_len = encrypter.encrypt(&input, &mut encoded).unwrap(); // Use only the part of the buffer with the encoded data let encoded = &encoded[..encoded_len];
This corresponds to EVP_PKEY_encrypt
.
pub fn encrypt_len(&self, from: &[u8]) -> Result<usize, ErrorStack>
[src]
Gets the size of the buffer needed to encrypt the input data.
This corresponds to EVP_PKEY_encrypt
called with a null pointer as output argument.
Trait Implementations
impl<'a> Drop for Encrypter<'a>
[src]
impl<'a> Send for Encrypter<'a>
[src]
impl<'a> Sync for Encrypter<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Encrypter<'a>
impl<'a> Unpin for Encrypter<'a>
impl<'a> UnwindSafe for Encrypter<'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>,