From 32c22bd1eb9fe05db30cf1062d089b21bd00c3a7 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 27 Dec 2018 17:57:26 +0100 Subject: Implement the lock command This patch implements the lock command that locks the password safe and, on the Nitrokey Storage, the encrypted volume. See issue #18 for details on the locking mechanism. --- nitrocli/src/commands.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nitrocli/src/commands.rs') diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index c903cfd..1b26326 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -340,6 +340,13 @@ pub fn config_set( .map_err(|err| get_error("Could not set configuration", &err)) } +/// Lock the Nitrokey device. +pub fn lock() -> Result<()> { + get_device()? + .lock() + .map_err(|err| get_error("Getting Storage status failed", &err)) +} + fn get_otp(slot: u8, algorithm: args::OtpAlgorithm, device: &T) -> Result { match algorithm { args::OtpAlgorithm::Hotp => device.get_hotp_code(slot), -- cgit v1.2.1