|
| 1 | +From 96ac8f13f4d0ee96baf5724d9f96c44c34b8606c Mon Sep 17 00:00:00 2001 |
| 2 | +From: David Carlier < [email protected]> |
| 3 | +Date: Tue, 24 Aug 2021 22:40:14 +0100 |
| 4 | +Subject: [PATCH] Darwin platform allows to build on releases before |
| 5 | + Yosemite/ios 8. |
| 6 | + |
| 7 | +issue #16407 #16408 |
| 8 | + |
| 9 | +Reviewed-by: Paul Dale < [email protected]> |
| 10 | +Reviewed-by: Tomas Mraz < [email protected]> |
| 11 | +(Merged from https://github.com/openssl/openssl/pull/16409) |
| 12 | +--- |
| 13 | + crypto/rand/rand_unix.c | 5 +---- |
| 14 | + include/crypto/rand.h | 10 ++++++++++ |
| 15 | + 2 files changed, 11 insertions(+), 4 deletions(-) |
| 16 | + |
| 17 | +diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c |
| 18 | +index 43f1069d151d..0f4525106af7 100644 |
| 19 | +--- a/crypto/rand/rand_unix.c |
| 20 | ++++ b/crypto/rand/rand_unix.c |
| 21 | +@@ -34,9 +34,6 @@ |
| 22 | + #if defined(__OpenBSD__) |
| 23 | + # include <sys/param.h> |
| 24 | + #endif |
| 25 | +-#if defined(__APPLE__) |
| 26 | +-# include <CommonCrypto/CommonRandom.h> |
| 27 | +-#endif |
| 28 | + |
| 29 | + #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__) |
| 30 | + # include <sys/types.h> |
| 31 | +@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen) |
| 32 | + if (errno != ENOSYS) |
| 33 | + return -1; |
| 34 | + } |
| 35 | +-# elif defined(__APPLE__) |
| 36 | ++# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM) |
| 37 | + if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess) |
| 38 | + return (ssize_t)buflen; |
| 39 | + |
| 40 | +diff --git a/include/crypto/rand.h b/include/crypto/rand.h |
| 41 | +index 5350d3a93119..674f840fd13c 100644 |
| 42 | +--- a/include/crypto/rand.h |
| 43 | ++++ b/include/crypto/rand.h |
| 44 | +@@ -20,6 +20,16 @@ |
| 45 | + |
| 46 | + # include <openssl/rand.h> |
| 47 | + |
| 48 | ++# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM) |
| 49 | ++# include <Availability.h> |
| 50 | ++# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \ |
| 51 | ++ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) |
| 52 | ++# define OPENSSL_APPLE_CRYPTO_RANDOM 1 |
| 53 | ++# include <CommonCrypto/CommonCryptoError.h> |
| 54 | ++# include <CommonCrypto/CommonRandom.h> |
| 55 | ++# endif |
| 56 | ++# endif |
| 57 | ++ |
| 58 | + /* forward declaration */ |
| 59 | + typedef struct rand_pool_st RAND_POOL; |
| 60 | + |
0 commit comments