From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- vendor/fuchsia-cprng/src/lib.rs | 57 ----------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 vendor/fuchsia-cprng/src/lib.rs (limited to 'vendor/fuchsia-cprng/src/lib.rs') diff --git a/vendor/fuchsia-cprng/src/lib.rs b/vendor/fuchsia-cprng/src/lib.rs deleted file mode 100644 index 5074690..0000000 --- a/vendor/fuchsia-cprng/src/lib.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2019 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -//! Type-safe bindings for the Zircon kernel's CPRNG. - -#![no_std] -#![deny(warnings)] - -/// Draw random bytes from the kernel's CPRNG to fill the given buffer. -/// -/// Wraps the -/// [zx_cprng_draw](https://fuchsia.googlesource.com/fuchsia/+/master/zircon/docs/syscalls/cprng_draw.md) -/// syscall. -pub fn cprng_draw(buffer: &mut [u8]) { - unsafe { zx_cprng_draw(buffer.as_mut_ptr(), buffer.len()) }; -} - -#[link(name = "zircon")] -extern "C" { - fn zx_cprng_draw(buffer: *mut u8, length: usize); -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn cprng() { - let mut buffer = [0; 20]; - cprng_draw(&mut buffer); - let mut first_zero = 0; - let mut last_zero = 0; - for _ in 0..30 { - let mut buffer = [0; 20]; - cprng_draw(&mut buffer); - if buffer[0] == 0 { - first_zero += 1; - } - if buffer[19] == 0 { - last_zero += 1; - } - } - assert_ne!(first_zero, 30); - assert_ne!(last_zero, 30); - } - - #[test] - fn cprng_large() { - let mut buffer = [0; 1024]; - cprng_draw(&mut buffer); - - for mut s in buffer.chunks_mut(256) { - cprng_draw(&mut s); - } - } -} -- cgit v1.2.3