From ce414f26eec3e90629da733c43ce942709b9ef3d Mon Sep 17 00:00:00 2001 From: Stefan Seemayer Date: Sun, 28 Apr 2024 06:08:09 +0200 Subject: [PATCH] feat: impl Zeroize for TOTP closes #203 --- src/db/otp.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/db/otp.rs b/src/db/otp.rs index b6dfecb8..4172713d 100644 --- a/src/db/otp.rs +++ b/src/db/otp.rs @@ -3,12 +3,13 @@ use std::time::{Duration, SystemTime, SystemTimeError, UNIX_EPOCH}; use thiserror::Error; use totp_lite::{totp_custom, Sha1, Sha256, Sha512}; use url::Url; +use zeroize::{Zeroize, ZeroizeOnDrop}; const DEFAULT_PERIOD: u64 = 30; const DEFAULT_DIGITS: u32 = 8; /// Choices of hash algorithm for TOTP -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Zeroize, ZeroizeOnDrop)] pub enum TOTPAlgorithm { Sha1, Sha256, @@ -29,7 +30,7 @@ impl std::str::FromStr for TOTPAlgorithm { } /// Time-based one time password settings -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Zeroize, ZeroizeOnDrop)] pub struct TOTP { pub label: String, pub issuer: String,