aboutsummaryrefslogtreecommitdiff
path: root/nitrokey/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'nitrokey/src/util.rs')
-rw-r--r--nitrokey/src/util.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/nitrokey/src/util.rs b/nitrokey/src/util.rs
index fdb73c3..5a56c55 100644
--- a/nitrokey/src/util.rs
+++ b/nitrokey/src/util.rs
@@ -5,8 +5,7 @@ use std::ffi::{CStr, CString};
use std::os::raw::{c_char, c_int};
use libc::{c_void, free};
-use rand_core::RngCore;
-use rand_os::OsRng;
+use rand_core::{OsRng, RngCore};
use crate::error::{Error, LibraryError};
@@ -77,9 +76,8 @@ pub fn get_last_error() -> Error {
}
pub fn generate_password(length: usize) -> Result<Vec<u8>, Error> {
- let mut rng = OsRng::new().map_err(|err| Error::RandError(Box::new(err)))?;
let mut data = vec![0u8; length];
- rng.fill_bytes(&mut data[..]);
+ OsRng.fill_bytes(&mut data[..]);
Ok(data)
}