aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2024-05-08 22:07:46 -0400
committerJesse Luehrs <doy@tozt.net>2024-05-08 22:07:46 -0400
commit5489b718a9add3d0a93de58c1d618fce6c0ca188 (patch)
treee4f65c6cd3e28d56c0c2cb292d51e0bcabb027d3 /src/bin
parent5f5dd37a7376b2351d76b09d4017eadfaa5e836a (diff)
downloadrbw-5489b718a9add3d0a93de58c1d618fce6c0ca188.tar.gz
rbw-5489b718a9add3d0a93de58c1d618fce6c0ca188.zip
formatting
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/rbw/commands.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 557eed6..6d36eb3 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -1948,6 +1948,7 @@ struct TotpParams {
digits: u32,
period: u64,
}
+
fn decode_totp_secret(secret: &str) -> anyhow::Result<Vec<u8>> {
base32::decode(
base32::Alphabet::RFC4648 { padding: false },
@@ -1955,6 +1956,7 @@ fn decode_totp_secret(secret: &str) -> anyhow::Result<Vec<u8>> {
)
.ok_or_else(|| anyhow::anyhow!("totp secret was not valid base32"))
}
+
fn parse_totp_secret(secret: &str) -> anyhow::Result<TotpParams> {
if let Ok(u) = url::Url::parse(secret) {
if u.scheme() != "otpauth" {
@@ -1990,7 +1992,7 @@ fn parse_totp_secret(secret: &str) -> anyhow::Result<TotpParams> {
anyhow::anyhow!("period parameter in totp url must be a valid integer.")
})?
}
- None => 30,
+ None => totp_lite::DEFAULT_STEP,
}
})
} else {
@@ -1998,7 +2000,7 @@ fn parse_totp_secret(secret: &str) -> anyhow::Result<TotpParams> {
secret: decode_totp_secret(secret)?,
algorithm: String::from("SHA1"),
digits: 6,
- period: 30,
+ period: totp_lite::DEFAULT_STEP,
})
}
}