Skip to content

Commit

Permalink
fixup! crypto/cmp/,apps/lib/cmp_mock_srv.c: various improvements on d…
Browse files Browse the repository at this point in the history
…elayed delivery
  • Loading branch information
DDvO committed Dec 20, 2023
1 parent ddfad87 commit 08e0f4f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/lib/cmp_mock_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,13 @@ static int process_pollReq(OSSL_CMP_SRV_CTX *srv_ctx,
{
mock_srv_ctx *ctx = OSSL_CMP_SRV_CTX_get0_custom_ctx(srv_ctx);

if (req != NULL)
*req = NULL;
if (ctx == NULL || pollReq == NULL
|| req == NULL || check_after == NULL) {
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
return 0;
}
*req = NULL;

if (ctx->sendError == 1
|| ctx->sendError == OSSL_CMP_MSG_get_bodytype(pollReq)) {
Expand Down
23 changes: 18 additions & 5 deletions crypto/cmp/cmp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ static OSSL_CMP_MSG *delayed_delivery(OSSL_CMP_SRV_CTX *srv_ctx,
const OSSL_CMP_MSG *req)
{
int ret;
unsigned long err;
int status = OSSL_CMP_PKISTATUS_waiting,
fail_info = 0, errorCode = 0;
const char *txt = NULL, *details = NULL;
OSSL_CMP_PKISI *si;
OSSL_CMP_MSG *msg;

Expand All @@ -179,16 +183,25 @@ static OSSL_CMP_MSG *delayed_delivery(OSSL_CMP_SRV_CTX *srv_ctx,
return NULL;

ret = srv_ctx->delayed_delivery(srv_ctx, req);
if (ret == 0 || !ossl_assert(ret != -1))
if (ret == 0)
return NULL;
if (ret == 1) {
srv_ctx->polling = 1;
} else {
status = OSSL_CMP_PKISTATUS_rejection;
fail_info = 1 << OSSL_CMP_PKIFAILUREINFO_systemFailure;
txt = "server application error";
err = ERR_peek_error();
errorCode = ERR_GET_REASON(err);
details = ERR_reason_error_string(err);
}

srv_ctx->polling = 1;
si = OSSL_CMP_STATUSINFO_new(OSSL_CMP_PKISTATUS_waiting, 0, NULL);
si = OSSL_CMP_STATUSINFO_new(status, fail_info, txt);
if (si == NULL)
return NULL;

msg = ossl_cmp_error_new(srv_ctx->ctx, si, 0,
NULL, srv_ctx->sendUnprotectedErrors);
msg = ossl_cmp_error_new(srv_ctx->ctx, si, errorCode, details,
srv_ctx->sendUnprotectedErrors);
OSSL_CMP_PKISI_free(si);
return msg;
}
Expand Down
4 changes: 4 additions & 0 deletions doc/man3/OSSL_CMP_SRV_CTX_new.pod
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ All other functions return 1 on success, 0 on error.

The OpenSSL CMP support was added in OpenSSL 3.0.

OSSL_CMP_SRV_CTX_init_trans()
supporting delayed delivery of all types of response messages
was added in OpenSSL 3.3.

=head1 COPYRIGHT

Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
Expand Down
2 changes: 1 addition & 1 deletion doc/man3/OSSL_CMP_exec_certreq.pod
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ The OpenSSL CMP support was added in OpenSSL 3.0.
OSSL_CMP_get1_caCerts() and OSSL_CMP_get1_rootCaKeyUpdate()
were added in OpenSSL 3.2.

Support for delayed delivery of all types of responses
Support for delayed delivery of all types of response messages
was added in OpenSSL 3.3.

=head1 COPYRIGHT
Expand Down

0 comments on commit 08e0f4f

Please sign in to comment.