aboutsummaryrefslogtreecommitdiff
path: root/crypto/rand/rand_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rand/rand_unix.c')
-rw-r--r--crypto/rand/rand_unix.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
index ec6be791b37f..43f1069d151d 100644
--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -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;