File tree 3 files changed +14
-0
lines changed
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;
25
25
/// Windows | [`ProcessPrng`]
26
26
/// macOS and other UNIXes | [`getentropy`]
27
27
/// other Apple platforms | `CCRandomGenerateBytes`
28
+ /// ESP-IDF | [`esp_fill_random`]
28
29
/// Fuchsia | [`cprng_draw`]
29
30
/// Hermit | `read_entropy`
30
31
/// Horizon | `getrandom` shim
@@ -45,6 +46,7 @@ use crate::sys::random as sys;
45
46
/// [`/dev/urandom`]: https://www.man7.org/linux/man-pages/man4/random.4.html
46
47
/// [`ProcessPrng`]: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
47
48
/// [`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
48
50
/// [`cprng_draw`]: https://fuchsia.dev/reference/syscalls/cprng_draw
49
51
/// [`kern.arandom`]: https://man.netbsd.org/rnd.4
50
52
/// [`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! {
24
24
} else if #[ cfg( all( target_vendor = "apple" , not( target_os = "macos" ) ) ) ] {
25
25
mod apple;
26
26
pub use apple:: fill_bytes;
27
+ } else if #[ cfg( target_os = "espidf" ) ] {
28
+ mod espidf;
29
+ pub use espidf:: fill_bytes;
27
30
} else if #[ cfg( target_os = "fuchsia" ) ] {
28
31
mod fuchsia;
29
32
pub use fuchsia:: fill_bytes;
You can’t perform that action at this time.
0 commit comments