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/cmp | |
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/cmp')
-rw-r--r-- | crypto/cmp/cmp_client.c | 9 | ||||
-rw-r--r-- | crypto/cmp/cmp_err.c | 2 | ||||
-rw-r--r-- | crypto/cmp/cmp_local.h | 1 | ||||
-rw-r--r-- | crypto/cmp/cmp_msg.c | 4 | ||||
-rw-r--r-- | crypto/cmp/cmp_server.c | 10 | ||||
-rw-r--r-- | crypto/cmp/cmp_vfy.c | 8 |
6 files changed, 18 insertions, 16 deletions
diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index c7a846f03e..f8d9f0749c 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -34,7 +34,7 @@ static int unprotected_exception(const OSSL_CMP_CTX *ctx, int invalid_protection, int expected_type /* ignored here */) { - int rcvd_type = ossl_cmp_msg_get_bodytype(rep /* may be NULL */); + int rcvd_type = OSSL_CMP_MSG_get_bodytype(rep /* may be NULL */); const char *msg_type = NULL; if (!ossl_assert(ctx != NULL && rep != NULL)) @@ -132,7 +132,7 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req, || expected_type == OSSL_CMP_PKIBODY_POLLREP || expected_type == OSSL_CMP_PKIBODY_PKICONF; const char *req_type_str = - ossl_cmp_bodytype_to_string(ossl_cmp_msg_get_bodytype(req)); + ossl_cmp_bodytype_to_string(OSSL_CMP_MSG_get_bodytype(req)); const char *expected_type_str = ossl_cmp_bodytype_to_string(expected_type); int msg_timeout; int bt; @@ -177,7 +177,7 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req, return 0; } - bt = ossl_cmp_msg_get_bodytype(*rep); + bt = OSSL_CMP_MSG_get_bodytype(*rep); /* * The body type in the 'bt' variable is not yet verified. * Still we use this preliminary value already for a progress report because @@ -268,7 +268,7 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid, goto err; /* handle potential pollRep */ - if (ossl_cmp_msg_get_bodytype(prep) == OSSL_CMP_PKIBODY_POLLREP) { + if (OSSL_CMP_MSG_get_bodytype(prep) == OSSL_CMP_PKIBODY_POLLREP) { OSSL_CMP_POLLREPCONTENT *prc = prep->body->value.pollRep; OSSL_CMP_POLLREP *pollRep = NULL; int64_t check_after; @@ -818,6 +818,7 @@ int OSSL_CMP_exec_RR_ses(OSSL_CMP_CTX *ctx) goto err; } if ((cid = ossl_cmp_revrepcontent_get_CertId(rrep, rsid)) == NULL) { + ERR_raise(ERR_LIB_CMP, CMP_R_MISSING_CERTID); ret = 0; goto err; } diff --git a/crypto/cmp/cmp_err.c b/crypto/cmp/cmp_err.c index e36696bef8..67d9964dbe 100644 --- a/crypto/cmp/cmp_err.c +++ b/crypto/cmp/cmp_err.c @@ -86,6 +86,7 @@ static const ERR_STRING_DATA CMP_str_reasons[] = { "fail info out of range"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_INVALID_ARGS), "invalid args"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_INVALID_OPTION), "invalid option"}, + {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_MISSING_CERTID), "missing certid"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_MISSING_KEY_INPUT_FOR_CREATING_PROTECTION), "missing key input for creating protection"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_MISSING_KEY_USAGE_DIGITALSIGNATURE), @@ -150,6 +151,7 @@ static const ERR_STRING_DATA CMP_str_reasons[] = { {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_VALUE_TOO_SMALL), "value too small"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_WRONG_ALGORITHM_OID), "wrong algorithm oid"}, + {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_WRONG_CERTID), "wrong certid"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_WRONG_CERTID_IN_RP), "wrong certid in rp"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_WRONG_PBM_VALUE), "wrong pbm value"}, {ERR_PACK(ERR_LIB_CMP, 0, CMP_R_WRONG_RP_COMPONENT_COUNT), diff --git a/crypto/cmp/cmp_local.h b/crypto/cmp/cmp_local.h index 1cca238916..f2a0587ca4 100644 --- a/crypto/cmp/cmp_local.h +++ b/crypto/cmp/cmp_local.h @@ -859,7 +859,6 @@ int ossl_cmp_msg_set0_libctx(OSSL_CMP_MSG *msg, OSSL_LIB_CTX *libctx, const char *propq); const char *ossl_cmp_bodytype_to_string(int type); int ossl_cmp_msg_set_bodytype(OSSL_CMP_MSG *msg, int type); -int ossl_cmp_msg_get_bodytype(const OSSL_CMP_MSG *msg); OSSL_CMP_MSG *ossl_cmp_msg_create(OSSL_CMP_CTX *ctx, int bodytype); OSSL_CMP_MSG *ossl_cmp_certreq_new(OSSL_CMP_CTX *ctx, int bodytype, const OSSL_CRMF_MSG *crm); diff --git a/crypto/cmp/cmp_msg.c b/crypto/cmp/cmp_msg.c index 4fef006933..5fb67ae2cb 100644 --- a/crypto/cmp/cmp_msg.c +++ b/crypto/cmp/cmp_msg.c @@ -93,7 +93,7 @@ int ossl_cmp_msg_set_bodytype(OSSL_CMP_MSG *msg, int type) return 1; } -int ossl_cmp_msg_get_bodytype(const OSSL_CMP_MSG *msg) +int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg) { if (!ossl_assert(msg != NULL && msg->body != NULL)) return -1; @@ -651,7 +651,7 @@ int ossl_cmp_msg_gen_push0_ITAV(OSSL_CMP_MSG *msg, OSSL_CMP_ITAV *itav) if (!ossl_assert(msg != NULL && itav != NULL)) return 0; - bodytype = ossl_cmp_msg_get_bodytype(msg); + bodytype = OSSL_CMP_MSG_get_bodytype(msg); if (bodytype != OSSL_CMP_PKIBODY_GENM && bodytype != OSSL_CMP_PKIBODY_GENP) { ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS); diff --git a/crypto/cmp/cmp_server.c b/crypto/cmp/cmp_server.c index 593c074f8d..59847f5fe1 100644 --- a/crypto/cmp/cmp_server.c +++ b/crypto/cmp/cmp_server.c @@ -167,7 +167,7 @@ static OSSL_CMP_MSG *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx, if (!ossl_assert(srv_ctx != NULL && srv_ctx->ctx != NULL && req != NULL)) return NULL; - switch (ossl_cmp_msg_get_bodytype(req)) { + switch (OSSL_CMP_MSG_get_bodytype(req)) { case OSSL_CMP_PKIBODY_P10CR: case OSSL_CMP_PKIBODY_CR: bodytype = OSSL_CMP_PKIBODY_CP; @@ -183,7 +183,7 @@ static OSSL_CMP_MSG *process_cert_request(OSSL_CMP_SRV_CTX *srv_ctx, return NULL; } - if (ossl_cmp_msg_get_bodytype(req) == OSSL_CMP_PKIBODY_P10CR) { + if (OSSL_CMP_MSG_get_bodytype(req) == OSSL_CMP_PKIBODY_P10CR) { certReqId = OSSL_CMP_CERTREQID; p10cr = req->body->value.p10cr; } else { @@ -428,7 +428,7 @@ static int unprotected_exception(const OSSL_CMP_CTX *ctx, invalid_protection ? "invalid" : "missing"); return 1; } - if (ossl_cmp_msg_get_bodytype(req) == OSSL_CMP_PKIBODY_ERROR + if (OSSL_CMP_MSG_get_bodytype(req) == OSSL_CMP_PKIBODY_ERROR && OSSL_CMP_CTX_get_option(ctx, OSSL_CMP_OPT_UNPROTECTED_ERRORS) == 1) { ossl_cmp_warn(ctx, "ignoring missing protection of error message"); return 1; @@ -469,7 +469,7 @@ OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx, if (!OSSL_CMP_CTX_set1_recipient(ctx, hdr->sender->d.directoryName)) goto err; - req_type = ossl_cmp_msg_get_bodytype(req); + req_type = OSSL_CMP_MSG_get_bodytype(req); switch (req_type) { case OSSL_CMP_PKIBODY_IR: case OSSL_CMP_PKIBODY_CR: @@ -588,7 +588,7 @@ OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx, ctx->secretValue = backup_secret; rsp_type = - rsp != NULL ? ossl_cmp_msg_get_bodytype(rsp) : OSSL_CMP_PKIBODY_ERROR; + rsp != NULL ? OSSL_CMP_MSG_get_bodytype(rsp) : OSSL_CMP_PKIBODY_ERROR; if (rsp != NULL) ossl_cmp_log1(DEBUG, ctx, "sending %s", ossl_cmp_bodytype_to_string(rsp_type)); diff --git a/crypto/cmp/cmp_vfy.c b/crypto/cmp/cmp_vfy.c index 28c9a984d2..aa4665a562 100644 --- a/crypto/cmp/cmp_vfy.c +++ b/crypto/cmp/cmp_vfy.c @@ -406,7 +406,7 @@ static int check_msg_all_certs(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg, if (mode_3gpp && ((!ctx->permitTAInExtraCertsForIR - || ossl_cmp_msg_get_bodytype(msg) != OSSL_CMP_PKIBODY_IP))) + || OSSL_CMP_MSG_get_bodytype(msg) != OSSL_CMP_PKIBODY_IP))) return 0; ossl_cmp_info(ctx, @@ -576,7 +576,7 @@ int OSSL_CMP_validate_msg(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg) * the caPubs field may be directly trusted as a root CA * certificate by the initiator.' */ - switch (ossl_cmp_msg_get_bodytype(msg)) { + switch (OSSL_CMP_MSG_get_bodytype(msg)) { case -1: return 0; case OSSL_CMP_PKIBODY_IP: @@ -732,7 +732,7 @@ int ossl_cmp_msg_check_update(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg, #endif } - if (ossl_cmp_msg_get_bodytype(msg) < 0) { + if (OSSL_CMP_MSG_get_bodytype(msg) < 0) { #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION ERR_raise(ERR_LIB_CMP, CMP_R_PKIBODY_ERROR); return 0; @@ -793,7 +793,7 @@ int ossl_cmp_msg_check_update(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg, * the caPubs field may be directly trusted as a root CA * certificate by the initiator.' */ - switch (ossl_cmp_msg_get_bodytype(msg)) { + switch (OSSL_CMP_MSG_get_bodytype(msg)) { case OSSL_CMP_PKIBODY_IP: case OSSL_CMP_PKIBODY_CP: case OSSL_CMP_PKIBODY_KUP: |