Struct bearssl::br_aead_class_
[−]
[src]
#[repr(C)]pub struct br_aead_class_ { pub tag_size: usize, pub reset: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void, _: usize)>, pub aad_inject: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void, _: usize)>, pub flip: Option<unsafe extern "C" fn(_: *mut *const br_aead_class)>, pub run: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: c_int, _: *mut c_void, _: usize)>, pub get_tag: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *mut c_void)>, pub check_tag: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void) -> u32>, }
Fields
tag_size: usize
\brief Size (in bytes) of authentication tags created by this AEAD algorithm.
reset: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void, _: usize)>
\brief Reset an AEAD context.
This function resets an already initialised AEAD context for a new computation run. Implementations and keys are conserved. This function can be called at any time; it cancels any ongoing AEAD computation that uses the provided context structure.
The provided IV is a nonce. Each AEAD algorithm has its own requirements on IV size and contents; for most of them, it is crucial to security that each nonce value is used only once for a given secret key.
\param cc AEAD context structure. \param iv AEAD nonce to use. \param len AEAD nonce length (in bytes).
aad_inject: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void, _: usize)>
\brief Inject additional authenticated data.
The provided data is injected into a running AEAD
computation. Additional data must be injected before the
call to flip()
. Additional data can be injected in several
chunks of arbitrary length.
\param cc AEAD context structure. \param data pointer to additional authenticated data. \param len length of additiona authenticated data (in bytes).
flip: Option<unsafe extern "C" fn(_: *mut *const br_aead_class)>
\brief Finish injection of additional authenticated data.
This function MUST be called before beginning the actual
encryption or decryption (with run()
), even if no
additional authenticated data was injected. No additional
authenticated data may be injected after this function call.
\param cc AEAD context structure.
run: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: c_int, _: *mut c_void, _: usize)>
\brief Encrypt or decrypt some data.
Data encryption or decryption can be done after flip()
has
been called on the context. If encrypt
is non-zero, then
the provided data shall be plaintext, and it is encrypted in
place. Otherwise, the data shall be ciphertext, and it is
decrypted in place.
Data may be provided in several chunks of arbitrary length.
\param cc AEAD context structure. \param encrypt non-zero for encryption, zero for decryption. \param data data to encrypt or decrypt. \param len data length (in bytes).
get_tag: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *mut c_void)>
\brief Compute authentication tag.
Compute the AEAD authentication tag. The tag length depends
on the AEAD algorithm; it is written in the provided tag
buffer. This call terminates the AEAD run: no data may be
processed with that AEAD context afterwards, until reset()
is called to initiate a new AEAD run.
The tag value must normally be sent along with the encrypted
data. When decrypting, the tag value must be recomputed and
compared with the received tag: if the two tag values differ,
then either the tag or the encrypted data was altered in
transit. As an alternative to this function, the
check_tag()
function may be used to compute and check the
tag value.
\param cc AEAD context structure. \param tag destination buffer for the tag.
check_tag: Option<unsafe extern "C" fn(_: *mut *const br_aead_class, _: *const c_void) -> u32>
\brief Compute and check authentication tag.
This function is an alternative to get_tag()
, and is
normally used on the receiving end (i.e. when decrypting
messages). The tag value is recomputed and compared with the
provided tag value. If they match, 1 is returned; on
mismatch, 0 is returned. A returned value of 0 means that the
data or the tag was altered in transit, normally leading to
wholesale rejection of the complete message.
\param cc AEAD context structure. \param tag tag value to compare with (16 bytes). \return 1 on success (exact match of tag value), 0 otherwise.
Trait Implementations
impl Debug for br_aead_class_
[src]
impl Copy for br_aead_class_
[src]
impl Clone for br_aead_class_
[src]
fn clone(&self) -> br_aead_class_
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more