Description
The constant-time comparison in src/auth.rs (lines 57-62) uses std::hint::black_box to prevent compiler optimizations from short-circuiting the byte comparison. However, the documentation for black_box explicitly states it does not offer any guarantees for cryptographic or security purposes.
The code acknowledges this limitation in comments (lines 49-56). While the current approach (SHA384 hashing + XOR fold) is reasonable, the subtle crate provides a well-audited ConstantTimeEq trait specifically designed for this use case.
Severity
Low
Suggested Fix
Replace the custom const_comp function with the subtle crate ConstantTimeEq for a stronger guarantee.
Description
The constant-time comparison in
src/auth.rs(lines 57-62) usesstd::hint::black_boxto prevent compiler optimizations from short-circuiting the byte comparison. However, the documentation forblack_boxexplicitly states it does not offer any guarantees for cryptographic or security purposes.The code acknowledges this limitation in comments (lines 49-56). While the current approach (SHA384 hashing + XOR fold) is reasonable, the
subtlecrate provides a well-auditedConstantTimeEqtrait specifically designed for this use case.Severity
Low
Suggested Fix
Replace the custom
const_compfunction with thesubtlecrateConstantTimeEqfor a stronger guarantee.