upstream: https://github.com/mirage/mirage-crypto

Use arc4random_buf for Android 27 and earlier

getrandom is not present until Android 28.

Confer: https://android.googlesource.com/platform/bionic/+/02ce401d1e2b31586c94c8b6999364bbbce27388/libc/include/sys/random.h

+13 -1
+5
CHANGES.md
··· 1 + ## Pending 2 + 3 + * Use arc4random_buf instead of getrandom on Android before getrandom 4 + became available in API 28. 5 + 1 6 ## v2.0.0 (2025-02-03) 2 7 3 8 * Remove now superfluous mirage-crypto-rng-{eio,lwt,async} packages
+8 -1
rng/unix/mc_getrandom_stubs.c
··· 9 9 #include <caml/unixsupport.h> 10 10 #include <caml/bigarray.h> 11 11 12 - #if defined(__linux) || defined(__GNU__) 12 + #if defined(__ANDROID_API__) && __ANDROID_API__ < 28 13 + // on Android 27 and earlier, we use Google's <sys/random.h> recommended arc4random_buf 14 + # include <stdlib.h> 15 + 16 + void raw_getrandom (uint8_t *data, size_t len) { 17 + arc4random_buf(data, len); 18 + } 19 + #elif defined(__linux) || defined(__GNU__) 13 20 # include <errno.h> 14 21 // on Linux and GNU/Hurd, we use getrandom and loop 15 22