hashEmailCode returns HMAC-SHA256(code) hex-encoded, keyed with the server's auth secret. HMAC with a server-side secret (vs. bare SHA-256) prevents offline brute force of the 10^6-size code space if the DB is ever compromised — the attacker would also need the auth secret to verify candidate codes.
(code string)
| 1617 | // 10^6-size code space if the DB is ever compromised — the attacker would also need the |
| 1618 | // auth secret to verify candidate codes. |
| 1619 | func (s *AuthService) hashEmailCode(code string) string { |
| 1620 | mac := hmac.New(sha256.New, []byte(s.secret)) |
| 1621 | mac.Write([]byte(code)) |
| 1622 | return hex.EncodeToString(mac.Sum(nil)) |
| 1623 | } |
| 1624 | |
| 1625 | // SendEmailLoginCode sends a 6-digit verification code. Always returns success |
| 1626 | // (no email enumeration). Rate limit: 60-sec resend cooldown enforced atomically |
no outgoing calls
no test coverage detected