#include <internal/thread_once.h>
#include "rand_lcl.h"
-#if defined(BN_DEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
-# define PREDICT 1
-#endif
-
#define STATE_SIZE 1023
typedef struct ossl_rand_state_st OSSL_RAND_STATE;
*/
static CRYPTO_THREAD_ID locking_threadid;
-#ifdef PREDICT
-int rand_predictable = 0;
-#endif
-
static int rand_hw_seed(EVP_MD_CTX *ctx);
static void rand_thread_cleanup(void *arg)
if (!num)
return 1;
-#ifdef PREDICT
- if (rand_predictable)
- return 1;
-#endif
-
/*
* (Based on the rand(3) manpage)
*
gettimeofday(&tv, NULL);
#endif
-#ifdef PREDICT
- if (rand_predictable) {
- unsigned char val = 1;
-
- for (i = 0; i < num; i++)
- buf[i] = val++;
- return (1);
- }
-#endif
-
if (num <= 0)
return 1;
#include <openssl/rand.h>
#include "fuzzer.h"
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-extern int rand_predictable;
-#endif
-#define ENTROPY_NEEDED 32
-
static ASN1_ITEM_EXP *item_type[] = {
ASN1_ITEM_ref(ACCESS_DESCRIPTION),
#ifndef OPENSSL_NO_RFC3779
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
ERR_get_state();
CRYPTO_free_ex_index(0, -1);
- RAND_add("", 1, ENTROPY_NEEDED);
- RAND_status();
-
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- rand_predictable = 1;
-#endif
+ FuzzerSetRand();
return 1;
}
#include <openssl/err.h>
#include "fuzzer.h"
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-extern int rand_predictable;
-#endif
-#define ENTROPY_NEEDED 32
-
/* unused, to avoid warning. */
static int idx;
ERR_get_state();
CRYPTO_free_ex_index(0, -1);
idx = SSL_get_ex_data_X509_STORE_CTX_idx();
- RAND_add("", 1, ENTROPY_NEEDED);
- RAND_status();
+ FuzzerSetRand();
comp_methods = SSL_COMP_get_compression_methods();
OPENSSL_sk_sort((OPENSSL_STACK *)comp_methods);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- rand_predictable = 1;
-#endif
-
return 1;
}
int FuzzerTestOneInput(const uint8_t *buf, size_t len);
int FuzzerInitialize(int *argc, char ***argv);
void FuzzerCleanup(void);
+void FuzzerSetRand(void);
};
#endif
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-extern int rand_predictable;
-#endif
-#define ENTROPY_NEEDED 32
-
/* unused, to avoid warning. */
static int idx;
ERR_get_state();
CRYPTO_free_ex_index(0, -1);
idx = SSL_get_ex_data_X509_STORE_CTX_idx();
- RAND_add("", 1, ENTROPY_NEEDED);
- RAND_status();
+ FuzzerSetRand();
comp_methods = SSL_COMP_get_compression_methods();
OPENSSL_sk_sort((OPENSSL_STACK *)comp_methods);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- rand_predictable = 1;
-#endif
-
return 1;
}
#include <stdlib.h>
#include <sys/stat.h>
#include <openssl/crypto.h>
+#include <openssl/rand.h>
#include "fuzzer.h"
+static int fuzz_bytes(unsigned char *buf, int num)
+{
+ unsigned char val = 1;
+
+ while (--num >= 0)
+ *buf++ = val++;
+ return 1;
+}
+
+static int fuzz_status(void)
+{
+ return 1;
+}
+
+static RAND_METHOD fuzz_rand_method = {
+ NULL,
+ fuzz_bytes,
+ NULL,
+ NULL,
+ fuzz_bytes,
+ fuzz_status
+};
+
+void FuzzerSetRand(void)
+{
+ RAND_set_rand_method(&fuzz_rand_method);
+}
+
+
+
int main(int argc, char **argv) {
int n;
#include <openssl/rand.h>
#include "fuzzer.h"
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-extern int rand_predictable;
-#endif
-#define ENTROPY_NEEDED 32
-
int FuzzerInitialize(int *argc, char ***argv)
{
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
ERR_get_state();
CRYPTO_free_ex_index(0, -1);
- RAND_add("", 1, ENTROPY_NEEDED);
- RAND_status();
-
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- rand_predictable = 1;
-#endif
+ FuzzerSetRand();
return 1;
}
int (*status) (void);
};
-# ifdef BN_DEBUG
-extern int rand_predictable;
-# endif
-
int RAND_set_rand_method(const RAND_METHOD *meth);
const RAND_METHOD *RAND_get_rand_method(void);
# ifndef OPENSSL_NO_ENGINE