Trait nitrokey::GetPasswordSafe
source · pub trait GetPasswordSafe {
fn get_password_safe(
&self,
user_pin: &str
) -> Result<PasswordSafe<'_>, CommandError>;
}
Expand description
Provides access to a PasswordSafe
.
The device that implements this trait must always live at least as long as a password safe retrieved from it.
Required Methods
sourcefn get_password_safe(
&self,
user_pin: &str
) -> Result<PasswordSafe<'_>, CommandError>
fn get_password_safe(
&self,
user_pin: &str
) -> Result<PasswordSafe<'_>, CommandError>
Enables and returns the password safe.
The underlying device must always live at least as long as a password safe retrieved from
it. It is mandatory to lock the underlying device using lock
after the password safe
has been used. Otherwise, other applications can access the password store without
authentication.
Errors
InvalidString
if one of the provided passwords contains a null byteWrongPassword
if the current user password is wrong
Example
use nitrokey::{Device, GetPasswordSafe, PasswordSafe};
fn use_password_safe(pws: &PasswordSafe) {}
let device = nitrokey::connect()?;
match device.get_password_safe("123456") {
Ok(pws) => {
use_password_safe(&pws);
device.lock()?;
},
Err(err) => println!("Could not open the password safe: {}", err),
};