Add additional parameter to CMS_final() to handle detached content.
This commit is contained in:
parent
eaee098e1f
commit
e0fbd07309
@ -891,7 +891,7 @@ int MAIN(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (!(flags & CMS_STREAM))
|
if (!(flags & CMS_STREAM))
|
||||||
{
|
{
|
||||||
if (!CMS_final(cms, in, flags))
|
if (!CMS_final(cms, in, NULL, flags))
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,7 +978,7 @@ int MAIN(int argc, char **argv)
|
|||||||
/* If not streaming or resigning finalize structure */
|
/* If not streaming or resigning finalize structure */
|
||||||
if ((operation == SMIME_SIGN) && !(flags & CMS_STREAM))
|
if ((operation == SMIME_SIGN) && !(flags & CMS_STREAM))
|
||||||
{
|
{
|
||||||
if (!CMS_final(cms, in, flags))
|
if (!CMS_final(cms, in, NULL, flags))
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
|
||||||
int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);
|
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,
|
CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
|
||||||
BIO *data, unsigned int flags);
|
BIO *data, unsigned int flags);
|
||||||
|
@ -149,7 +149,7 @@ CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags)
|
|||||||
if (!cms)
|
if (!cms)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((flags & CMS_STREAM) || CMS_final(cms, in, flags))
|
if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
|
||||||
return cms;
|
return cms;
|
||||||
|
|
||||||
CMS_ContentInfo_free(cms);
|
CMS_ContentInfo_free(cms);
|
||||||
@ -194,7 +194,7 @@ CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
|
|||||||
if(!(flags & CMS_DETACHED))
|
if(!(flags & CMS_DETACHED))
|
||||||
CMS_set_detached(cms, 0);
|
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;
|
return cms;
|
||||||
|
|
||||||
CMS_ContentInfo_free(cms);
|
CMS_ContentInfo_free(cms);
|
||||||
@ -246,7 +246,8 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
|
|||||||
if(!(flags & CMS_DETACHED))
|
if(!(flags & CMS_DETACHED))
|
||||||
CMS_set_detached(cms, 0);
|
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;
|
return cms;
|
||||||
|
|
||||||
CMS_ContentInfo_free(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))
|
if(!(flags & CMS_DETACHED))
|
||||||
CMS_set_detached(cms, 0);
|
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;
|
return cms;
|
||||||
else
|
else
|
||||||
goto err;
|
goto err;
|
||||||
@ -526,7 +528,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* Finalize structure */
|
/* Finalize structure */
|
||||||
if (!CMS_final(cms, rct_cont, flags))
|
if (!CMS_final(cms, rct_cont, NULL, flags))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* Set embedded content */
|
/* Set embedded content */
|
||||||
@ -567,7 +569,8 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data,
|
|||||||
if(!(flags & CMS_DETACHED))
|
if(!(flags & CMS_DETACHED))
|
||||||
CMS_set_detached(cms, 0);
|
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;
|
return cms;
|
||||||
else
|
else
|
||||||
goto err;
|
goto err;
|
||||||
@ -679,11 +682,11 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
|
|||||||
return r;
|
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;
|
BIO *cmsbio;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (!(cmsbio = CMS_dataInit(cms, NULL)))
|
if (!(cmsbio = CMS_dataInit(cms, dcont)))
|
||||||
{
|
{
|
||||||
CMSerr(CMS_F_CMS_FINAL,ERR_R_MALLOC_FAILURE);
|
CMSerr(CMS_F_CMS_FINAL,ERR_R_MALLOC_FAILURE);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user