Replace RAND_bytes with getrandom crate

This commit is contained in:
Jack Grigg
2019-11-20 21:02:28 +00:00
parent ffdb114ae5
commit c0bbf9aa06
4 changed files with 13 additions and 44 deletions
-21
View File
@@ -69,7 +69,6 @@ extern "C" {
keylen: i32,
out: *mut u8,
) -> i32;
fn RAND_bytes(buf: *mut u8, num: i32) -> i32;
}
/// DES-related errors
@@ -234,26 +233,6 @@ pub unsafe fn yk_des_is_weak_key(key: *const u8, _cb_key: usize) -> bool {
DES_is_weak_key(key as (*mut [u8; 8])) != 0
}
/// PRNG errors/results
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(i32)]
pub enum PRngErrorKind {
/// Ok
Ok = 0,
/// General error
GeneralError = -1,
}
/// Generate bytes with the PRNG
pub unsafe fn _ykpiv_prng_generate(buffer: *mut u8, cb_req: usize) -> PRngErrorKind {
if RAND_bytes(buffer, cb_req as (i32)) != -1 {
PRngErrorKind::Ok
} else {
PRngErrorKind::GeneralError
}
}
/// PKCS#5 error types
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(i32)]