MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / enforce_auth_floor

Function enforce_auth_floor

nodedb/src/control/server/session_auth/native.rs:271–277  ·  view source on GitHub ↗

Sleep until `auth_start + AUTH_FLOOR` to enforce a constant-time error path. Called on every password-auth failure so that no failure mode (rate-limit, lockout, wrong password, unknown user) can be distinguished from any other by wall-clock timing. When Argon2 already ran, `auth_start` is old enough that the sleep duration is effectively zero.

(auth_start: std::time::Instant)

Source from the content-addressed store, hash-verified

269/// by wall-clock timing. When Argon2 already ran, `auth_start` is old enough
270/// that the sleep duration is effectively zero.
271async fn enforce_auth_floor(auth_start: std::time::Instant) {
272 let deadline = auth_start + AUTH_FLOOR;
273 let now = std::time::Instant::now();
274 if deadline > now {
275 tokio::time::sleep(deadline - now).await;
276 }
277}

Callers 1

authenticateFunction · 0.85

Calls 1

nowFunction · 0.85

Tested by

no test coverage detected