summaryrefslogtreecommitdiffstats
path: root/providers
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 /providers
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 'providers')
-rw-r--r--providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c4
-rw-r--r--providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c4
-rw-r--r--providers/implementations/ciphers/cipher_des.c4
-rw-r--r--providers/implementations/ciphers/cipher_tdes.c4
-rw-r--r--providers/implementations/ciphers/cipher_tdes_wrap.c4
-rw-r--r--providers/implementations/ciphers/ciphercommon_gcm.c6
6 files changed, 13 insertions, 13 deletions
diff --git a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c
index 57e59c30c3..04f60216ae 100644
--- a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c
+++ b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c
@@ -23,7 +23,7 @@ int cipher_capable_aes_cbc_hmac_sha1(void)
}
#else
-# include "crypto/rand.h"
+# include <openssl/rand.h>
# include "crypto/evp.h"
# include "internal/constant_time.h"
@@ -135,7 +135,7 @@ static size_t tls1_multi_block_encrypt(void *vctx,
# endif
/* ask for IVs in bulk */
- if (rand_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
+ if (RAND_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
return 0;
mctx = (SHA1_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */
diff --git a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c
index 26bc8f7c49..5cfa76fde5 100644
--- a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c
+++ b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c
@@ -23,7 +23,7 @@ int cipher_capable_aes_cbc_hmac_sha256(void)
}
#else
-# include "crypto/rand.h"
+# include <openssl/rand.h>
# include "crypto/evp.h"
# include "internal/constant_time.h"
@@ -139,7 +139,7 @@ static size_t tls1_multi_block_encrypt(void *vctx,
# endif
/* ask for IVs in bulk */
- if (rand_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
+ if (RAND_bytes_ex(ctx->base.libctx, (IVs = blocks[0].c), 16 * x4) <= 0)
return 0;
mctx = (SHA256_MB_CTX *) (storage + 32 - ((size_t)storage % 32)); /* align */
diff --git a/providers/implementations/ciphers/cipher_des.c b/providers/implementations/ciphers/cipher_des.c
index 200c365282..74539d3da4 100644
--- a/providers/implementations/ciphers/cipher_des.c
+++ b/providers/implementations/ciphers/cipher_des.c
@@ -9,7 +9,7 @@
#include "prov/ciphercommon.h"
#include "cipher_des.h"
-#include "crypto/rand.h"
+#include <openssl/rand.h>
#include "prov/implementations.h"
#include "prov/providercommonerr.h"
@@ -81,7 +81,7 @@ static int des_generatekey(PROV_CIPHER_CTX *ctx, void *ptr)
DES_cblock *deskey = ptr;
size_t kl = ctx->keylen;
- if (kl == 0 || rand_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
+ if (kl == 0 || RAND_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
return 0;
DES_set_odd_parity(deskey);
return 1;
diff --git a/providers/implementations/ciphers/cipher_tdes.c b/providers/implementations/ciphers/cipher_tdes.c
index e6dab582ca..80afcd5fd9 100644
--- a/providers/implementations/ciphers/cipher_tdes.c
+++ b/providers/implementations/ciphers/cipher_tdes.c
@@ -9,7 +9,7 @@
#include "prov/ciphercommon.h"
#include "cipher_tdes.h"
-#include "crypto/rand.h"
+#include <openssl/rand.h>
#include "prov/implementations.h"
#include "prov/providercommonerr.h"
@@ -71,7 +71,7 @@ static int tdes_generatekey(PROV_CIPHER_CTX *ctx, void *ptr)
DES_cblock *deskey = ptr;
size_t kl = ctx->keylen;
- if (kl == 0 || rand_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
+ if (kl == 0 || RAND_priv_bytes_ex(ctx->libctx, ptr, kl) <= 0)
return 0;
DES_set_odd_parity(deskey);
if (kl >= 16)
diff --git a/providers/implementations/ciphers/cipher_tdes_wrap.c b/providers/implementations/ciphers/cipher_tdes_wrap.c
index a6f4e4efe4..9db60ad2c7 100644
--- a/providers/implementations/ciphers/cipher_tdes_wrap.c
+++ b/providers/implementations/ciphers/cipher_tdes_wrap.c
@@ -14,9 +14,9 @@
#include "internal/deprecated.h"
#include <openssl/sha.h>
+#include <openssl/rand.h>
#include "cipher_tdes_default.h"
#include "crypto/evp.h"
-#include "crypto/rand.h"
#include "prov/implementations.h"
#include "prov/providercommonerr.h"
@@ -98,7 +98,7 @@ static int des_ede3_wrap(PROV_CIPHER_CTX *ctx, unsigned char *out,
memcpy(out + inl + ivlen, sha1tmp, icvlen);
OPENSSL_cleanse(sha1tmp, SHA_DIGEST_LENGTH);
/* Generate random IV */
- if (rand_bytes_ex(ctx->libctx, ctx->iv, ivlen) <= 0)
+ if (RAND_bytes_ex(ctx->libctx, ctx->iv, ivlen) <= 0)
return 0;
memcpy(out, ctx->iv, ivlen);
/* Encrypt everything after IV in place */
diff --git a/providers/implementations/ciphers/ciphercommon_gcm.c b/providers/implementations/ciphers/ciphercommon_gcm.c
index a6928e1ba3..a64462a5c1 100644
--- a/providers/implementations/ciphers/ciphercommon_gcm.c
+++ b/providers/implementations/ciphers/ciphercommon_gcm.c
@@ -12,7 +12,7 @@
#include "prov/ciphercommon.h"
#include "prov/ciphercommon_gcm.h"
#include "prov/providercommonerr.h"
-#include "crypto/rand.h"
+#include <openssl/rand.h>
#include "prov/provider_ctx.h"
static int gcm_tls_init(PROV_GCM_CTX *dat, unsigned char *aad, size_t aad_len);
@@ -338,7 +338,7 @@ static int gcm_iv_generate(PROV_GCM_CTX *ctx, int offset)
return 0;
/* Use DRBG to generate random iv */
- if (rand_bytes_ex(ctx->libctx, ctx->iv + offset, sz) <= 0)
+ if (RAND_bytes_ex(ctx->libctx, ctx->iv + offset, sz) <= 0)
return 0;
ctx->iv_state = IV_STATE_BUFFERED;
ctx->iv_gen_rand = 1;
@@ -452,7 +452,7 @@ static int gcm_tls_iv_set_fixed(PROV_GCM_CTX *ctx, unsigned char *iv,
if (len > 0)
memcpy(ctx->iv, iv, len);
if (ctx->enc
- && rand_bytes_ex(ctx->libctx, ctx->iv + len, ctx->ivlen - len) <= 0)
+ && RAND_bytes_ex(ctx->libctx, ctx->iv + len, ctx->ivlen - len) <= 0)
return 0;
ctx->iv_gen = 1;
ctx->iv_state = IV_STATE_BUFFERED;