aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1/p5_pbev2.c
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-05-31 16:31:18 +1000
committerPauli <pauli@openssl.org>2021-06-01 18:13:56 +1000
commit28cab20916731c188180628330de27f6ce5f684e (patch)
treef85f272ab8aba403ab10401af29deeda217f0138 /crypto/asn1/p5_pbev2.c
parentdfefa4c16424cb3628b2a75b53c11e0be5247baa (diff)
downloadopenssl-28cab20916731c188180628330de27f6ce5f684e.zip
openssl-28cab20916731c188180628330de27f6ce5f684e.tar.gz
openssl-28cab20916731c188180628330de27f6ce5f684e.tar.bz2
crypto: updates to pass size_t to RAND_bytes_ex()
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/15540)
Diffstat (limited to 'crypto/asn1/p5_pbev2.c')
-rw-r--r--crypto/asn1/p5_pbev2.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/asn1/p5_pbev2.c b/crypto/asn1/p5_pbev2.c
index d16fb8c..162e31d 100644
--- a/crypto/asn1/p5_pbev2.c
+++ b/crypto/asn1/p5_pbev2.c
@@ -45,7 +45,7 @@ X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter,
OSSL_LIB_CTX *libctx)
{
X509_ALGOR *scheme = NULL, *ret = NULL;
- int alg_nid, keylen;
+ int alg_nid, keylen, ivlen;
EVP_CIPHER_CTX *ctx = NULL;
unsigned char iv[EVP_MAX_IV_LENGTH];
PBE2PARAM *pbe2 = NULL;
@@ -66,11 +66,11 @@ X509_ALGOR *PKCS5_pbe2_set_iv_ex(const EVP_CIPHER *cipher, int iter,
goto merr;
/* Create random IV */
- if (EVP_CIPHER_iv_length(cipher)) {
+ ivlen = EVP_CIPHER_iv_length(cipher);
+ if (ivlen > 0) {
if (aiv)
- memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher));
- else if (RAND_bytes_ex(libctx, iv, EVP_CIPHER_iv_length(cipher),
- 0) <= 0)
+ memcpy(iv, aiv, ivlen);
+ else if (RAND_bytes_ex(libctx, iv, ivlen, 0) <= 0)
goto err;
}