riot_sys

Function sha256_chain_with_waypoints

Source
pub unsafe extern "C" fn sha256_chain_with_waypoints(
    seed: *const c_void,
    seed_length: size_t,
    elements: size_t,
    tail_element: *mut c_void,
    waypoints: *mut sha256_chain_idx_elm_t,
    waypoints_length: *mut size_t,
) -> *mut c_void
Expand description

@brief function to produce a hash chain starting with a given seed element. The chain is computed the same way as done with sha256_chain(). Additionally intermediate elements are saved while computing the chain. This slows down computation, but provides the caller with indexed “waypoint”-elements. They are supposed to shortcut computing verification elements, this comes in handy when using long chains, e.g. a chain with 232 elements.

@param[in] seed the seed of the sha256-chain, i.e. the first element @param[in] seed_length the size of seed in bytes @param[in] elements the number of chained elements, i.e. the index of the last element is (elements-1) @param[out] tail_element the final element of the sha256-chain @param[out] waypoints intermediate elements are stored there. @param[in, out] waypoints_length the size of the waypoints array. If the given size is equal or greater elements, the complete chain will be stored. Otherwise every n-th element is stored where: n = floor(elements / waypoints_length); floor is implicitly used since we perform unsigned integer division. The last used waypoint index is stored in the variable after call. That is (elements - 1) if the complete chain is stored, and (*waypoints_length - 1) if we only store some waypoints.

@returns pointer to tail_element