fi
+if [ $njs_found = no ]; then
+
+ # macOS 10.10.
+
+ njs_feature="CCRandomGenerateBytes() in CommonCrypto/CommonRandom.h"
+ njs_feature_name=NJS_HAVE_CCRANDOMGENERATEBYTES
+ njs_feature_test="#include <CommonCrypto/CommonCryptoError.h>
+ #include <CommonCrypto/CommonRandom.h>
+
+ int main(void) {
+ char buf[4];
+
+ if (CCRandomGenerateBytes(buf, 4) != kCCSuccess) {
+ return 1;
+ }
+
+ return 0;
+ }"
+ . auto/feature
+fi
+
+
if [ $njs_found = no ]; then
# OpenBSD 5.6 lacks <sys/random.h>.
if [ $njs_found = no ]; then
- # macOS 10.12.
+ # Solaris based systems.
njs_feature="getentropy() in sys/random.h"
njs_feature_name=NJS_HAVE_GETENTROPY_SYS_RANDOM
#include <njs_main.h>
#if (NJS_HAVE_GETRANDOM)
#include <sys/random.h>
+#elif (NJS_HAVE_CCRANDOMGENERATEBYTES)
+#include <CommonCrypto/CommonCryptoError.h>
+#include <CommonCrypto/CommonRandom.h>
#elif (NJS_HAVE_LINUX_SYS_GETRANDOM)
#include <sys/syscall.h>
#include <linux/random.h>
n = syscall(SYS_getrandom, &key, NJS_RANDOM_KEY_SIZE, 0);
+#elif (NJS_HAVE_CCRANDOMGENERATEBYTES)
+
+ /* Apple discourages the use of getentropy. */
+
+ n = 0;
+
+ if (CCRandomGenerateBytes(&key, NJS_RANDOM_KEY_SIZE) == kCCSuccess) {
+ n = NJS_RANDOM_KEY_SIZE;
+ }
+
#elif (NJS_HAVE_GETENTROPY || NJS_HAVE_GETENTROPY_SYS_RANDOM)
n = 0;