summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7/pk7_doit.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-05-10 00:47:42 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-05-10 00:47:42 +0000
commit884e8ec61533ee6361d72151066a808a0cfcd6d3 (patch)
tree45ea7a5baeef816089ea84b81e41e773762d0b9c /crypto/pkcs7/pk7_doit.c
parent9d5cceac6fb0eca8945f630afff1a2288aa6332a (diff)
Various PKCS#7 fixes to properly (maybe!) handle PKCS#7 enveloped data.
Containts elements of code by Sebastian Akerman <sak@parallelconsulting.com> and made a bit less "naughty" by Steve.
Diffstat (limited to 'crypto/pkcs7/pk7_doit.c')
-rw-r--r--crypto/pkcs7/pk7_doit.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c
index 1536aa8c1d..d19ee41073 100644
--- a/crypto/pkcs7/pk7_doit.c
+++ b/crypto/pkcs7/pk7_doit.c
@@ -156,19 +156,14 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio)
keylen=EVP_CIPHER_key_length(evp_cipher);
ivlen=EVP_CIPHER_iv_length(evp_cipher);
- if (ivlen > 0)
- {
- ASN1_OCTET_STRING *os;
-
- RAND_bytes(iv,ivlen);
- os=ASN1_OCTET_STRING_new();
- ASN1_OCTET_STRING_set(os,iv,ivlen);
-/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX this needs to change */
- if (xalg->parameter == NULL)
- xalg->parameter=ASN1_TYPE_new();
- ASN1_TYPE_set(xalg->parameter,V_ASN1_OCTET_STRING,
- (char *)os);
- }
+ if (ivlen > 0) {
+ EVP_CIPHER_CTX *ctx;
+ BIO_get_cipher_ctx(btmp, &ctx);
+ if (xalg->parameter == NULL)
+ xalg->parameter=ASN1_TYPE_new();
+ if(EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) < 0)
+ goto err;
+ }
RAND_bytes(key,keylen);
/* Lets do the pub key stuff :-) */