File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Expand file tree Collapse file tree 3 files changed +14
-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`]
2626/// macOS and other UNIXes | [`getentropy`]
2727/// other Apple platforms | `CCRandomGenerateBytes`
28+ /// ESP-IDF | [`esp_fill_random`]
2829/// Fuchsia | [`cprng_draw`]
2930/// Hermit | `read_entropy`
3031/// Horizon | `getrandom` shim
@@ -45,6 +46,7 @@ use crate::sys::random as sys;
4546/// [`/dev/urandom`]: https://www.man7.org/linux/man-pages/man4/random.4.html
4647/// [`ProcessPrng`]: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
4748/// [`getentropy`]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html
49+ /// [`esp_fill_random`]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html#_CPPv415esp_fill_randomPv6size_t
4850/// [`cprng_draw`]: https://fuchsia.dev/reference/syscalls/cprng_draw
4951/// [`kern.arandom`]: https://man.netbsd.org/rnd.4
5052/// [`rdrand`]: https://en.wikipedia.org/wiki/RDRAND
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 @@ -24,6 +24,9 @@ cfg_if::cfg_if! {
2424 } else if #[ cfg( all( target_vendor = "apple" , not( target_os = "macos" ) ) ) ] {
2525 mod apple;
2626 pub use apple:: fill_bytes;
27+ } else if #[ cfg( target_os = "espidf" ) ] {
28+ mod espidf;
29+ pub use espidf:: fill_bytes;
2730 } else if #[ cfg( target_os = "fuchsia" ) ] {
2831 mod fuchsia;
2932 pub use fuchsia:: fill_bytes;
You can’t perform that action at this time.
0 commit comments