Use libc's syscall() and NR_GETENTROPY const
This commit is contained in:
parent
314062b701
commit
9fde3e9b94
@ -204,12 +204,6 @@ mod imp {
|
||||
_dummy: (),
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn syscall(number: c_long, ...) -> c_long;
|
||||
}
|
||||
|
||||
const NR_GETENTROPY: c_long = 7;
|
||||
|
||||
impl OsRng {
|
||||
/// Create a new `OsRng`.
|
||||
pub fn new() -> io::Result<OsRng> {
|
||||
@ -232,7 +226,7 @@ mod imp {
|
||||
// getentropy(2) permits a maximum buffer size of 256 bytes
|
||||
for s in v.chunks_mut(256) {
|
||||
let ret = unsafe {
|
||||
syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len())
|
||||
libc::syscall(libc::NR_GETENTROPY, s.as_mut_ptr(), s.len())
|
||||
};
|
||||
if ret == -1 {
|
||||
panic!("unexpected getentropy error: {}", errno());
|
||||
|
Loading…
x
Reference in New Issue
Block a user