Struct bearssl::br_hash_class_
[−]
[src]
#[repr(C)]pub struct br_hash_class_ { pub context_size: usize, pub desc: u32, pub init: Option<unsafe extern "C" fn(_: *mut *const br_hash_class)>, pub update: Option<unsafe extern "C" fn(_: *mut *const br_hash_class, _: *const c_void, _: usize)>, pub out: Option<unsafe extern "C" fn(_: *const *const br_hash_class, _: *mut c_void)>, pub state: Option<unsafe extern "C" fn(_: *const *const br_hash_class, _: *mut c_void) -> u64>, pub set_state: Option<unsafe extern "C" fn(_: *mut *const br_hash_class, _: *const c_void, _: u64)>, }
Fields
context_size: usize
\brief Size (in bytes) of the context structure appropriate for computing this hash function.
desc: u32
\brief Descriptor word that contains information about the hash function.
For each word xxx
described below, use BR_HASHDESC_xxx_OFF
and BR_HASHDESC_xxx_MASK
to access the specific value, as
follows:
(hf->desc >> BR_HASHDESC_xxx_OFF) & BR_HASHDESC_xxx_MASK
The defined elements are:
ID
: the symbolic identifier for the function, as defined in TLS (MD5 = 1, SHA-1 = 2,...).OUT
: hash output size, in bytes.STATE
: internal running state size, in bytes.LBLEN
: base-2 logarithm for the internal block size, as defined for HMAC processing (this is 6 for MD5, SHA-1, SHA-224 and SHA-256, since these functions use 64-byte blocks; for SHA-384 and SHA-512, this is 7, corresponding to their 128-byte blocks).
The descriptor may contain a few other flags.
init: Option<unsafe extern "C" fn(_: *mut *const br_hash_class)>
\brief Initialisation method.
This method takes as parameter a pointer to a context area, that it initialises. The first field of the context is set to this vtable; other elements are initialised for a new hash computation.
\param ctx pointer to (the first field of) the context.
update: Option<unsafe extern "C" fn(_: *mut *const br_hash_class, _: *const c_void, _: usize)>
\brief Data injection method.
The len
bytes starting at address data
are injected into
the running hash computation incarnated by the specified
context. The context is updated accordingly. It is allowed
to have len == 0
, in which case data
is ignored (and could
be NULL
), and nothing happens.
on the input data.
\param ctx pointer to (the first field of) the context. \param data pointer to the first data byte to inject. \param len number of bytes to inject.
out: Option<unsafe extern "C" fn(_: *const *const br_hash_class, _: *mut c_void)>
\brief Produce hash output.
The hash output corresponding to all data bytes injected in the
context since the last init()
call is computed, and written
in the buffer pointed to by dst
. The hash output size depends
on the implemented hash function (e.g. 16 bytes for MD5).
The context is not modified by this call, so further bytes
may be afterwards injected to continue the current computation.
\param ctx pointer to (the first field of) the context. \param dst destination buffer for the hash output.
state: Option<unsafe extern "C" fn(_: *const *const br_hash_class, _: *mut c_void) -> u64>
\brief Get running state.
This method saves the current running state into the dst
buffer. What constitutes the "running state" depends on the
hash function; for Merkle-Damgård hash functions (like
MD5 or SHA-1), this is the output obtained after processing
each block. The number of bytes injected so far is returned.
The context is not modified by this call.
\param ctx pointer to (the first field of) the context. \param dst destination buffer for the state. \return the injected total byte length.
set_state: Option<unsafe extern "C" fn(_: *mut *const br_hash_class, _: *const c_void, _: u64)>
\brief Set running state.
This methods replaces the running state for the function.
\param ctx pointer to (the first field of) the context. \param stb source buffer for the state. \param count injected total byte length.
Trait Implementations
impl Debug for br_hash_class_
[src]
impl Copy for br_hash_class_
[src]
impl Clone for br_hash_class_
[src]
fn clone(&self) -> br_hash_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