diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-25 18:16:18 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-05 09:39:10 +0200 |
commit | dea2878fac8bde549fa0dd3b8e895703b174391b (patch) | |
tree | 8e0b77927b65d77397e6294086b2aabe5b851e7f /crypto/pkcs7 | |
parent | Teach the ASN.1 code how to create embedded objects with libctx/propq (diff) | |
download | openssl-dea2878fac8bde549fa0dd3b8e895703b174391b.tar.xz openssl-dea2878fac8bde549fa0dd3b8e895703b174391b.zip |
Teach more of the ASN.1 code about libctx/propq
Make sure we pass libctx/propq down to all the layers so that objects that
are created during parsing have the right values. Then use this new
capability for PKCS7.
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/pkcs7')
-rw-r--r-- | crypto/pkcs7/pk7_asn1.c | 13 | ||||
-rw-r--r-- | crypto/pkcs7/pk7_mime.c | 9 |
2 files changed, 19 insertions, 3 deletions
diff --git a/crypto/pkcs7/pk7_asn1.c b/crypto/pkcs7/pk7_asn1.c index 60ad5b1e76..1cd867721e 100644 --- a/crypto/pkcs7/pk7_asn1.c +++ b/crypto/pkcs7/pk7_asn1.c @@ -66,8 +66,16 @@ ASN1_NDEF_SEQUENCE_cb(PKCS7, pk7_cb) = { PKCS7 *d2i_PKCS7(PKCS7 **a, const unsigned char **in, long len) { PKCS7 *ret; + OSSL_LIB_CTX *libctx = NULL; + const char *propq = NULL; - ret = (PKCS7 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (PKCS7_it())); + if (a != NULL && *a != NULL) { + libctx = (*a)->ctx.libctx; + propq = (*a)->ctx.propq; + } + + ret = (PKCS7 *)ASN1_item_d2i_ex((ASN1_VALUE **)a, in, len, (PKCS7_it()), + libctx, propq); if (ret != NULL) ossl_pkcs7_resolve_libctx(ret); return ret; @@ -85,7 +93,8 @@ PKCS7 *PKCS7_new(void) PKCS7 *PKCS7_new_ex(OSSL_LIB_CTX *libctx, const char *propq) { - PKCS7 *pkcs7 = PKCS7_new(); + PKCS7 *pkcs7 = (PKCS7 *)ASN1_item_new_ex(ASN1_ITEM_rptr(PKCS7), libctx, + propq); if (pkcs7 != NULL) { pkcs7->ctx.libctx = libctx; diff --git a/crypto/pkcs7/pk7_mime.c b/crypto/pkcs7/pk7_mime.c index b446423384..49a0da5f81 100644 --- a/crypto/pkcs7/pk7_mime.c +++ b/crypto/pkcs7/pk7_mime.c @@ -49,9 +49,16 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7) { PKCS7 *ret; + OSSL_LIB_CTX *libctx = NULL; + const char *propq = NULL; + + if (p7 != NULL && *p7 != NULL) { + libctx = (*p7)->ctx.libctx; + propq = (*p7)->ctx.propq; + } ret = (PKCS7 *)SMIME_read_ASN1_ex(bio, 0, bcont, ASN1_ITEM_rptr(PKCS7), - (ASN1_VALUE **)p7); + (ASN1_VALUE **)p7, libctx, propq); if (ret != NULL) ossl_pkcs7_resolve_libctx(ret); return ret; |