aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/commands.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-12-27 17:57:26 +0100
committerDaniel Mueller <deso@posteo.net>2019-01-07 18:13:50 -0800
commit32c22bd1eb9fe05db30cf1062d089b21bd00c3a7 (patch)
treed611e08ad6bdf27e01899d4c4e64fdc649dcfd60 /nitrocli/src/commands.rs
parent0c679b30ef04de8bc556ce33b305d3ccf740a970 (diff)
downloadnitrocli-32c22bd1eb9fe05db30cf1062d089b21bd00c3a7.tar.gz
nitrocli-32c22bd1eb9fe05db30cf1062d089b21bd00c3a7.tar.bz2
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.
Diffstat (limited to 'nitrocli/src/commands.rs')
-rw-r--r--nitrocli/src/commands.rs7
1 files changed, 7 insertions, 0 deletions
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<T: GenerateOtp>(slot: u8, algorithm: args::OtpAlgorithm, device: &T) -> Result<String> {
match algorithm {
args::OtpAlgorithm::Hotp => device.get_hotp_code(slot),