Blame SOURCES/0064-CVE-2022-1343.diff

727bdf
diff --git a/crypto/ocsp/ocsp_vfy.c b/crypto/ocsp/ocsp_vfy.c
727bdf
index 7a4a45d537..3c5f48ec0a 100644
727bdf
--- a/crypto/ocsp/ocsp_vfy.c
727bdf
+++ b/crypto/ocsp/ocsp_vfy.c
727bdf
@@ -59,9 +59,10 @@ static int ocsp_verify_signer(X509 *signer, int response,
727bdf
 
727bdf
     ret = X509_verify_cert(ctx);
727bdf
     if (ret <= 0) {
727bdf
-        ret = X509_STORE_CTX_get_error(ctx);
727bdf
+        int err = X509_STORE_CTX_get_error(ctx);
727bdf
+
727bdf
         ERR_raise_data(ERR_LIB_OCSP, OCSP_R_CERTIFICATE_VERIFY_ERROR,
727bdf
-                       "Verify error: %s", X509_verify_cert_error_string(ret));
727bdf
+                       "Verify error: %s", X509_verify_cert_error_string(err));
727bdf
         goto end;
727bdf
     }
727bdf
     if (chain != NULL)
727bdf
diff --git a/test/recipes/80-test_ocsp.t b/test/recipes/80-test_ocsp.t
727bdf
index d42030cb89..34fdfcbccc 100644
727bdf
--- a/test/recipes/80-test_ocsp.t
727bdf
+++ b/test/recipes/80-test_ocsp.t
727bdf
@@ -35,6 +35,7 @@ sub test_ocsp {
727bdf
         $untrusted = $CAfile;
727bdf
     }
727bdf
     my $expected_exit = shift;
727bdf
+    my $nochecks = shift;
727bdf
     my $outputfile = basename($inputfile, '.ors') . '.dat';
727bdf
 
727bdf
     run(app(["openssl", "base64", "-d",
727bdf
@@ -45,7 +46,8 @@ sub test_ocsp {
727bdf
                            "-partial_chain", @check_time,
727bdf
                            "-CAfile", catfile($ocspdir, $CAfile),
727bdf
                            "-verify_other", catfile($ocspdir, $untrusted),
727bdf
-                           "-no-CApath", "-no-CAstore"])),
727bdf
+                           "-no-CApath", "-no-CAstore",
727bdf
+                           $nochecks ? "-no_cert_checks" : ()])),
727bdf
                   $title); });
727bdf
 }
727bdf
 
727bdf
@@ -55,143 +57,149 @@ subtest "=== VALID OCSP RESPONSES ===" => sub {
727bdf
     plan tests => 7;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "ND1.ors", "ND1_Issuer_ICA.pem", "", 0);
727bdf
+              "ND1.ors", "ND1_Issuer_ICA.pem", "", 0, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ND2.ors", "ND2_Issuer_Root.pem", "", 0);
727bdf
+              "ND2.ors", "ND2_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "ND3.ors", "ND3_Issuer_Root.pem", "", 0);
727bdf
+              "ND3.ors", "ND3_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("NON-DELEGATED; 3-level CA hierarchy",
727bdf
-              "ND1.ors", "ND1_Cross_Root.pem", "ND1_Issuer_ICA-Cross.pem", 0);
727bdf
+              "ND1.ors", "ND1_Cross_Root.pem", "ND1_Issuer_ICA-Cross.pem", 0, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "D1.ors", "D1_Issuer_ICA.pem", "", 0);
727bdf
+              "D1.ors", "D1_Issuer_ICA.pem", "", 0, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "D2.ors", "D2_Issuer_Root.pem", "", 0);
727bdf
+              "D2.ors", "D2_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "D3.ors", "D3_Issuer_Root.pem", "", 0);
727bdf
+              "D3.ors", "D3_Issuer_Root.pem", "", 0, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== INVALID SIGNATURE on the OCSP RESPONSE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "ISOP_ND1.ors", "ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "ISOP_ND1.ors", "ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ISOP_ND2.ors", "ND2_Issuer_Root.pem", "", 1);
727bdf
+              "ISOP_ND2.ors", "ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "ISOP_ND3.ors", "ND3_Issuer_Root.pem", "", 1);
727bdf
+              "ISOP_ND3.ors", "ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "ISOP_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "ISOP_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ISOP_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "ISOP_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "ISOP_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "ISOP_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG RESPONDERID in the OCSP RESPONSE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "WRID_ND1.ors", "ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "WRID_ND1.ors", "ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WRID_ND2.ors", "ND2_Issuer_Root.pem", "", 1);
727bdf
+              "WRID_ND2.ors", "ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "WRID_ND3.ors", "ND3_Issuer_Root.pem", "", 1);
727bdf
+              "WRID_ND3.ors", "ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "WRID_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "WRID_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WRID_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "WRID_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "WRID_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "WRID_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG ISSUERNAMEHASH in the OCSP RESPONSE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "WINH_ND1.ors", "ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "WINH_ND1.ors", "ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WINH_ND2.ors", "ND2_Issuer_Root.pem", "", 1);
727bdf
+              "WINH_ND2.ors", "ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "WINH_ND3.ors", "ND3_Issuer_Root.pem", "", 1);
727bdf
+              "WINH_ND3.ors", "ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "WINH_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "WINH_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WINH_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "WINH_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "WINH_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "WINH_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG ISSUERKEYHASH in the OCSP RESPONSE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "WIKH_ND1.ors", "ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "WIKH_ND1.ors", "ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WIKH_ND2.ors", "ND2_Issuer_Root.pem", "", 1);
727bdf
+              "WIKH_ND2.ors", "ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "WIKH_ND3.ors", "ND3_Issuer_Root.pem", "", 1);
727bdf
+              "WIKH_ND3.ors", "ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "WIKH_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "WIKH_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WIKH_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "WIKH_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "WIKH_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "WIKH_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG KEY in the DELEGATED OCSP SIGNING CERTIFICATE ===" => sub {
727bdf
     plan tests => 3;
