diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-27 10:56:02 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-05 17:39:27 +1000 |
commit | 7be04a3ac40fb6cf83be2c619dc30625988c6742 (patch) | |
tree | 1fa067011552138e104b42eb78dcdc3894572f00 /crypto/asn1 | |
parent | 6282d6c28456543734defc45f653adeec1362958 (diff) |
Give ASN.1 objects the ability to report their libctx/propq
Some ASN.1 objects have an embedded libctx/propq. If they have one we
give the ASN.1 code the ability to find these values and use them where
needed. This is used for OSSL_CMP_MSG_dup() and X509_dup().
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/asn1')
-rw-r--r-- | crypto/asn1/a_dup.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto/asn1/a_dup.c b/crypto/asn1/a_dup.c index 2fa3ccd28a..93e8b2aa8d 100644 --- a/crypto/asn1/a_dup.c +++ b/crypto/asn1/a_dup.c @@ -56,6 +56,8 @@ void *ASN1_item_dup(const ASN1_ITEM *it, const void *x) const unsigned char *p; long i; ASN1_VALUE *ret; + OSSL_LIB_CTX *libctx = NULL; + const char *propq = NULL; if (x == NULL) return NULL; @@ -67,9 +69,12 @@ void *ASN1_item_dup(const ASN1_ITEM *it, const void *x) asn1_cb = aux != NULL ? aux->asn1_cb : NULL; } - if (asn1_cb != NULL - && !asn1_cb(ASN1_OP_DUP_PRE, (ASN1_VALUE **)&x, it, NULL)) - goto auxerr; + if (asn1_cb != NULL) { + if (!asn1_cb(ASN1_OP_DUP_PRE, (ASN1_VALUE **)&x, it, NULL) + || !asn1_cb(ASN1_OP_GET0_LIBCTX, (ASN1_VALUE **)&x, it, &libctx) + || !asn1_cb(ASN1_OP_GET0_PROPQ, (ASN1_VALUE **)&x, it, &propq)) + goto auxerr; + } i = ASN1_item_i2d(x, &b, it); if (b == NULL) { @@ -77,7 +82,7 @@ void *ASN1_item_dup(const ASN1_ITEM *it, const void *x) return NULL; } p = b; - ret = ASN1_item_d2i(NULL, &p, i, it); + ret = ASN1_item_d2i_ex(NULL, &p, i, it, libctx, propq); OPENSSL_free(b); if (asn1_cb != NULL |