File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ use crate::sys::random as sys;
2525/// Windows | [`ProcessPrng`](https://learn.microsoft.com/en-us/windows/win32/seccng/processprng)
2626/// Apple | `CCRandomGenerateBytes`
2727/// DragonFly | [`arc4random_buf`](https://man.dragonflybsd.org/?command=arc4random§ion=ANY)
28+ /// ESP-IDF | [`esp_fill_random`](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html#_CPPv415esp_fill_randomPv6size_t)
2829/// FreeBSD | [`arc4random_buf`](https://man.freebsd.org/cgi/man.cgi?query=arc4random&apropos=0&sektion=0&manpath=FreeBSD+15.0-CURRENT&arch=default&format=html)
2930/// Fuchsia | [`cprng_draw`](https://fuchsia.dev/reference/syscalls/cprng_draw)
3031/// Haiku | `arc4random_buf`
Original file line number Diff line number Diff line change 1+ use crate :: ffi:: c_void;
2+
3+ extern "C" {
4+ fn esp_fill_random ( buf : * mut c_void , len : usize ) ;
5+ }
6+
7+ pub fn fill_bytes ( bytes : & mut [ u8 ] , _best_effort : bool ) {
8+ unsafe { esp_fill_random ( bytes. as_mut_ptr ( ) . cast ( ) , bytes. len ( ) ) }
9+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ cfg_if::cfg_if! {
2525 } else if #[ cfg( target_os = "emscripten" ) ] {
2626 mod getentropy;
2727 pub use getentropy:: fill_bytes;
28+ } else if #[ cfg( target_os = "espidf" ) ] {
29+ mod espidf;
30+ pub use espidf:: fill_bytes;
2831 } else if #[ cfg( target_os = "fuchsia" ) ] {
2932 mod fuchsia;
3033 pub use fuchsia:: fill_bytes;
You can’t perform that action at this time.
0 commit comments