Skip to content

Commit

Permalink
Fix PKINIT CMS error checking for older OpenSSL
Browse files Browse the repository at this point in the history
Commit 70f61d4 updated the
CMS_verify() error code checks, using two error codes new to OpenSSL
3.0 (RSA_R_DIGEST_NOT_ALLOWED and CMS_R_UNKNOWN_DIGEST_ALGORITHM).
This change broke the build for OpenSSL 1.0 and 1.1.

Instead of looking for codes indicating an algorithm issue and
assuming that everything else is an invalid signature, check for the
code indicating an invalid signature and assume that everything else
is an algorithm issue.

(cherry picked from commit e48e2e5)

ticket: 9069
version_fixed: 1.20.2
  • Loading branch information
greghudson committed Jul 6, 2023
1 parent 9a20519 commit a6971d2
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,18 +2102,10 @@ cms_signeddata_verify(krb5_context context,
goto cleanup;
out = BIO_new(BIO_s_mem());
if (CMS_verify(cms, NULL, store, NULL, out, flags) == 0) {
unsigned long err = ERR_peek_last_error();
switch(ERR_GET_REASON(err)) {
case RSA_R_DIGEST_NOT_ALLOWED:
case CMS_R_UNKNOWN_DIGEST_ALGORITHM:
case CMS_R_NO_MATCHING_DIGEST:
case CMS_R_NO_MATCHING_SIGNATURE:
retval = KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED;
break;
case CMS_R_VERIFICATION_FAILURE:
default:
if (ERR_peek_last_error() == CMS_R_VERIFICATION_FAILURE)
retval = KRB5KDC_ERR_INVALID_SIG;
}
else
retval = KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED;
(void)oerr(context, retval, _("Failed to verify CMS message"));
goto cleanup;
}
Expand Down

0 comments on commit a6971d2

Please sign in to comment.