提交 708cf5de 编写于 作者: D Dr. Stephen Henson

Only set CMS parameter when encrypting

Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 ec5b56f3
...@@ -175,21 +175,22 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) ...@@ -175,21 +175,22 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
CMS_R_CIPHER_INITIALISATION_ERROR); CMS_R_CIPHER_INITIALISATION_ERROR);
goto err; goto err;
} }
if (enc) {
calg->parameter = ASN1_TYPE_new(); calg->parameter = ASN1_TYPE_new();
if (calg->parameter == NULL) { if (calg->parameter == NULL) {
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
if (EVP_CIPHER_param_to_asn1(ctx, calg->parameter) <= 0) { if (EVP_CIPHER_param_to_asn1(ctx, calg->parameter) <= 0) {
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR); CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
goto err; goto err;
} }
/* If parameter type not set omit parameter */ /* If parameter type not set omit parameter */
if (calg->parameter->type == V_ASN1_UNDEF) { if (calg->parameter->type == V_ASN1_UNDEF) {
ASN1_TYPE_free(calg->parameter); ASN1_TYPE_free(calg->parameter);
calg->parameter = NULL; calg->parameter = NULL;
}
} }
ok = 1; ok = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册