Skip to content

Commit cb73bca

Browse files
committed
replace fuchsia-zircon with fuchsia-cprng in rand-0.4
As in #706, fuchsia is replacing users of fuchsia-zircon with fuchsia-cprng since that reduces exposure to our changing syscalls.
1 parent 6cb6f88 commit cb73bca

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ winapi = { version = "0.3", features = ["minwindef", "ntsecapi", "profileapi", "
3232
members = ["rand-derive"]
3333

3434
[target.'cfg(target_os = "fuchsia")'.dependencies]
35-
fuchsia-zircon = "0.3.2"
35+
fuchsia-cprng = "0.1.0"
3636

3737
[target.'cfg(target_env = "sgx")'.dependencies]
3838
rdrand = "0.4.0"

src/os.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ mod imp {
389389

390390
#[cfg(target_os = "fuchsia")]
391391
mod imp {
392-
extern crate fuchsia_zircon;
392+
extern crate fuchsia_cprng;
393393

394394
use std::io;
395395
use Rng;
@@ -413,15 +413,7 @@ mod imp {
413413
next_u64(&mut |v| self.fill_bytes(v))
414414
}
415415
fn fill_bytes(&mut self, v: &mut [u8]) {
416-
for s in v.chunks_mut(fuchsia_zircon::sys::ZX_CPRNG_DRAW_MAX_LEN) {
417-
let mut filled = 0;
418-
while filled < s.len() {
419-
match fuchsia_zircon::cprng_draw(&mut s[filled..]) {
420-
Ok(actual) => filled += actual,
421-
Err(e) => panic!("cprng_draw failed: {:?}", e),
422-
};
423-
}
424-
}
416+
fuchsia_cprng::cprng_draw(v);
425417
}
426418
}
427419
}

0 commit comments

Comments
 (0)