| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_RAND_INTERNAL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_RAND_INTERNAL_H |
| 17 |
| 18 | #include <openssl/base.h> |
| 19 |
| 20 | #if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) |
| 21 | #define OPENSSL_RAND_DETERMINISTIC |
| 22 | #elif defined(OPENSSL_TRUSTY) |
| 23 | #define OPENSSL_RAND_TRUSTY |
| 24 | #elif defined(OPENSSL_WINDOWS) |
| 25 | #define OPENSSL_RAND_WINDOWS |
| 26 | #elif defined(OPENSSL_LINUX) |
| 27 | #define OPENSSL_RAND_URANDOM |
| 28 | #elif defined(OPENSSL_APPLE) && !defined(OPENSSL_MACOS) |
| 29 | // Unlike macOS, iOS and similar hide away getentropy(). |
| 30 | #define OPENSSL_RAND_IOS |
| 31 | #else |
| 32 | // By default if you are integrating BoringSSL we expect you to |
| 33 | // provide getentropy from the <unistd.h> header file. |
| 34 | #define OPENSSL_RAND_GETENTROPY |
| 35 | #endif |
| 36 |
| 37 | #if defined(OPENSSL_LINUX) |
| 38 | // On linux we use MADVISE instead of pthread_atfork(), due |
| 39 | // to concerns about clone() being used for address space |
| 40 | // duplication. |
| 41 | #define OPENSSL_FORK_DETECTION |
| 42 | #define OPENSSL_FORK_DETECTION_MADVISE |
| 43 | #elif defined(OPENSSL_MACOS) || defined(OPENSSL_IOS) || \ |
| 44 | defined(OPENSSL_OPENBSD) || defined(OPENSSL_FREEBSD) |
| 45 | // These platforms may detect address space duplication with pthread_atfork. |
| 46 | // iOS doesn't normally allow fork in apps, but it's there. |
| 47 | #define OPENSSL_FORK_DETECTION |
| 48 | #define OPENSSL_FORK_DETECTION_PTHREAD_ATFORK |
| 49 | #elif defined(OPENSSL_WINDOWS) || defined(OPENSSL_TRUSTY) || \ |
| 50 | defined(__ZEPHYR__) || defined(CROS_EC) |
| 51 | // These platforms do not fork. |
| 52 | #define OPENSSL_DOES_NOT_FORK |
| 53 | #endif |
| 54 |
| 55 | #endif // OPENSSL_HEADER_CRYPTO_RAND_INTERNAL_H |
| 56 |