Struct openssl::symm::Crypter
[−]
[src]
pub struct Crypter { /* fields omitted */ }
Represents a symmetric cipher context.
Methods
impl Crypter
[src]
fn new(t: Cipher,
mode: Mode,
key: &[u8],
iv: Option<&[u8]>)
-> Result<Crypter, ErrorStack>
mode: Mode,
key: &[u8],
iv: Option<&[u8]>)
-> Result<Crypter, ErrorStack>
fn pad(&mut self, padding: bool)
Enables or disables padding.
If padding is disabled, total amount of data encrypted/decrypted must be a multiple of the cipher's block size.
fn set_tag(&mut self, tag: &[u8]) -> Result<(), ErrorStack>
Sets the tag used to authenticate ciphertext in AEAD ciphers such as AES GCM.
When decrypting cipher text using an AEAD cipher, this must be called before finalize
.
fn aad_update(&mut self, input: &[u8]) -> Result<(), ErrorStack>
Feeds Additional Authenticated Data (AAD) through the cipher.
This can only be used with AEAD ciphers such as AES GCM. Data fed in is not encrypted, but
is factored into the authentication tag. It must be called before the first call to
update
.
fn update(&mut self,
input: &[u8],
output: &mut [u8])
-> Result<usize, ErrorStack>
input: &[u8],
output: &mut [u8])
-> Result<usize, ErrorStack>
Feeds data from input
through the cipher, writing encrypted/decrypted
bytes into output
.
The number of bytes written to output
is returned. Note that this may
not be equal to the length of input
.
Panics
Panics if output.len() < input.len() + block_size
where
block_size
is the block size of the cipher (see Cipher::block_size
),
or if output.len() > c_int::max_value()
.
fn finalize(&mut self, output: &mut [u8]) -> Result<usize, ErrorStack>
Finishes the encryption/decryption process, writing any remaining data
to output
.
The number of bytes written to output
is returned.
update
should not be called after this method.
Panics
Panics if output
is less than the cipher's block size.
fn get_tag(&self, tag: &mut [u8]) -> Result<(), ErrorStack>
Retrieves the authentication tag used to authenticate ciphertext in AEAD ciphers such as AES GCM.
When encrypting data with an AEAD cipher, this must be called after finalize
.
The size of the buffer indicates the required size of the tag. While some ciphers support a range of tag sizes, it is recommended to pick the maximum size. For AES GCM, this is 16 bytes, for example.