diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-25 17:46:11 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-05 17:39:10 +1000 |
commit | 5dca2afca3f5de55f3de3a404ede1a96c6d9af26 (patch) | |
tree | 17ad77f58a22d0b058cb05acfbda684e796a4315 /crypto | |
parent | dea2878fac8bde549fa0dd3b8e895703b174391b (diff) |
Use the new ASN.1 libctx aware functions in CMS
Make sure we pass the libctx around when working with CMS structures
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15591)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cms/cms_io.c | 13 | ||||
-rw-r--r-- | crypto/cms/cms_lib.c | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/crypto/cms/cms_io.c b/crypto/cms/cms_io.c index 9c260d0904..3768ea4db2 100644 --- a/crypto/cms/cms_io.c +++ b/crypto/cms/cms_io.c @@ -36,8 +36,11 @@ int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms) { CMS_ContentInfo *ci; + const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms == NULL ? NULL : *cms); - ci = ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms); + ci = ASN1_item_d2i_bio_ex(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms, + ossl_cms_ctx_get0_libctx(ctx), + ossl_cms_ctx_get0_propq(ctx)); if (ci != NULL) ossl_cms_resolve_libctx(ci); return ci; @@ -90,13 +93,17 @@ int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags) ossl_cms_ctx_get0_propq(ctx)); } -CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont, CMS_ContentInfo **cms) +CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont, + CMS_ContentInfo **cms) { CMS_ContentInfo *ci; + const CMS_CTX *ctx = ossl_cms_get0_cmsctx(cms == NULL ? NULL : *cms); ci = (CMS_ContentInfo *)SMIME_read_ASN1_ex(bio, flags, bcont, ASN1_ITEM_rptr(CMS_ContentInfo), - (ASN1_VALUE **)cms); + (ASN1_VALUE **)cms, + ossl_cms_ctx_get0_libctx(ctx), + ossl_cms_ctx_get0_propq(ctx)); if (ci != NULL) ossl_cms_resolve_libctx(ci); return ci; diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c index 673a1f7ad5..4ad9302910 100644 --- a/crypto/cms/cms_lib.c +++ b/crypto/cms/cms_lib.c @@ -28,9 +28,12 @@ CMS_ContentInfo *d2i_CMS_ContentInfo(CMS_ContentInfo **a, const unsigned char **in, long len) { CMS_ContentInfo *ci; + const CMS_CTX *ctx = ossl_cms_get0_cmsctx(a == NULL ? NULL : *a); - ci = (CMS_ContentInfo *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, - (CMS_ContentInfo_it())); + ci = (CMS_ContentInfo *)ASN1_item_d2i_ex((ASN1_VALUE **)a, in, len, + (CMS_ContentInfo_it()), + ossl_cms_ctx_get0_libctx(ctx), + ossl_cms_ctx_get0_propq(ctx)); if (ci != NULL) ossl_cms_resolve_libctx(ci); return ci; @@ -45,7 +48,8 @@ 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)); + ci = (CMS_ContentInfo *)ASN1_item_new_ex(ASN1_ITEM_rptr(CMS_ContentInfo), + libctx, propq); if (ci != NULL) { ci->ctx.libctx = libctx; ci->ctx.propq = NULL; |