diff options
author | Pauli <pauli@openssl.org> | 2021-05-28 06:46:17 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-05-29 09:17:12 +0200 |
commit | 965fa9c0804dadb6f99dedbff9255a2ce6ddb640 (patch) | |
tree | 794905b3e098208e30870722a231fcc63e0c5676 /providers | |
parent | ssl: add zero strenght arguments to BN and RAND RNG calls (diff) | |
download | openssl-965fa9c0804dadb6f99dedbff9255a2ce6ddb640.tar.xz openssl-965fa9c0804dadb6f99dedbff9255a2ce6ddb640.zip |
prov: add zero strenght arguments to BN and RAND RNG calls
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15513)
Diffstat (limited to 'providers')
8 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 bd1c611b42..f70e98508a 100644 --- a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c +++ b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha1_hw.c @@ -143,7 +143,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) <= 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 7001dfcd1c..14fbf63b03 100644 --- a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c +++ b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha256_hw.c @@ -147,7 +147,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) <= 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 4563ea2edb..d03d65b668 100644 --- a/providers/implementations/ciphers/cipher_des.c +++ b/providers/implementations/ciphers/cipher_des.c @@ -122,7 +122,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) <= 0) return 0; DES_set_odd_parity(deskey); return 1; diff --git a/providers/implementations/ciphers/cipher_tdes_common.c b/providers/implementations/ciphers/cipher_tdes_common.c index 88acc16049..346aec05a1 100644 --- a/providers/implementations/ciphers/cipher_tdes_common.c +++ b/providers/implementations/ciphers/cipher_tdes_common.c @@ -120,7 +120,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) <= 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 4bfd17f515..f6a859539e 100644 --- a/providers/implementations/ciphers/cipher_tdes_wrap.c +++ b/providers/implementations/ciphers/cipher_tdes_wrap.c @@ -97,7 +97,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) <= 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 b19e15b3b2..97a1af3191 100644 --- a/providers/implementations/ciphers/ciphercommon_gcm.c +++ b/providers/implementations/ciphers/ciphercommon_gcm.c @@ -371,7 +371,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) <= 0) return 0; ctx->iv_state = IV_STATE_BUFFERED; ctx->iv_gen_rand = 1; @@ -485,7 +485,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) <= 0) return 0; ctx->iv_gen = 1; ctx->iv_state = IV_STATE_BUFFERED; diff --git a/providers/implementations/kem/rsa_kem.c b/providers/implementations/kem/rsa_kem.c index 1ccc57a8da..313ab133b3 100644 --- a/providers/implementations/kem/rsa_kem.c +++ b/providers/implementations/kem/rsa_kem.c @@ -229,7 +229,7 @@ static int rsasve_gen_rand_bytes(RSA *rsa_pub, ret = (z != NULL && (BN_copy(nminus3, RSA_get0_n(rsa_pub)) != NULL) && BN_sub_word(nminus3, 3) - && BN_priv_rand_range_ex(z, nminus3, bnctx) + && BN_priv_rand_range_ex(z, nminus3, 0, bnctx) && BN_add_word(z, 2) && (BN_bn2binpad(z, out, outlen) == outlen)); BN_CTX_end(bnctx); diff --git a/providers/implementations/keymgmt/ecx_kmgmt.c b/providers/implementations/keymgmt/ecx_kmgmt.c index 506f350173..9de954651b 100644 --- a/providers/implementations/keymgmt/ecx_kmgmt.c +++ b/providers/implementations/keymgmt/ecx_kmgmt.c @@ -577,7 +577,7 @@ static void *ecx_gen(struct ecx_gen_ctx *gctx) ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); goto err; } - if (RAND_priv_bytes_ex(gctx->libctx, privkey, key->keylen) <= 0) + if (RAND_priv_bytes_ex(gctx->libctx, privkey, key->keylen, 0) <= 0) goto err; switch (gctx->type) { case ECX_KEY_TYPE_X25519: @@ -836,7 +836,7 @@ static void *s390x_ecx_keygen25519(struct ecx_gen_ctx *gctx) goto err; } - if (RAND_priv_bytes_ex(gctx->libctx, privkey, X25519_KEYLEN) <= 0) + if (RAND_priv_bytes_ex(gctx->libctx, privkey, X25519_KEYLEN, 0) <= 0) goto err; privkey[0] &= 248; @@ -882,7 +882,7 @@ static void *s390x_ecx_keygen448(struct ecx_gen_ctx *gctx) goto err; } - if (RAND_priv_bytes_ex(gctx->libctx, privkey, X448_KEYLEN) <= 0) + if (RAND_priv_bytes_ex(gctx->libctx, privkey, X448_KEYLEN, 0) <= 0) goto err; privkey[0] &= 252; @@ -934,7 +934,7 @@ static void *s390x_ecd_keygen25519(struct ecx_gen_ctx *gctx) goto err; } - if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED25519_KEYLEN) <= 0) + if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED25519_KEYLEN, 0) <= 0) goto err; sha = EVP_MD_fetch(gctx->libctx, "SHA512", gctx->propq); @@ -1004,7 +1004,7 @@ static void *s390x_ecd_keygen448(struct ecx_gen_ctx *gctx) shake = EVP_MD_fetch(gctx->libctx, "SHAKE256", gctx->propq); if (shake == NULL) goto err; - if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED448_KEYLEN) <= 0) + if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED448_KEYLEN, 0) <= 0) goto err; hashctx = EVP_MD_CTX_new(); |