Clean up references to FIPS
[openssl.git] / crypto / rand / md_rand.c
index 7924478e9e8973654938941c4fa44775a24adf56..8cbfae170f4ab700141d220ce89fe29efce61877 100644 (file)
 
 #include <internal/thread_once.h>
 
-#ifdef OPENSSL_FIPS
-# include <openssl/fips.h>
-#endif
-
-#ifdef BN_DEBUG
+#if defined(BN_DEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
 # define PREDICT
 #endif
 
@@ -89,6 +85,7 @@ static RAND_METHOD rand_meth = {
 
 DEFINE_RUN_ONCE_STATIC(do_rand_lock_init)
 {
+    OPENSSL_init_crypto(0, NULL);
     rand_lock = CRYPTO_THREAD_lock_new();
     rand_tmp_lock = CRYPTO_THREAD_lock_new();
     return rand_lock != NULL && rand_tmp_lock != NULL;
@@ -125,6 +122,11 @@ static int rand_add(const void *buf, int num, double add)
     if (!num)
         return 1;
 
+#ifdef PREDICT
+    if (rand_predictable)
+        return 1;
+#endif
+
     /*
      * (Based on the rand(3) manpage)
      *
@@ -306,7 +308,7 @@ static int rand_bytes(unsigned char *buf, int num, int pseudo)
 
 #ifdef PREDICT
     if (rand_predictable) {
-        static unsigned char val = 0;
+        unsigned char val = 1;
 
         for (i = 0; i < num; i++)
             buf[i] = val++;