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)
| 269 | /// by wall-clock timing. When Argon2 already ran, `auth_start` is old enough |
| 270 | /// that the sleep duration is effectively zero. |
| 271 | async 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 | } |