static ENGINE *funct_ref;
static CRYPTO_RWLOCK *rand_engine_lock;
# endif
+# ifndef OPENSSL_NO_DEPRECATED_3_0
static CRYPTO_RWLOCK *rand_meth_lock;
static const RAND_METHOD *default_RAND_meth;
+# endif
static CRYPTO_ONCE rand_init = CRYPTO_ONCE_STATIC_INIT;
static int rand_inited = 0;
return 0;
# endif
+# ifndef OPENSSL_NO_DEPRECATED_3_0
rand_meth_lock = CRYPTO_THREAD_lock_new();
if (rand_meth_lock == NULL)
goto err;
+# endif
if (!rand_pool_init())
goto err;
return 1;
err:
+# ifndef OPENSSL_NO_DEPRECATED_3_0
CRYPTO_THREAD_lock_free(rand_meth_lock);
rand_meth_lock = NULL;
+# endif
# ifndef OPENSSL_NO_ENGINE
CRYPTO_THREAD_lock_free(rand_engine_lock);
rand_engine_lock = NULL;
void rand_cleanup_int(void)
{
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = default_RAND_meth;
if (!rand_inited)
if (meth != NULL && meth->cleanup != NULL)
meth->cleanup();
RAND_set_rand_method(NULL);
+# endif
rand_pool_cleanup();
# ifndef OPENSSL_NO_ENGINE
CRYPTO_THREAD_lock_free(rand_engine_lock);
rand_engine_lock = NULL;
# endif
+# ifndef OPENSSL_NO_DEPRECATED_3_0
CRYPTO_THREAD_lock_free(rand_meth_lock);
rand_meth_lock = NULL;
+# endif
rand_inited = 0;
}
*/
int RAND_poll(void)
{
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
int ret = meth == RAND_OpenSSL();
if (meth == NULL)
return 0;
-#ifndef OPENSSL_NO_DEPRECATED_3_0
if (!ret) {
/* fill random pool and seed the current legacy RNG */
RAND_POOL *pool = rand_pool_new(RAND_DRBG_STRENGTH, 1,
err:
rand_pool_free(pool);
}
-#endif
return ret;
+# else
+ static const char salt[] = "polling";
+
+ RAND_seed(salt, sizeof(salt));
+ return 1;
+# endif
}
+# ifndef OPENSSL_NO_DEPRECATED_3_0
int RAND_set_rand_method(const RAND_METHOD *meth)
{
if (!RUN_ONCE(&rand_init, do_rand_init))
return 0;
CRYPTO_THREAD_write_lock(rand_meth_lock);
-# ifndef OPENSSL_NO_ENGINE
+# ifndef OPENSSL_NO_ENGINE
ENGINE_finish(funct_ref);
funct_ref = NULL;
-# endif
+# endif
default_RAND_meth = meth;
CRYPTO_THREAD_unlock(rand_meth_lock);
return 1;
CRYPTO_THREAD_write_lock(rand_meth_lock);
if (default_RAND_meth == NULL) {
-# ifndef OPENSSL_NO_ENGINE
+# ifndef OPENSSL_NO_ENGINE
ENGINE *e;
/* If we have an engine that can do RAND, use it. */
ENGINE_finish(e);
default_RAND_meth = &rand_meth;
}
-# else
+# else
default_RAND_meth = &rand_meth;
-# endif
+# endif
}
tmp_meth = default_RAND_meth;
CRYPTO_THREAD_unlock(rand_meth_lock);
return tmp_meth;
}
-# if !defined(OPENSSL_NO_ENGINE)
+# if !defined(OPENSSL_NO_ENGINE)
int RAND_set_rand_engine(ENGINE *engine)
{
const RAND_METHOD *tmp_meth = NULL;
CRYPTO_THREAD_unlock(rand_engine_lock);
return 1;
}
-# endif
+# endif
+# endif /* OPENSSL_NO_DEPRECATED_3_0 */
void RAND_seed(const void *buf, int num)
{
+ EVP_RAND_CTX *drbg;
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
- if (meth != NULL && meth->seed != NULL)
+ if (meth != NULL && meth->seed != NULL) {
meth->seed(buf, num);
+ return;
+ }
+# endif
+
+ drbg = RAND_get0_primary(NULL);
+ if (drbg != NULL && num > 0)
+ EVP_RAND_reseed(drbg, 0, NULL, 0, buf, num);
}
void RAND_add(const void *buf, int num, double randomness)
{
+ EVP_RAND_CTX *drbg;
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
- if (meth != NULL && meth->add != NULL)
+ if (meth != NULL && meth->add != NULL) {
meth->add(buf, num, randomness);
+ return;
+ }
+# endif
+ drbg = RAND_get0_primary(NULL);
+ if (drbg != NULL && num > 0)
+ EVP_RAND_reseed(drbg, 0, NULL, 0, buf, num);
}
# if !defined(OPENSSL_NO_DEPRECATED_1_1_0)
int RAND_status(void)
{
EVP_RAND_CTX *rand;
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth != NULL && meth != RAND_OpenSSL())
return meth->status != NULL ? meth->status() : 0;
+# endif
if ((rand = RAND_get0_primary(NULL)) == NULL)
return 0;
return EVP_RAND_state(rand) == EVP_RAND_STATE_READY;
}
-#else /* !FIPS_MODULE */
+# else /* !FIPS_MODULE */
+# ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *RAND_get_rand_method(void)
{
return NULL;
}
+# endif
#endif /* !FIPS_MODULE */
/*
int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num)
{
EVP_RAND_CTX *rand;
+#ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth != NULL && meth != RAND_OpenSSL()) {
ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
return -1;
}
+#endif
rand = RAND_get0_private(ctx);
if (rand != NULL)
int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num)
{
EVP_RAND_CTX *rand;
+#ifndef OPENSSL_NO_DEPRECATED_3_0
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth != NULL && meth != RAND_OpenSSL()) {
ERR_raise(ERR_LIB_RAND, RAND_R_FUNC_NOT_IMPLEMENTED);
return -1;
}
+#endif
rand = RAND_get0_public(ctx);
if (rand != NULL)
#ifndef FIPS_MODULE
static int random_set_string(char **p, const char *s)
{
- char *d = OPENSSL_strdup(s);
+ char *d = NULL;
- if (d == NULL) {
- ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE);
- return 0;
+ if (s != NULL) {
+ d = OPENSSL_strdup(s);
+ if (d == NULL) {
+ ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
}
OPENSSL_free(*p);
*p = d;
OSSL_TRACE(CONF, "Adding config module 'random'\n");
CONF_module_add("random", random_conf_init, random_conf_deinit);
}
+
+int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq,
+ const char *cipher, const char *digest)
+{
+ RAND_GLOBAL *dgbl = rand_get_global(ctx);
+
+ if (dgbl == NULL)
+ return 0;
+ if (dgbl->primary != NULL) {
+ ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
+ return 0;
+ }
+ return random_set_string(&dgbl->rng_name, drbg)
+ && random_set_string(&dgbl->rng_propq, propq)
+ && random_set_string(&dgbl->rng_cipher, cipher)
+ && random_set_string(&dgbl->rng_digest, digest);
+}
+
+int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed,
+ const char *propq)
+{
+ RAND_GLOBAL *dgbl = rand_get_global(ctx);
+
+ if (dgbl == NULL)
+ return 0;
+ if (dgbl->primary != NULL) {
+ ERR_raise(ERR_LIB_CRYPTO, RAND_R_ALREADY_INSTANTIATED);
+ return 0;
+ }
+ return random_set_string(&dgbl->seed_name, seed)
+ && random_set_string(&dgbl->seed_propq, propq);
+}
+
#endif
X509_set_pubkey 75 3_0_0 EXIST::FUNCTION:
ASN1_item_print 76 3_0_0 EXIST::FUNCTION:
CONF_set_nconf 77 3_0_0 EXIST::FUNCTION:
-RAND_set_rand_method 78 3_0_0 EXIST::FUNCTION:
+RAND_set_rand_method 78 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0
BN_GF2m_mod_mul 79 3_0_0 EXIST::FUNCTION:EC2M
UI_add_input_boolean 80 3_0_0 EXIST::FUNCTION:
ASN1_TIME_adj 81 3_0_0 EXIST::FUNCTION:
EVP_PKCS82PKEY 171 3_0_0 EXIST::FUNCTION:
BN_generate_prime_ex 172 3_0_0 EXIST::FUNCTION:
EVP_EncryptInit 173 3_0_0 EXIST::FUNCTION:
-RAND_OpenSSL 174 3_0_0 EXIST::FUNCTION:
+RAND_OpenSSL 174 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0
BN_uadd 175 3_0_0 EXIST::FUNCTION:
EVP_PKEY_derive_init 176 3_0_0 EXIST::FUNCTION:
PEM_write_bio_ASN1_stream 177 3_0_0 EXIST::FUNCTION:
EVP_aes_192_wrap 1430 3_0_0 EXIST::FUNCTION:
OCSP_CERTID_it 1431 3_0_0 EXIST::FUNCTION:OCSP
ENGINE_get_RSA 1432 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,ENGINE
-RAND_get_rand_method 1433 3_0_0 EXIST::FUNCTION:
+RAND_get_rand_method 1433 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0
ERR_load_DSA_strings 1434 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,DSA
ASN1_check_infinite_end 1435 3_0_0 EXIST::FUNCTION:
i2d_PKCS7_DIGEST 1436 3_0_0 EXIST::FUNCTION:
X509_CERT_AUX_it 1787 3_0_0 EXIST::FUNCTION:
X509_get_X509_PUBKEY 1789 3_0_0 EXIST::FUNCTION:
TXT_DB_create_index 1790 3_0_0 EXIST::FUNCTION:
-RAND_set_rand_engine 1791 3_0_0 EXIST::FUNCTION:ENGINE
+RAND_set_rand_engine 1791 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,ENGINE
X509_set_serialNumber 1792 3_0_0 EXIST::FUNCTION:
BN_mod_exp_mont_consttime 1793 3_0_0 EXIST::FUNCTION:
X509V3_parse_list 1794 3_0_0 EXIST::FUNCTION:
EVP_PKEY_param_check_quick ? 3_0_0 EXIST::FUNCTION:
EVP_PKEY_public_check_quick ? 3_0_0 EXIST::FUNCTION:
EVP_PKEY_CTX_is_a ? 3_0_0 EXIST::FUNCTION:
+RAND_set_DRBG_type ? 3_0_0 EXIST::FUNCTION:
+RAND_set_seed_source_type ? 3_0_0 EXIST::FUNCTION: