diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2018-12-23 02:19:00 +0100 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2018-12-24 18:15:28 -0800 |
commit | b7b9c6f3591e1ef28371d42229053b5368e79b7d (patch) | |
tree | d8f3a1f661034ab6950fa54cdc35bcb0433002d5 /nitrocli/src/commands.rs | |
parent | 1630c7872631f5f7e5bab599121df1fed26e47da (diff) | |
download | nitrocli-b7b9c6f3591e1ef28371d42229053b5368e79b7d.tar.gz nitrocli-b7b9c6f3591e1ef28371d42229053b5368e79b7d.tar.bz2 |
Implement the otp clear subcommand
This patch implements the `otp clear` subcommand that erases an OTP slot.
Diffstat (limited to 'nitrocli/src/commands.rs')
-rw-r--r-- | nitrocli/src/commands.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index 8dc8c42..93e9bd3 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -322,6 +322,17 @@ pub fn otp_set( Ok(()) } +/// Clear an OTP slot. +pub fn otp_clear(slot: u8, algorithm: args::OtpAlgorithm) -> Result<()> { + let device = authenticate_admin(get_device()?)?; + match algorithm { + args::OtpAlgorithm::Hotp => device.erase_hotp_slot(slot), + args::OtpAlgorithm::Totp => device.erase_totp_slot(slot), + } + .map_err(|err| get_error("Could not clear OTP slot", &err))?; + Ok(()) +} + #[cfg(test)] mod tests { use super::*; |