From 7dc4a03360da9a55f63f696b66c1e92a40a9da4c Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Thu, 6 Jul 2023 07:26:37 +0000 Subject: [PATCH] Fuchsia has getentropy() via musl - use it and drop the custom file Bug: 287 Change-Id: Ia907c5dd7fd31e95098730673d2da1bede6d79ed Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61405 Commit-Queue: David Benjamin Auto-Submit: Bob Beck Reviewed-by: David Benjamin --- crypto/CMakeLists.txt | 1 - crypto/fipsmodule/rand/internal.h | 2 -- crypto/rand_extra/fuchsia.c | 34 ------------------------------- crypto/rand_extra/getentropy.c | 2 +- 4 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 crypto/rand_extra/fuchsia.c diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 7c944c1aa..e004f19b5 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -199,7 +199,6 @@ add_library( pool/pool.c rand_extra/deterministic.c rand_extra/forkunsafe.c - rand_extra/fuchsia.c rand_extra/getentropy.c rand_extra/ios.c rand_extra/passive.c diff --git a/crypto/fipsmodule/rand/internal.h b/crypto/fipsmodule/rand/internal.h index 163672203..595013dd0 100644 --- a/crypto/fipsmodule/rand/internal.h +++ b/crypto/fipsmodule/rand/internal.h @@ -28,8 +28,6 @@ extern "C" { #if defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) #define OPENSSL_RAND_DETERMINISTIC -#elif defined(OPENSSL_FUCHSIA) -#define OPENSSL_RAND_FUCHSIA #elif defined(OPENSSL_TRUSTY) // Trusty's PRNG file is, for now, maintained outside the tree. #elif defined(OPENSSL_WINDOWS) diff --git a/crypto/rand_extra/fuchsia.c b/crypto/rand_extra/fuchsia.c deleted file mode 100644 index d4fb9797a..000000000 --- a/crypto/rand_extra/fuchsia.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2017, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#include - -#include "../fipsmodule/rand/internal.h" - -#if defined(OPENSSL_RAND_FUCHSIA) - -#include -#include - -#include - -void CRYPTO_sysrand(uint8_t *out, size_t requested) { - zx_cprng_draw(out, requested); -} - -void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { - CRYPTO_sysrand(out, requested); -} - -#endif // OPENSSL_RAND_FUCHSIA diff --git a/crypto/rand_extra/getentropy.c b/crypto/rand_extra/getentropy.c index fddf0beed..d4b5e68e3 100644 --- a/crypto/rand_extra/getentropy.c +++ b/crypto/rand_extra/getentropy.c @@ -22,7 +22,7 @@ #include #include -#if defined(OPENSSL_MACOS) +#if defined(OPENSSL_MACOS) || defined(OPENSSL_FUCHSIA) #include #endif