62 static int cms_copy_content(
BIO *out,
BIO *in,
unsigned int flags)
64 unsigned char buf[4096];
100 if (tmpout && (
BIO_write(tmpout, buf, i) != i))
116 if (tmpout && (tmpout != out))
133 static void do_free_upto(
BIO *
f,
BIO *upto)
162 r = cms_copy_content(out, cont, flags);
177 CMS_ContentInfo_free(cms);
193 if (!dcont && !check_content(cms))
199 r = cms_copy_content(out, cont, flags);
202 do_free_upto(cont, dcont);
222 CMS_ContentInfo_free(cms);
227 const unsigned char *
key,
size_t keylen,
228 BIO *dcont,
BIO *out,
unsigned int flags)
239 if (!dcont && !check_content(cms))
247 r = cms_copy_content(out, cont, flags);
248 do_free_upto(cont, dcont);
253 const unsigned char *
key,
size_t keylen,
262 cms = CMS_ContentInfo_new();
275 CMS_ContentInfo_free(cms);
324 int i, scount = 0, ret = 0;
325 BIO *cmsbio = NULL, *tmpin = NULL;
327 if (!dcont && !check_content(cms))
332 sinfos = CMS_get0_SignerInfos(cms);
361 cms_certs = CMS_get1_certs(cms);
363 crls = CMS_get1_crls(cms);
367 if (!cms_signerinfo_verify_cert(si, store,
368 cms_certs, crls, flags))
414 if (!cms_copy_content(out, cmsbio, flags))
435 if (dcont && (tmpin == dcont))
436 do_free_upto(cmsbio, dcont);
454 r =
CMS_verify(rcms, certs, store, NULL, NULL, flags);
466 cms = CMS_ContentInfo_new();
497 CMS_ContentInfo_free(cms);
509 BIO *rct_cont = NULL;
515 if (!pkey || !signcert)
523 cms =
CMS_sign(NULL, NULL, certs, NULL, flags);
554 if (!
CMS_final(cms, rct_cont, NULL, flags))
568 CMS_ContentInfo_free(cms);
605 CMS_ContentInfo_free(cms);
615 ris = CMS_get0_RecipientInfos(cms);
653 else if (r > 0 && debug)
670 unsigned char *
key,
size_t keylen,
671 unsigned char *
id,
size_t idlen)
676 ris = CMS_get0_RecipientInfos(cms);
714 ris = CMS_get0_RecipientInfos(cms);
743 if (!dcont && !check_content(cms))
749 if (!pk && !cert && !dcont && !out)
756 r = cms_copy_content(out, cont, flags);
757 do_free_upto(cont, dcont);
785 do_free_upto(cmsbio, dcont);
805 if (!dcont && !check_content(cms))
811 r = cms_copy_content(out, cont, flags);
812 do_free_upto(cont, dcont);
831 CMS_ContentInfo_free(cms);