From 89b8a947e5c622272362e967847eb19337aa68da Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 28 May 2018 22:02:10 +0000 Subject: Add rudimentary support for the Nitrokey Storage This patch adds the Storage struct and the test-storage feature. It also enables all currently supported Pro commands for the Storage. --- src/auth.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs index 80abbc0..c772faf 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,5 +1,5 @@ use config::{Config, RawConfig}; -use device::{Device, DeviceWrapper, Pro}; +use device::{Device, DeviceWrapper, Pro, Storage}; use nitrokey_sys; use std::ffi::CString; use std::ops::Deref; @@ -387,3 +387,17 @@ impl Authenticate for Pro { }) } } + +impl Authenticate for Storage { + fn authenticate_user(self, password: &str) -> Result, (Self, CommandError)> { + authenticate(self, password, |password_ptr, temp_password_ptr| unsafe { + nitrokey_sys::NK_user_authenticate(password_ptr, temp_password_ptr) + }) + } + + fn authenticate_admin(self, password: &str) -> Result, (Self, CommandError)> { + authenticate(self, password, |password_ptr, temp_password_ptr| unsafe { + nitrokey_sys::NK_first_authenticate(password_ptr, temp_password_ptr) + }) + } +} -- cgit v1.2.1