Only set CMS parameter when encrypting
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 708cf5ded2
)
This commit is contained in:
parent
0c4465ede7
commit
6e216ba689
1 changed files with 16 additions and 15 deletions
|
@ -179,21 +179,22 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
|||
CMS_R_CIPHER_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 parameter type not set omit parameter */
|
||||
if (calg->parameter->type == V_ASN1_UNDEF) {
|
||||
ASN1_TYPE_free(calg->parameter);
|
||||
calg->parameter = NULL;
|
||||
if (enc) {
|
||||
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 parameter type not set omit parameter */
|
||||
if (calg->parameter->type == V_ASN1_UNDEF) {
|
||||
ASN1_TYPE_free(calg->parameter);
|
||||
calg->parameter = NULL;
|
||||
}
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue