diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-06-16 10:26:26 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-06-30 10:38:23 +0200 |
commit | 7df56adac7cf58b4ad3e8e34077ccd988263f408 (patch) | |
tree | 19132b8de64b3b271c72fae4bd744bf8aa1746c0 /crypto/crmf/crmf_lib.c | |
parent | b9bc8eb0546b22d7b23b25dc62eb5a459f745b98 (diff) |
CMP: Add missing getter functions to CRMF API and CMP API
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15790)
Diffstat (limited to 'crypto/crmf/crmf_lib.c')
-rw-r--r-- | crypto/crmf/crmf_lib.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/crypto/crmf/crmf_lib.c b/crypto/crmf/crmf_lib.c index d03904a7bc..22707b160a 100644 --- a/crypto/crmf/crmf_lib.c +++ b/crypto/crmf/crmf_lib.c @@ -42,13 +42,29 @@ * valt = Value Type * ctrlinf = "regCtrl" or "regInfo" */ -#define IMPLEMENT_CRMF_CTRL_FUNC(atyp, valt, ctrlinf) \ -int OSSL_CRMF_MSG_set1_##ctrlinf##_##atyp(OSSL_CRMF_MSG *msg, \ - const valt *in) \ +#define IMPLEMENT_CRMF_CTRL_FUNC(atyp, valt, ctrlinf) \ +valt *OSSL_CRMF_MSG_get0_##ctrlinf##_##atyp(const OSSL_CRMF_MSG *msg) \ +{ \ + int i; \ + STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *controls; \ + OSSL_CRMF_ATTRIBUTETYPEANDVALUE *atav = NULL; \ + \ + if (msg == NULL || msg->certReq == NULL) \ + return NULL; \ + controls = msg->certReq->controls; \ + for (i = 0; i < sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_num(controls); i++) { \ + atav = sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_value(controls, i); \ + if (OBJ_obj2nid(atav->type) == NID_id_##ctrlinf##_##atyp) \ + return atav->value.atyp; \ + } \ + return NULL; \ +} \ + \ +int OSSL_CRMF_MSG_set1_##ctrlinf##_##atyp(OSSL_CRMF_MSG *msg, const valt *in) \ { \ OSSL_CRMF_ATTRIBUTETYPEANDVALUE *atav = NULL; \ \ - if (msg == NULL || in == NULL) \ + if (msg == NULL || in == NULL) \ goto err; \ if ((atav = OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new()) == NULL) \ goto err; \ @@ -515,6 +531,12 @@ ASN1_INTEGER return tmpl != NULL ? tmpl->serialNumber : NULL; } +const X509_NAME + *OSSL_CRMF_CERTTEMPLATE_get0_subject(const OSSL_CRMF_CERTTEMPLATE *tmpl) +{ + return tmpl != NULL ? tmpl->subject : NULL; +} + /* retrieves the issuer name of the given cert template or NULL on error */ const X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_issuer(const OSSL_CRMF_CERTTEMPLATE *tmpl) @@ -522,6 +544,12 @@ const X509_NAME return tmpl != NULL ? tmpl->issuer : NULL; } +X509_EXTENSIONS + *OSSL_CRMF_CERTTEMPLATE_get0_extensions(const OSSL_CRMF_CERTTEMPLATE *tmpl) +{ + return tmpl != NULL ? tmpl->extensions : NULL; +} + /* retrieves the issuer name of the given CertId or NULL on error */ const X509_NAME *OSSL_CRMF_CERTID_get0_issuer(const OSSL_CRMF_CERTID *cid) { |