From a23c692dc38fe95b1a584663166fd3c9ed251326 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sun, 9 Apr 2017 20:21:39 -0700 Subject: Detect wrong password during 'open' command When a wrong password is entered when attempting to open the encrypted volume the nitrokey will report that in the form of an error. In such a case we should retry the operation after asking the user for the corrected password. This change implements this logic. Note that because we use gpg-agent for the PIN inquiry and because it caches passwords by default we must make sure to clear the cache before retrying. --- nitrocli/src/nitrokey.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nitrocli/src/nitrokey.rs') diff --git a/nitrocli/src/nitrokey.rs b/nitrocli/src/nitrokey.rs index d1d6c72..00a681c 100644 --- a/nitrocli/src/nitrokey.rs +++ b/nitrocli/src/nitrokey.rs @@ -241,6 +241,9 @@ pub enum CommandStatus { #[allow(dead_code)] +#[derive(Copy)] +#[derive(Clone)] +#[derive(Debug)] #[derive(PartialEq)] #[repr(u8)] pub enum StorageStatus { @@ -272,6 +275,17 @@ impl

AsRef<[u8]> for Response

{ } +#[repr(packed)] +pub struct StorageResponse { + pub padding1: [u8; 13], + pub command_counter: u8, + pub last_storage_command: Command, + pub storage_status: StorageStatus, + pub progress: u8, + pub padding2: [u8; 2], +} + + #[repr(packed)] pub struct DeviceStatusResponse { pub padding0: [u8; 22], -- cgit v1.2.1