diff options
author | Ulf Möller <ulf@openssl.org> | 2000-01-21 01:15:56 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-01-21 01:15:56 +0000 |
commit | e7f97e2d22e386df60c8da63277727a931bf22b7 (patch) | |
tree | 45c42494189d95fada508ac3ff806dee37c00d22 /crypto/asn1 | |
parent | 731d9c5fb5d0535e3c84866e3c355cbf21a92a67 (diff) |
Check RAND_bytes() return value or use RAND_pseudo_bytes().
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/p5_pbe.c | 3 | ||||
-rw-r--r-- | crypto/asn1/p5_pbev2.c | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/crypto/asn1/p5_pbe.c b/crypto/asn1/p5_pbe.c index adb92e5fd0..8cda4f609a 100644 --- a/crypto/asn1/p5_pbe.c +++ b/crypto/asn1/p5_pbe.c @@ -129,7 +129,8 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, } pbe->salt->length = saltlen; if (salt) memcpy (pbe->salt->data, salt, saltlen); - else RAND_bytes (pbe->salt->data, saltlen); + else if (RAND_bytes (pbe->salt->data, saltlen) <= 0) + return NULL; if (!(astype = ASN1_TYPE_new())) { ASN1err(ASN1_F_ASN1_PBE_SET,ERR_R_MALLOC_FAILURE); diff --git a/crypto/asn1/p5_pbev2.c b/crypto/asn1/p5_pbev2.c index 502a8c399d..44d5b5bc6e 100644 --- a/crypto/asn1/p5_pbev2.c +++ b/crypto/asn1/p5_pbev2.c @@ -194,7 +194,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; /* Create random IV */ - RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)); + RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)); /* Dummy cipherinit to just setup the IV */ EVP_CipherInit(&ctx, cipher, NULL, iv, 0); @@ -212,7 +212,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, if (!(osalt->data = Malloc (saltlen))) goto merr; osalt->length = saltlen; if (salt) memcpy (osalt->data, salt, saltlen); - else RAND_bytes (osalt->data, saltlen); + else if (RAND_bytes (osalt->data, saltlen) <= 0) goto merr; if(iter <= 0) iter = PKCS5_DEFAULT_ITER; if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; |