summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--src/util.rs13
2 files changed, 5 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f3560a2..663e596 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,4 +19,4 @@ test-storage = []
[dependencies]
libc = "0.2"
nitrokey-sys = "3.4.1"
-rand = "0.4"
+rand = "0.6"
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);
}