|
| 1 | +From cef404f1e7a598166cbc2fd2e0048f7e2d752ad5 Mon Sep 17 00:00:00 2001 |
| 2 | +From: David Carlier <devnexen@gmail.com> |
| 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 | + crypto/rand/rand_unix.c | 5 +---- |
| 10 | + include/crypto/rand.h | 10 ++++++++++ |
| 11 | + 2 files changed, 11 insertions(+), 4 deletions(-) |
| 12 | + |
| 13 | +diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c |
| 14 | +index 43f1069d15..0f4525106a 100644 |
| 15 | +--- a/crypto/rand/rand_unix.c |
| 16 | ++++ b/crypto/rand/rand_unix.c |
| 17 | +@@ -34,9 +34,6 @@ |
| 18 | + #if defined(__OpenBSD__) |
| 19 | + # include <sys/param.h> |
| 20 | + #endif |
| 21 | +-#if defined(__APPLE__) |
| 22 | +-# include <CommonCrypto/CommonRandom.h> |
| 23 | +-#endif |
| 24 | + |
| 25 | + #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__) |
| 26 | + # include <sys/types.h> |
| 27 | +@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen) |
| 28 | + if (errno != ENOSYS) |
| 29 | + return -1; |
| 30 | + } |
| 31 | +-# elif defined(__APPLE__) |
| 32 | ++# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM) |
| 33 | + if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess) |
| 34 | + return (ssize_t)buflen; |
| 35 | + |
| 36 | +diff --git a/include/crypto/rand.h b/include/crypto/rand.h |
| 37 | +index 5350d3a931..674f840fd1 100644 |
| 38 | +--- a/include/crypto/rand.h |
| 39 | ++++ b/include/crypto/rand.h |
| 40 | +@@ -20,6 +20,16 @@ |
| 41 | + |
| 42 | + # include <openssl/rand.h> |
| 43 | + |
| 44 | ++# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM) |
| 45 | ++# include <Availability.h> |
| 46 | ++# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \ |
| 47 | ++ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) |
| 48 | ++# define OPENSSL_APPLE_CRYPTO_RANDOM 1 |
| 49 | ++# include <CommonCrypto/CommonCryptoError.h> |
| 50 | ++# include <CommonCrypto/CommonRandom.h> |
| 51 | ++# endif |
| 52 | ++# endif |
| 53 | ++ |
| 54 | + /* forward declaration */ |
| 55 | + typedef struct rand_pool_st RAND_POOL; |
| 56 | + |
| 57 | +-- |
| 58 | +2.33.0 |
| 59 | + |
0 commit comments