Struct openssl::encrypt::Encrypter[][src]

pub struct Encrypter<'a> { /* fields omitted */ }
Expand description

A type which encrypts data.

Implementations

Creates a new Encrypter.

OpenSSL documentation at EVP_PKEY_encrypt_init.

Returns the RSA padding mode in use.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_get_rsa_padding.

Sets the RSA padding mode.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_padding.

Sets the RSA MGF1 algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_mgf1_md.

Sets the RSA OAEP algorithm.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set_rsa_oaep_md.

Sets the RSA OAEP label.

This is only useful for RSA keys.

This corresponds to EVP_PKEY_CTX_set0_rsa_oaep_label.

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.

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

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.