diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2016-03-21 15:48:51 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-05-05 22:30:23 +0100 |
commit | 3fd60dc42288591737a35a90368d72dbd00fdef8 (patch) | |
tree | 1f85d76e5ba1380386401df3042cd6ecc2ffc3d1 | |
parent | 50b4a9ba1382de7a1990fb4716585754b9c7f50d (diff) | |
download | openssl-3fd60dc42288591737a35a90368d72dbd00fdef8.zip openssl-3fd60dc42288591737a35a90368d72dbd00fdef8.tar.gz openssl-3fd60dc42288591737a35a90368d72dbd00fdef8.tar.bz2 |
Always try to set ASN.1 parameters for CMS.
Try to set the ASN.1 parameters for CMS encryption even if the IV
length is zero as the underlying cipher should still set the type.
This will correctly result in errors if an attempt is made to use
an unsupported cipher type.
Reviewed-by: Rich Salz <rsalz@openssl.org>
-rw-r--r-- | crypto/cms/cms_enc.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c index 23adc2f..7d75f4b 100644 --- a/crypto/cms/cms_enc.c +++ b/crypto/cms/cms_enc.c @@ -176,17 +176,20 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) goto err; } - if (piv) { - calg->parameter = ASN1_TYPE_new(); - if (calg->parameter == NULL) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); - goto err; - } - if (EVP_CIPHER_param_to_asn1(ctx, calg->parameter) <= 0) { - CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, - CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); - goto err; - } + calg->parameter = ASN1_TYPE_new(); + if (calg->parameter == NULL) { + CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); + goto err; + } + if (EVP_CIPHER_param_to_asn1(ctx, calg->parameter) <= 0) { + CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, + CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); + goto err; + } + /* If paremeter type not set omit parameter */ + if (calg->parameter->type == V_ASN1_UNDEF) { + ASN1_TYPE_free(calg->parameter); + calg->parameter = NULL; } ok = 1; |