/// Callback for an HMAC-SHA256 implementation.
/// This function shall initialize an HMAC context with the provided key.
///
/// @param hmac_context private HMAC context pointer
/// @param key pointer to the key
/// @param key_len length of the key
/// @return 0 on success, negative on failure
Callback for an HMAC-SHA256 implementation.
This function shall initialize an HMAC context with the provided key.
Callback for an HMAC - SHA256 implementation . This function shall initialize an HMAC context with the provided key .
extern "C" fn hmac_sha256_init_func(
    hmac_context: *mut *mut c_void,
    key: *const u8,
    key_len: usize,
    _user_data: *mut c_void,
) -> c_int {
    debug!("hmac_sha256_init_func");
    let hkey = unsafe { slice::from_raw_parts_mut(key as *mut u8, key_len) };
    let hmac = HmacWrapper::new(Sha256::new(), hkey);
    // "leak" the pointer to let the C side manage its lifetime.
    let addr = Box::into_raw(Box::new(hmac)) as *mut c_void;
    // copy the address of our pointer to the right place.
    unsafe { *hmac_context = addr };
    0
}
extern " " fn hmac_sha256_init_func ( hmac_context : * mut * mut c_void , key : * const u8 , key_len : usize , _user_data : * mut c_void , ) -> c_int { debug ! ( " " ) ; let hkey = unsafe { slice :: from_raw_parts_mut ( key as * mut u8 , key_len ) } ; let hmac = HmacWrapper :: new ( Sha256 :: new ( ) , hkey ) ; // "leak" the pointer to let the C side manage its lifetime. let addr = Box :: into_raw ( Box :: new ( hmac ) ) as * mut c_void ; // copy the address of our pointer to the right place. unsafe { * hmac_context = addr } ; 0 }
Callback for an HMAC-SHA256 implementation.
Callback for an HMAC - SHA256 implementation .
0 on success, negative on failure
0 on success negative on failure
hmac_context
*mut *mut c_void
private HMAC context pointer
private HMAC context pointer
key
*const u8
pointer to the key
pointer to the key
key_len
usize
length of the key
length of the key
_user_data
*mut c_void