summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2004-03-28 17:38:00 +0000
committerDr. Stephen Henson <steve@openssl.org>2004-03-28 17:38:00 +0000
commit216659eb87485402a8e861a6de77233d1f5d7425 (patch)
treefb761bda98537dffb5029f9b7ad71b63a4e0530a /crypto/pkcs7
parent5d6383c83f34a9c8612a6eedd484d41e4be4974c (diff)
Enhance EVP code to generate random symmetric keys of the
appropriate form, for example correct DES parity. Update S/MIME code and EVP_SealInit to use new functions. PR: 700
Diffstat (limited to 'crypto/pkcs7')
-rw-r--r--crypto/pkcs7/pk7_doit.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 0b262fa065..25483bc156 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -215,11 +215,14 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
BIO_get_cipher_ctx(btmp, &ctx);
keylen=EVP_CIPHER_key_length(evp_cipher);
ivlen=EVP_CIPHER_iv_length(evp_cipher);
- if (RAND_bytes(key,keylen) <= 0)
- goto err;
xalg->algorithm = OBJ_nid2obj(EVP_CIPHER_type(evp_cipher));
if (ivlen > 0) RAND_pseudo_bytes(iv,ivlen);
- EVP_CipherInit_ex(ctx, evp_cipher, NULL, key, iv, 1);
+ if (EVP_CipherInit_ex(ctx, evp_cipher, NULL, NULL, NULL, 1)<=0)
+ goto err;
+ if (EVP_CIPHER_CTX_rand_key(ctx, key) <= 0)
+ goto err;
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, 1) <= 0)
+ goto err;
if (ivlen > 0) {
if (xalg->parameter == NULL)
@@ -440,7 +443,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
evp_ctx=NULL;
BIO_get_cipher_ctx(etmp,&evp_ctx);
- EVP_CipherInit_ex(evp_ctx,evp_cipher,NULL,NULL,NULL,0);
+ if (EVP_CipherInit_ex(evp_ctx,evp_cipher,NULL,NULL,NULL,0) <= 0)
+ goto err;
if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
goto err;
@@ -456,7 +460,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
goto err;
}
}
- EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0);
+ if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0)
+ goto err;
OPENSSL_cleanse(tmp,jj);