Blame SOURCES/0010-Update-error-checking-for-OpenSSL-CMS_verify.patch

905476
From 75f71ace74449a6e5154314229bfa61960cd326c Mon Sep 17 00:00:00 2001
905476
From: Julien Rische <jrische@redhat.com>
905476
Date: Thu, 28 Jul 2022 15:20:12 +0200
905476
Subject: [PATCH] Update error checking for OpenSSL CMS_verify
905476
905476
The code for CMS data verification was initially written for OpenSSL's
905476
PKCS7_verify() function.  It now uses CMS_verify(), but error handling
905476
is still done using PKCS7_verify() error identifiers.  Update the
905476
recognized error codes so that the KDC generates
905476
KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED errors when appropriate.
905476
Use ERR_peek_last_error() to observe the error generated closest to
905476
the API surface.
905476
905476
[ghudson@mit.edu: edited commit message]
905476
905476
ticket: 9069 (new)
905476
tags: pullup
905476
target_version: 1.20-next
905476
---
905476
 src/plugins/preauth/pkinit/pkinit_crypto_openssl.c | 9 ++++++---
905476
 1 file changed, 6 insertions(+), 3 deletions(-)
905476
905476
diff --git a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
905476
index 1c2aa02827..16edf15cb2 100644
905476
--- a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
905476
+++ b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
905476
@@ -2102,12 +2102,15 @@ cms_signeddata_verify(krb5_context context,
905476
             goto cleanup;
905476
         out = BIO_new(BIO_s_mem());
905476
         if (CMS_verify(cms, NULL, store, NULL, out, flags) == 0) {
905476
-            unsigned long err = ERR_peek_error();
905476
+            unsigned long err = ERR_peek_last_error();
905476
             switch(ERR_GET_REASON(err)) {
905476
-            case PKCS7_R_DIGEST_FAILURE:
905476
+            case RSA_R_DIGEST_NOT_ALLOWED:
905476
+            case CMS_R_UNKNOWN_DIGEST_ALGORITHM:
905476
+            case CMS_R_NO_MATCHING_DIGEST:
905476
+            case CMS_R_NO_MATCHING_SIGNATURE:
905476
                 retval = KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED;
905476
                 break;
905476
-            case PKCS7_R_SIGNATURE_FAILURE:
905476
+            case CMS_R_VERIFICATION_FAILURE:
905476
             default:
905476
                 retval = KRB5KDC_ERR_INVALID_SIG;
905476
             }
905476
-- 
905476
2.38.1
905476