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

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