diff --git a/apps/vault/src/totp.rs b/apps/vault/src/totp.rs index 23e6a7846..22c9e87cb 100644 --- a/apps/vault/src/totp.rs +++ b/apps/vault/src/totp.rs @@ -17,13 +17,22 @@ pub enum TotpAlgorithm { HmacSha1, HmacSha256, HmacSha512, + None, } + +impl Default for TotpAlgorithm { + fn default() -> Self { + Self::None + } +} + impl std::fmt::Debug for TotpAlgorithm { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { TotpAlgorithm::HmacSha1 => write!(f, "SHA1"), TotpAlgorithm::HmacSha256 => write!(f, "SHA256"), TotpAlgorithm::HmacSha512 => write!(f, "SHA512"), + TotpAlgorithm::None => write!(f, "None"), } } } @@ -45,6 +54,7 @@ impl Into for TotpAlgorithm { TotpAlgorithm::HmacSha1 => "SHA1".to_string(), TotpAlgorithm::HmacSha256 => "SHA256".to_string(), TotpAlgorithm::HmacSha512 => "SHA512".to_string(), + TotpAlgorithm::None => "None".to_string(), } } } @@ -112,6 +122,9 @@ fn generate_hmac_bytes(unix_timestamp: u64, totp_entry: &TotpEntry) -> Result { + panic!("cannot generate hmac bytes for None algorithm") + } } Ok(computed_hmac)