aboutsummaryrefslogtreecommitdiff
path: root/src/auth.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-05-28 22:02:10 +0000
committerRobin Krahl <robin.krahl@ireas.org>2018-05-29 00:03:56 +0200
commit89b8a947e5c622272362e967847eb19337aa68da (patch)
treeccbd24b53b4a98312247a304b51774fac2e3b685 /src/auth.rs
parentf58400a22986cdedf34f85dc17d1d59335ffb404 (diff)
downloadnitrokey-rs-89b8a947e5c622272362e967847eb19337aa68da.tar.gz
nitrokey-rs-89b8a947e5c622272362e967847eb19337aa68da.tar.bz2
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.
Diffstat (limited to 'src/auth.rs')
-rw-r--r--src/auth.rs16
1 files changed, 15 insertions, 1 deletions
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<User<Self>, (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<Admin<Self>, (Self, CommandError)> {
+ authenticate(self, password, |password_ptr, temp_password_ptr| unsafe {
+ nitrokey_sys::NK_first_authenticate(password_ptr, temp_password_ptr)
+ })
+ }
+}