diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2022-09-13 22:22:48 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2022-11-24 14:01:47 +0100 |
commit | cba0e2afd6a222aa041e05f8455e83c9e959d05b (patch) | |
tree | 49432cdd2b8288c076f48cdf1115265def904efa /crypto/cmp | |
parent | 19ddcc4cbb43464493a4b82332a1ab96da823451 (diff) |
CMP: fix handling of unset or missing failInfo PKI status information
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/19205)
Diffstat (limited to 'crypto/cmp')
-rw-r--r-- | crypto/cmp/cmp_client.c | 8 | ||||
-rw-r--r-- | crypto/cmp/cmp_status.c | 9 |
2 files changed, 6 insertions, 11 deletions
diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index 25f179e107..800f22316c 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -97,13 +97,7 @@ static int save_statusInfo(OSSL_CMP_CTX *ctx, OSSL_CMP_PKISI *si) if (ctx->status < OSSL_CMP_PKISTATUS_accepted) return 0; - ctx->failInfoCode = 0; - if (si->failInfo != NULL) { - for (i = 0; i <= OSSL_CMP_PKIFAILUREINFO_MAX; i++) { - if (ASN1_BIT_STRING_get_bit(si->failInfo, i)) - ctx->failInfoCode |= (1 << i); - } - } + ctx->failInfoCode = ossl_cmp_pkisi_get_pkifailureinfo(si); if (!ossl_cmp_ctx_set0_statusString(ctx, sk_ASN1_UTF8STRING_new_null()) || (ctx->statusString == NULL)) diff --git a/crypto/cmp/cmp_status.c b/crypto/cmp/cmp_status.c index 176c546f9c..5c02faec10 100644 --- a/crypto/cmp/cmp_status.c +++ b/crypto/cmp/cmp_status.c @@ -73,9 +73,10 @@ int ossl_cmp_pkisi_get_pkifailureinfo(const OSSL_CMP_PKISI *si) if (!ossl_assert(si != NULL)) return -1; - for (i = 0; i <= OSSL_CMP_PKIFAILUREINFO_MAX; i++) - if (ASN1_BIT_STRING_get_bit(si->failInfo, i)) - res |= 1 << i; + if (si->failInfo != NULL) + for (i = 0; i <= OSSL_CMP_PKIFAILUREINFO_MAX; i++) + if (ASN1_BIT_STRING_get_bit(si->failInfo, i)) + res |= 1 << i; return res; } @@ -193,7 +194,7 @@ char *snprint_PKIStatusInfo_parts(int status, int fail_info, * failInfo is optional and may be empty; * if present, print failInfo before statusString because it is more concise */ - if (fail_info != 0) { + if (fail_info != -1 && fail_info != 0) { printed_chars = BIO_snprintf(write_ptr, bufsize, "; PKIFailureInfo: "); ADVANCE_BUFFER; for (failure = 0; failure <= OSSL_CMP_PKIFAILUREINFO_MAX; failure++) { |