timing_safe_operation

Function timing_safe_operation 

Source
pub async fn timing_safe_operation<T, F, Fut>(
    operation: F,
    min_duration_ms: u64,
) -> Result<T>
where F: FnOnce() -> Fut, Fut: Future<Output = Result<T>>,
Expand description

Wrapper for sensitive authentication operations with timing protection

This function wraps sensitive operations with timing protection, ensuring that both success and failure cases take similar amounts of time.

§Arguments

  • operation - The async operation to perform
  • min_duration_ms - Minimum time the operation should take

§Returns

The result of the operation

§Security

Ensures that timing differences don’t leak information about the success or failure of the operation.