extern "C" fn random_func(data: *mut u8, len: usize, _user_data: *mut c_void) -> c_int {
    // debug!("random_func len={}", len);
    let rng = SystemRandom::new();

    let array = unsafe { slice::from_raw_parts_mut(data, len) };

    match rng.fill(array) {
        Ok(_) => 0,
        Err(_) => -1, // TODO: check return error types.
    }
}
/// Callback for a secure random number generator.
/// This function shall fill the provided buffer with random bytes.
///
/// @param data pointer to the output buffer
/// @param len size of the output buffer
/// @return 0 on success, negative on failure
Callback for a secure random number generator.
This function shall fill the provided buffer with random bytes.
Callback for a secure random number generator . This function shall fill the provided buffer with random bytes .
extern "C" fn random_func(data: *mut u8, len: usize, _user_data: *mut c_void) -> c_int {
    // debug!("random_func len={}", len);
    let rng = SystemRandom::new();
    let array = unsafe { slice::from_raw_parts_mut(data, len) };
    match rng.fill(array) {
        Ok(_) => 0,
        Err(_) => -1, // TODO: check return error types.
    }
}
extern " " fn random_func ( data : * mut u8 , len : usize , _user_data : * mut c_void ) -> c_int { // debug!("random_func len={}", len); let rng = SystemRandom :: new ( ) ; let array = unsafe { slice :: from_raw_parts_mut ( data , len ) } ; match rng . fill ( array ) { Ok ( _ ) => 0 , Err ( _ ) => - 1 , // TODO: check return error types. } }
Callback for a secure random number generator.
Callback for a secure random number generator .
data
*mut u8
len
usize
_user_data
*mut c_void
0 on success, negative on failure
0 on success negative on failure
data
*mut u8
pointer to the output buffer
pointer to the output buffer
len
usize
size of the output buffer
size of the output buffer
_user_data
*mut c_void