summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-01-15 16:34:55 +0000
committerMatt Caswell <matt@openssl.org>2020-01-20 14:54:31 +0000
commit993ebac9ed38481e4d3795c437d4e98b985c68ce (patch)
tree0e30982d57fac860519fae6071b33988c7e68c11 /crypto
parent09a4cb9ec7ea9ccb4885588ba3e138b9f5f606c7 (diff)
Convert rand_bytes_ex and rand_priv_bytes_ex to public functions
These were initially added as internal functions only. However they will also need to be used by libssl as well. Therefore it make sense to move them into the public API. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10864)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/bn/bn_rand.c8
-rw-r--r--crypto/rand/rand_lib.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index d61b08dba2..2428a49efd 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -47,8 +47,8 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
}
/* make a random number and set the top and bottom bits */
- b = flag == NORMAL ? rand_bytes_ex(libctx, buf, bytes)
- : rand_priv_bytes_ex(libctx, buf, bytes);
+ b = flag == NORMAL ? RAND_bytes_ex(libctx, buf, bytes)
+ : RAND_priv_bytes_ex(libctx, buf, bytes);
if (b <= 0)
goto err;
@@ -60,7 +60,7 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom,
unsigned char c;
for (i = 0; i < bytes; i++) {
- if (rand_bytes_ex(libctx, &c, 1) <= 0)
+ if (RAND_bytes_ex(libctx, &c, 1) <= 0)
goto err;
if (c >= 128 && i > 0)
buf[i] = buf[i - 1];
@@ -280,7 +280,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
goto err;
}
for (done = 0; done < num_k_bytes;) {
- if (!rand_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes)))
+ if (!RAND_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes)))
goto err;
if (!EVP_DigestInit_ex(mdctx, md, NULL)
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 0be9db1c5f..86952739c0 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -851,7 +851,7 @@ void RAND_add(const void *buf, int num, double randomness)
* the default method, then just call RAND_bytes(). Otherwise make
* sure we're instantiated and use the private DRBG.
*/
-int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
+int RAND_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
{
RAND_DRBG *drbg;
const RAND_METHOD *meth = RAND_get_rand_method();
@@ -872,10 +872,10 @@ int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
int RAND_priv_bytes(unsigned char *buf, int num)
{
- return rand_priv_bytes_ex(NULL, buf, num);
+ return RAND_priv_bytes_ex(NULL, buf, num);
}
-int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
+int RAND_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
{
RAND_DRBG *drbg;
const RAND_METHOD *meth = RAND_get_rand_method();
@@ -896,7 +896,7 @@ int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num)
int RAND_bytes(unsigned char *buf, int num)
{
- return rand_bytes_ex(NULL, buf, num);
+ return RAND_bytes_ex(NULL, buf, num);
}
#if !defined(OPENSSL_NO_DEPRECATED_1_1_0) && !defined(FIPS_MODE)