727bdf
 
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "WKDOSC_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "WKDOSC_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "WKDOSC_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "WKDOSC_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "WKDOSC_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "WKDOSC_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== INVALID SIGNATURE on the DELEGATED OCSP SIGNING CERTIFICATE ===" => sub {
727bdf
-    plan tests => 3;
727bdf
+    plan tests => 6;
727bdf
 
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "ISDOSC_D1.ors", "D1_Issuer_ICA.pem", "", 1);
727bdf
+              "ISDOSC_D1.ors", "D1_Issuer_ICA.pem", "", 1, 0);
727bdf
+    test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
+              "ISDOSC_D2.ors", "D2_Issuer_Root.pem", "", 1, 0);
727bdf
+    test_ocsp("DELEGATED; Root CA -> EE",
727bdf
+              "ISDOSC_D3.ors", "D3_Issuer_Root.pem", "", 1, 0);
727bdf
+    test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
+              "ISDOSC_D1.ors", "D1_Issuer_ICA.pem", "", 1, 1);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ISDOSC_D2.ors", "D2_Issuer_Root.pem", "", 1);
727bdf
+              "ISDOSC_D2.ors", "D2_Issuer_Root.pem", "", 1, 1);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "ISDOSC_D3.ors", "D3_Issuer_Root.pem", "", 1);
727bdf
+              "ISDOSC_D3.ors", "D3_Issuer_Root.pem", "", 1, 1);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG SUBJECT NAME in the ISSUER CERTIFICATE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "ND1.ors", "WSNIC_ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "ND1.ors", "WSNIC_ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ND2.ors", "WSNIC_ND2_Issuer_Root.pem", "", 1);
727bdf
+              "ND2.ors", "WSNIC_ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "ND3.ors", "WSNIC_ND3_Issuer_Root.pem", "", 1);
727bdf
+              "ND3.ors", "WSNIC_ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "D1.ors", "WSNIC_D1_Issuer_ICA.pem", "", 1);
727bdf
+              "D1.ors", "WSNIC_D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "D2.ors", "WSNIC_D2_Issuer_Root.pem", "", 1);
727bdf
+              "D2.ors", "WSNIC_D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "D3.ors", "WSNIC_D3_Issuer_Root.pem", "", 1);
727bdf
+              "D3.ors", "WSNIC_D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== WRONG KEY in the ISSUER CERTIFICATE ===" => sub {
727bdf
     plan tests => 6;
727bdf
 
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "ND1.ors", "WKIC_ND1_Issuer_ICA.pem", "", 1);
727bdf
+              "ND1.ors", "WKIC_ND1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ND2.ors", "WKIC_ND2_Issuer_Root.pem", "", 1);
727bdf
+              "ND2.ors", "WKIC_ND2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "ND3.ors", "WKIC_ND3_Issuer_Root.pem", "", 1);
727bdf
+              "ND3.ors", "WKIC_ND3_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "D1.ors", "WKIC_D1_Issuer_ICA.pem", "", 1);
727bdf
+              "D1.ors", "WKIC_D1_Issuer_ICA.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "D2.ors", "WKIC_D2_Issuer_Root.pem", "", 1);
727bdf
+              "D2.ors", "WKIC_D2_Issuer_Root.pem", "", 1, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "D3.ors", "WKIC_D3_Issuer_Root.pem", "", 1);
727bdf
+              "D3.ors", "WKIC_D3_Issuer_Root.pem", "", 1, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== INVALID SIGNATURE on the ISSUER CERTIFICATE ===" => sub {
727bdf
@@ -199,17 +207,17 @@ subtest "=== INVALID SIGNATURE on the ISSUER CERTIFICATE ===" => sub {
727bdf
 
727bdf
     # Expect success, because we're explicitly trusting the issuer certificate.
727bdf
     test_ocsp("NON-DELEGATED; Intermediate CA -> EE",
727bdf
-              "ND1.ors", "ISIC_ND1_Issuer_ICA.pem", "", 0);
727bdf
+              "ND1.ors", "ISIC_ND1_Issuer_ICA.pem", "", 0, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "ND2.ors", "ISIC_ND2_Issuer_Root.pem", "", 0);
727bdf
+              "ND2.ors", "ISIC_ND2_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("NON-DELEGATED; Root CA -> EE",
727bdf
-              "ND3.ors", "ISIC_ND3_Issuer_Root.pem", "", 0);
727bdf
+              "ND3.ors", "ISIC_ND3_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("DELEGATED; Intermediate CA -> EE",
727bdf
-              "D1.ors", "ISIC_D1_Issuer_ICA.pem", "", 0);
727bdf
+              "D1.ors", "ISIC_D1_Issuer_ICA.pem", "", 0, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> Intermediate CA",
727bdf
-              "D2.ors", "ISIC_D2_Issuer_Root.pem", "", 0);
727bdf
+              "D2.ors", "ISIC_D2_Issuer_Root.pem", "", 0, 0);
727bdf
     test_ocsp("DELEGATED; Root CA -> EE",
727bdf
-              "D3.ors", "ISIC_D3_Issuer_Root.pem", "", 0);
727bdf
+              "D3.ors", "ISIC_D3_Issuer_Root.pem", "", 0, 0);
727bdf
 };
727bdf
 
727bdf
 subtest "=== OCSP API TESTS===" => sub {