e331fc1
From ba6e65e2f7e7fe8d9cd62e1e7e345bc41dda424f Mon Sep 17 00:00:00 2001
1eb7adc
From: rpm-build <rpm-build>
e331fc1
Date: Thu, 19 Oct 2023 13:12:40 +0200
e331fc1
Subject: [PATCH 21/46] 0047-FIPS-early-KATS.patch
1eb7adc
1eb7adc
Patch-name: 0047-FIPS-early-KATS.patch
1eb7adc
Patch-id: 47
1eb7adc
Patch-status: |
e331fc1
    # # Execute KATS before HMAC verification
e331fc1
From-dist-git-commit: 5c67b5adc311af297f425c09e3e1ac7ca8483911
1eb7adc
---
1eb7adc
 providers/fips/self_test.c | 22 ++++++++++------------
1eb7adc
 1 file changed, 10 insertions(+), 12 deletions(-)
1eb7adc
1eb7adc
diff --git a/providers/fips/self_test.c b/providers/fips/self_test.c
e331fc1
index e3a629018a..3c09bd8638 100644
1eb7adc
--- a/providers/fips/self_test.c
1eb7adc
+++ b/providers/fips/self_test.c
e331fc1
@@ -401,6 +401,16 @@ int SELF_TEST_post(SELF_TEST_POST_PARAMS *st, int on_demand_test)
080143c
     if (ev == NULL)
080143c
         goto end;
080143c
 
080143c
+    /*
080143c
+     * Run the KAT's before HMAC verification according to FIPS-140-3 requirements
080143c
+     */
080143c
+    if (kats_already_passed == 0) {
080143c
+        if (!SELF_TEST_kats(ev, st->libctx)) {
080143c
+            ERR_raise(ERR_LIB_PROV, PROV_R_SELF_TEST_KAT_FAILURE);
080143c
+            goto end;
080143c
+        }
080143c
+    }
080143c
+
f4c397c
    if (st->module_checksum_data == NULL) {
f4c397c
         module_checksum = fips_hmac_container;
f4c397c
         checksum_len = sizeof(fips_hmac_container);
e331fc1
@@ -451,18 +461,6 @@ int SELF_TEST_post(SELF_TEST_POST_PARAMS *st, int on_demand_test)
080143c
         }
080143c
     }
1eb7adc
 
080143c
-    /*
080143c
-     * Only runs the KAT's during installation OR on_demand().
080143c
-     * NOTE: If the installation option 'self_test_onload' is chosen then this
080143c
-     * path will always be run, since kats_already_passed will always be 0.
080143c
-     */
080143c
-    if (on_demand_test || kats_already_passed == 0) {
080143c
-        if (!SELF_TEST_kats(ev, st->libctx)) {
080143c
-            ERR_raise(ERR_LIB_PROV, PROV_R_SELF_TEST_KAT_FAILURE);
080143c
-            goto end;
080143c
-        }
080143c
-    }
1eb7adc
-
9409bc7
     /* Verify that the RNG has been restored properly */
e331fc1
     rng = ossl_rand_get0_private_noncreating(st->libctx);
e331fc1
     if (rng != NULL)
1eb7adc
-- 
1eb7adc
2.41.0
1eb7adc