From 017a27a009947d73c00f934a1e052b0ef021680b Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 5 Jun 2018 22:30:04 +0200 Subject: Implement Drop for PasswordSafe By calling NK_lock_device when dropping a PasswordSafe instance, we can make sure that the password safe cannot be reused without authentication. --- src/pws.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/pws.rs') diff --git a/src/pws.rs b/src/pws.rs index 87a71dd..85726c5 100644 --- a/src/pws.rs +++ b/src/pws.rs @@ -315,6 +315,14 @@ impl<'a> PasswordSafe<'a> { } } +impl<'a> Drop for PasswordSafe<'a> { + fn drop(&mut self) { + unsafe { + nitrokey_sys::NK_lock_device(); + } + } +} + impl GetPasswordSafe for Pro { fn get_password_safe(&self, user_pin: &str) -> Result { get_password_safe(self, user_pin) -- cgit v1.2.1