提交 d6f68fa3 编写于 作者: B Bodo Möller

Fix for previous patch: If RAND_pseudo_bytes returns 0, this is not an error.

上级 645820f2
...@@ -129,7 +129,7 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, ...@@ -129,7 +129,7 @@ X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt,
} }
pbe->salt->length = saltlen; pbe->salt->length = saltlen;
if (salt) memcpy (pbe->salt->data, salt, saltlen); if (salt) memcpy (pbe->salt->data, salt, saltlen);
else if (RAND_pseudo_bytes (pbe->salt->data, saltlen) <= 0) else if (RAND_pseudo_bytes (pbe->salt->data, saltlen) < 0)
return NULL; return NULL;
if (!(astype = ASN1_TYPE_new())) { if (!(astype = ASN1_TYPE_new())) {
......
...@@ -194,7 +194,8 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, ...@@ -194,7 +194,8 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
if(!(scheme->parameter = ASN1_TYPE_new())) goto merr; if(!(scheme->parameter = ASN1_TYPE_new())) goto merr;
/* Create random IV */ /* Create random IV */
RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)); if (RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0)
goto err;
/* Dummy cipherinit to just setup the IV */ /* Dummy cipherinit to just setup the IV */
EVP_CipherInit(&ctx, cipher, NULL, iv, 0); EVP_CipherInit(&ctx, cipher, NULL, iv, 0);
...@@ -212,7 +213,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, ...@@ -212,7 +213,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
if (!(osalt->data = Malloc (saltlen))) goto merr; if (!(osalt->data = Malloc (saltlen))) goto merr;
osalt->length = saltlen; osalt->length = saltlen;
if (salt) memcpy (osalt->data, salt, saltlen); if (salt) memcpy (osalt->data, salt, saltlen);
else if (RAND_pseudo_bytes (osalt->data, saltlen) <= 0) goto merr; else if (RAND_pseudo_bytes (osalt->data, saltlen) < 0) goto merr;
if(iter <= 0) iter = PKCS5_DEFAULT_ITER; if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr; if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;
......
...@@ -373,7 +373,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x, ...@@ -373,7 +373,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
kstr=(unsigned char *)buf; kstr=(unsigned char *)buf;
} }
RAND_add(data,i,0);/* put in the RSA key. */ RAND_add(data,i,0);/* put in the RSA key. */
if (RAND_pseudo_bytes(iv,8) <= 0) /* Generate a salt */ if (RAND_pseudo_bytes(iv,8) < 0) /* Generate a salt */
goto err; goto err;
/* The 'iv' is used as the iv and as a salt. It is /* The 'iv' is used as the iv and as a salt. It is
* NOT taken from the BytesToKey function */ * NOT taken from the BytesToKey function */
......
...@@ -157,7 +157,7 @@ int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen, ...@@ -157,7 +157,7 @@ int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
return 0; return 0;
} }
if (!salt) { if (!salt) {
if (RAND_pseudo_bytes (p12->mac->salt->data, saltlen) <= 0) if (RAND_pseudo_bytes (p12->mac->salt->data, saltlen) < 0)
return 0; return 0;
} }
else memcpy (p12->mac->salt->data, salt, saltlen); else memcpy (p12->mac->salt->data, salt, saltlen);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册