Skip to content

Commit d4074d5

Browse files
committed
Use SecRandom.h only on macOS 10.7 or higher
1 parent 0bb352e commit d4074d5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/chacha20poly1305.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,15 @@ static size_t read_urandom(void* buf, size_t n)
383383
}
384384

385385
#if defined(__APPLE__)
386+
#include <AvailabilityMacros.h>
387+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
386388
#include <Security/SecRandom.h>
387389
#endif
390+
#endif
388391

389392
static size_t entropy(void* buf, size_t n)
390393
{
391-
#if defined(__APPLE__)
394+
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
392395
if (SecRandomCopyBytes(kSecRandomDefault, n, (uint8_t*) buf) == 0)
393396
return n;
394397
#elif defined(__linux__) && defined(SYS_getrandom)

0 commit comments

Comments
 (0)