From e0fbd0730995c8594ddf7408695f3a77263b64cd Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 10 Apr 2008 11:22:14 +0000 Subject: [PATCH] Add additional parameter to CMS_final() to handle detached content. --- apps/cms.c | 4 ++-- crypto/cms/cms.h | 2 +- crypto/cms/cms_smime.c | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/cms.c b/apps/cms.c index 620fe67075..b1ffb382ad 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -891,7 +891,7 @@ int MAIN(int argc, char **argv) } if (!(flags & CMS_STREAM)) { - if (!CMS_final(cms, in, flags)) + if (!CMS_final(cms, in, NULL, flags)) goto end; } } @@ -978,7 +978,7 @@ int MAIN(int argc, char **argv) /* If not streaming or resigning finalize structure */ if ((operation == SMIME_SIGN) && !(flags & CMS_STREAM)) { - if (!CMS_final(cms, in, flags)) + if (!CMS_final(cms, in, NULL, flags)) goto end; } } diff --git a/crypto/cms/cms.h b/crypto/cms/cms.h index db40f19581..9b32231d70 100644 --- a/crypto/cms/cms.h +++ b/crypto/cms/cms.h @@ -135,7 +135,7 @@ int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags) CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont); int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags); -int CMS_final(CMS_ContentInfo *cms, BIO *data, int flags); +int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags); CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, unsigned int flags); diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index b18c789f64..a9a11f5fdb 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -149,7 +149,7 @@ CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags) if (!cms) return NULL; - if ((flags & CMS_STREAM) || CMS_final(cms, in, flags)) + if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags)) return cms; CMS_ContentInfo_free(cms); @@ -194,7 +194,7 @@ CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, if(!(flags & CMS_DETACHED)) CMS_set_detached(cms, 0); - if ((flags & CMS_STREAM) || CMS_final(cms, in, flags)) + if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags)) return cms; CMS_ContentInfo_free(cms); @@ -246,7 +246,8 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, if(!(flags & CMS_DETACHED)) CMS_set_detached(cms, 0); - if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, in, flags)) + if ((flags & (CMS_STREAM|CMS_PARTIAL)) + || CMS_final(cms, in, NULL, flags)) return cms; CMS_ContentInfo_free(cms); @@ -459,7 +460,8 @@ CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, if(!(flags & CMS_DETACHED)) CMS_set_detached(cms, 0); - if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags)) + if ((flags & (CMS_STREAM|CMS_PARTIAL)) + || CMS_final(cms, data, NULL, flags)) return cms; else goto err; @@ -526,7 +528,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, goto err; /* Finalize structure */ - if (!CMS_final(cms, rct_cont, flags)) + if (!CMS_final(cms, rct_cont, NULL, flags)) goto err; /* Set embedded content */ @@ -567,7 +569,8 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data, if(!(flags & CMS_DETACHED)) CMS_set_detached(cms, 0); - if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags)) + if ((flags & (CMS_STREAM|CMS_PARTIAL)) + || CMS_final(cms, data, NULL, flags)) return cms; else goto err; @@ -679,11 +682,11 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert, return r; } -int CMS_final(CMS_ContentInfo *cms, BIO *data, int flags) +int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags) { BIO *cmsbio; int ret = 0; - if (!(cmsbio = CMS_dataInit(cms, NULL))) + if (!(cmsbio = CMS_dataInit(cms, dcont))) { CMSerr(CMS_F_CMS_FINAL,ERR_R_MALLOC_FAILURE); return 0; -- GitLab