File tree 3 files changed +13
-0
lines changed
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;
25
25
/// Windows | [`ProcessPrng`](https://learn.microsoft.com/en-us/windows/win32/seccng/processprng)
26
26
/// Apple | `CCRandomGenerateBytes`
27
27
/// 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)
28
29
/// 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)
29
30
/// Fuchsia | [`cprng_draw`](https://fuchsia.dev/reference/syscalls/cprng_draw)
30
31
/// 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! {
25
25
} else if #[ cfg( target_os = "emscripten" ) ] {
26
26
mod getentropy;
27
27
pub use getentropy:: fill_bytes;
28
+ } else if #[ cfg( target_os = "espidf" ) ] {
29
+ mod espidf;
30
+ pub use espidf:: fill_bytes;
28
31
} else if #[ cfg( target_os = "fuchsia" ) ] {
29
32
mod fuchsia;
30
33
pub use fuchsia:: fill_bytes;
You can’t perform that action at this time.
0 commit comments