apple getentropy removal
authorDavid CARLIER <devnexen@gmail.com>
Mon, 28 Jun 2021 08:55:22 +0000 (09:55 +0100)
committerPauli <pauli@openssl.org>
Tue, 29 Jun 2021 22:46:21 +0000 (08:46 +1000)
backport of #15924

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15935)

crypto/rand/rand_unix.c

index ec6be791b37f445620a7dcd1077b9c3059c9b7e7..eda0d5ae200e82802c9064c678d708dc957e32e9 100644 (file)
@@ -34,6 +34,9 @@
 #if defined(__OpenBSD__)
 # include <sys/param.h>
 #endif
+#if defined(__APPLE__)
+# include <CommonCrypto/CommonRandom.h>
+#endif
 
 #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__)
 # include <sys/types.h>
@@ -378,6 +381,11 @@ static ssize_t syscall_random(void *buf, size_t buflen)
         if (errno != ENOSYS)
             return -1;
     }
+#  elif defined(__APPLE__)
+    if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
+           return (ssize_t)buflen;
+
+    return -1;
 #  else
     union {
         void *p;