1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use HashedValue;
use crateResult;
use crateVerificationResult;
/// Abstraction over password / secret hashing and verification.
///
/// Implement this trait to plug in alternative hashing algorithms or services
/// (e.g. Argon2 variants, bcrypt, scrypt, external KMS / HSM, remote API).
///
/// # Requirements
/// Implementations SHOULD:
/// - Use a modern, memory‑hard password hashing algorithm (default provided: Argon2id)
/// - Embed salt & parameters in the produced [`HashedValue`] when the format supports it
/// - Return only opaque, self‑contained hash strings (safe to store directly)
///
/// # Error Semantics
/// - Return `Ok(HashedValue)` / `Ok(VerificationResult)` for normal outcomes
/// - Return `Err(..)` only for exceptional failures (misconfiguration, resource exhaustion,
/// serialization/encoding failure, upstream service error, etc.)
///
/// # Enumeration & Timing
/// This trait itself does not enforce constant‑time behavior; callers such as
/// the login flow will layer enumeration resistance. However, implementations
/// SHOULD avoid obviously data‑dependent early exits where practical.
///
/// See [`Argon2Hasher`](crate::hashing::argon2::Argon2Hasher) for a production‑ready implementation.