$OpenBSD: patch-configure_ac,v 1.9 2021/04/24 07:44:41 ajacoutot Exp $

Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -230,7 +230,7 @@ available_kdfs="s2k pkdf2 scrypt"
 enabled_kdfs=""
 
 # Definitions for random modules.
-available_random_modules="linux egd unix"
+available_random_modules="arc4random linux egd unix"
 auto_random_modules="$available_random_modules"
 
 # Supported thread backends.
@@ -2195,6 +2195,7 @@ AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf 
 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
 AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval elf_aux_info)
 AC_CHECK_FUNCS(explicit_bzero explicit_memset getentropy)
+AC_CHECK_FUNCS(arc4random)
 
 GNUPG_CHECK_MLOCK
 
@@ -2266,7 +2267,9 @@ fi
 if test "$random" = "default"; then
 
     # Select default value.
-    if test "$ac_cv_have_dev_random" = yes; then
+    if test "$ac_cv_func_arc4random" = yes; then
+        random_modules="arc4random"
+    elif test "$ac_cv_have_dev_random" = yes; then
         # Try Linuxish random device.
         random_modules="linux"
     else
@@ -3085,6 +3088,12 @@ LIST_MEMBER(scrypt, $enabled_kdfs)
 if test "$found" = "1" ; then
    GCRYPT_KDFS="$GCRYPT_KDFS scrypt.lo"
    AC_DEFINE(USE_SCRYPT, 1, [Defined if this module should be included])
+fi
+
+LIST_MEMBER(arc4random, $random_modules)
+if test "$found" = "1" ; then
+   GCRYPT_RANDOM="$GCRYPT_RANDOM rndarc4random.lo"
+   AC_DEFINE(USE_RNDARC4RANDOM, 1, [Defined if arc4random RNG should be used.])
 fi
 
 LIST_MEMBER(linux, $random_modules)
