Blame SOURCES/0047-FIPS-early-KATS.patch

bf760f
diff -up openssl-3.0.1/providers/fips/self_test.c.earlykats openssl-3.0.1/providers/fips/self_test.c
bf760f
--- openssl-3.0.1/providers/fips/self_test.c.earlykats	2022-01-19 13:10:00.635830783 +0100
bf760f
+++ openssl-3.0.1/providers/fips/self_test.c	2022-01-19 13:11:43.309342656 +0100
bf760f
@@ -362,6 +362,16 @@ int SELF_TEST_post(SELF_TEST_POST_PARAMS
bf760f
     if (ev == NULL)
bf760f
         goto end;
bf760f
 
bf760f
+    /*
bf760f
+     * Run the KAT's before HMAC verification according to FIPS-140-3 requirements
bf760f
+     */
bf760f
+    if (kats_already_passed == 0) {
bf760f
+        if (!SELF_TEST_kats(ev, st->libctx)) {
bf760f
+            ERR_raise(ERR_LIB_PROV, PROV_R_SELF_TEST_KAT_FAILURE);
bf760f
+            goto end;
bf760f
+        }
bf760f
+    }
bf760f
+
bf760f
     module_checksum = fips_hmac_container;
bf760f
     checksum_len = sizeof(fips_hmac_container);
bf760f
 
bf760f
@@ -411,18 +421,6 @@ int SELF_TEST_post(SELF_TEST_POST_PARAMS
bf760f
             kats_already_passed = 1;
bf760f
         }
bf760f
     }
bf760f
-
bf760f
-    /*
bf760f
-     * Only runs the KAT's during installation OR on_demand().
bf760f
-     * NOTE: If the installation option 'self_test_onload' is chosen then this
bf760f
-     * path will always be run, since kats_already_passed will always be 0.
bf760f
-     */
bf760f
-    if (on_demand_test || kats_already_passed == 0) {
bf760f
-        if (!SELF_TEST_kats(ev, st->libctx)) {
bf760f
-            ERR_raise(ERR_LIB_PROV, PROV_R_SELF_TEST_KAT_FAILURE);
bf760f
-            goto end;
bf760f
-        }
bf760f
-    }
bf760f
     ok = 1;
bf760f
 end:
bf760f
     OSSL_SELF_TEST_free(ev);