Skip to main content

EntropyCallback

Type Alias EntropyCallback 

Source
pub type EntropyCallback = unsafe extern "C" fn(dest: *mut u8, len: usize, context: *mut u8) -> i32;
Expand description

Function pointer type for custom entropy sources

This function should fill the provided buffer with cryptographically secure random bytes. The function must be thread-safe and should not block indefinitely.

§Arguments

  • dest - Buffer to fill with random bytes
  • len - Number of bytes to generate
  • context - Optional context data passed to the entropy source

§Returns

Returns Ok(()) on success, or an error if entropy generation fails.

§Safety

The dest pointer must be valid for len bytes and must not be null. The function must not cause undefined behavior.