axess_factors/otp_algorithm.rs
1//! HMAC algorithm choice shared by [`TotpConfig`](crate::totp::TotpConfig)
2//! and [`HotpConfig`](crate::hotp::HotpConfig).
3//!
4//! Not collapsed with the verifier-internal [`TotpAlgorithm`](crate::totp::TotpAlgorithm)
5//! and [`HotpAlgorithm`](crate::hotp::HotpAlgorithm); those are the
6//! per-verifier algorithm tags (one a `totp-rs` re-export with `SHA1`
7//! casing, the other a hand-rolled enum with `Sha1` casing). This enum
8//! is the storage shape that round-trips through `FactorConfig` and the
9//! adopter-facing JSON. Unifying the three is a separate concern.
10
11use serde::{Deserialize, Serialize};
12
13/// The HMAC algorithm used for OTP generation.
14#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
15pub enum OtpAlgorithm {
16 /// HMAC-SHA1: the only algorithm guaranteed by RFC 6238 for interop.
17 #[default]
18 Sha1,
19 /// HMAC-SHA256: supported by most modern authenticator apps.
20 Sha256,
21 /// HMAC-SHA512: supported by some authenticators.
22 Sha512,
23}