diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/util.rs b/src/util.rs index 2a75634..d98e675 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,11 +1,10 @@ -use libc::{c_void, free}; -use nitrokey_sys; -use rand::{OsRng, Rng}; -use std; use std::ffi::{CStr, CString}; use std::fmt; use std::os::raw::{c_char, c_int}; +use libc::{c_void, free}; +use rand::Rng; + /// Error types returned by Nitrokey device or by the library. #[derive(Debug, PartialEq)] pub enum CommandError { @@ -101,12 +100,8 @@ pub fn get_last_error() -> CommandError { } pub fn generate_password(length: usize) -> std::io::Result<Vec<u8>> { - let mut rng = match OsRng::new() { - Ok(rng) => rng, - Err(err) => return Err(err), - }; let mut data = vec![0u8; length]; - rng.fill_bytes(&mut data[..]); + rand::thread_rng().fill(&mut data[..]); return Ok(data); } |