+CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a,
+ const unsigned char **in, long len)
+{
+ CMS_ContentInfo *ci;
+
+ ci = (CMS_ContentInfo *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
+ (CMS_ContentInfo_it()));
+ if (ci != NULL)
+ cms_resolve_libctx(ci);
+ return ci;
+}
+
+int i2d_CMS_ContentInfo(const CMS_ContentInfo *a, unsigned char **out)
+{
+ return ASN1_item_i2d((const ASN1_VALUE *)a, out, (CMS_ContentInfo_it()));
+}
+
+CMS_ContentInfo *CMS_ContentInfo_new_ex(OSSL_LIB_CTX *libctx, const char *propq)
+{
+ CMS_ContentInfo *ci;
+
+ ci = (CMS_ContentInfo *)ASN1_item_new(ASN1_ITEM_rptr(CMS_ContentInfo));
+ if (ci != NULL) {
+ ci->ctx.libctx = libctx;
+ ci->ctx.propq = NULL;
+ if (propq != NULL) {
+ ci->ctx.propq = OPENSSL_strdup(propq);
+ if (ci->ctx.propq == NULL) {
+ CMS_ContentInfo_free(ci);
+ ci = NULL;
+ ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
+ }
+ }
+ }
+ return ci;
+}
+
+CMS_ContentInfo *CMS_ContentInfo_new(void)
+{
+ return CMS_ContentInfo_new_ex(NULL, NULL);
+}
+
+void CMS_ContentInfo_free(CMS_ContentInfo *cms)
+{
+ if (cms != NULL) {
+ OPENSSL_free(cms->ctx.propq);
+ ASN1_item_free((ASN1_VALUE *)cms, ASN1_ITEM_rptr(CMS_ContentInfo));
+ }
+}
+
+const CMS_CTX *cms_get0_cmsctx(const CMS_ContentInfo *cms)
+{
+ return cms != NULL ? &cms->ctx : NULL;
+}
+
+OSSL_LIB_CTX *cms_ctx_get0_libctx(const CMS_CTX *ctx)
+{
+ return ctx != NULL ? ctx->libctx : NULL;
+}
+
+const char *cms_ctx_get0_propq(const CMS_CTX *ctx)
+{
+ return ctx != NULL ? ctx->propq : NULL;
+}
+
+void cms_resolve_libctx(CMS_ContentInfo *ci)
+{
+ int i;
+ CMS_CertificateChoices *cch;
+ STACK_OF(CMS_CertificateChoices) **pcerts;
+ const CMS_CTX *ctx = cms_get0_cmsctx(ci);
+ OSSL_LIB_CTX *libctx = cms_ctx_get0_libctx(ctx);
+ const char *propq = cms_ctx_get0_propq(ctx);
+
+ cms_SignerInfos_set_cmsctx(ci);
+ cms_RecipientInfos_set_cmsctx(ci);
+
+ pcerts = cms_get0_certificate_choices(ci);
+ if (pcerts != NULL) {
+ for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) {
+ cch = sk_CMS_CertificateChoices_value(*pcerts, i);
+ if (cch->type == CMS_CERTCHOICE_CERT)
+ x509_set0_libctx(cch->d.certificate, libctx, propq);
+ }
+ }
+}
+
+const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms)