Add FIPS Self test kats for digests
[openssl.git] / providers / fips / fipsprov.c
index 788963911bcf6c55174fd134fe3762b697227406..cf4181dd2a87700e7fbd043862fe79202ed85666 100644 (file)
@@ -31,7 +31,7 @@
 #include "prov/provider_ctx.h"
 #include "prov/providercommon.h"
 #include "prov/provider_util.h"
-#include "selftest.h"
+#include "self_test.h"
 
 #define ALGC(NAMES, FUNC, CHECK) { { NAMES, "fips=yes", FUNC }, CHECK }
 #define ALG(NAMES, FUNC) ALGC(NAMES, FUNC, NULL)
@@ -649,9 +649,14 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
 {
     FIPS_GLOBAL *fgbl;
     OPENSSL_CTX *ctx;
+    OSSL_self_test_cb_fn *stcbfn = NULL;
+    OSSL_core_get_library_context_fn *c_get_libctx = NULL;
 
     for (; in->function_id != 0; in++) {
         switch (in->function_id) {
+        case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT:
+            c_get_libctx = OSSL_get_core_get_library_context(in);
+            break;
         case OSSL_FUNC_CORE_GETTABLE_PARAMS:
             c_gettable_params = OSSL_get_core_gettable_params(in);
             break;
@@ -715,12 +720,25 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
         case OSSL_FUNC_BIO_FREE:
             selftest_params.bio_free_cb = OSSL_get_BIO_free(in);
             break;
+        case OSSL_FUNC_SELF_TEST_CB: {
+            stcbfn = OSSL_get_self_test_cb(in);
+            break;
+        }
         default:
             /* Just ignore anything we don't understand */
             break;
         }
     }
 
+    if (stcbfn != NULL && c_get_libctx != NULL) {
+        stcbfn(c_get_libctx(provider), &selftest_params.event_cb,
+               &selftest_params.event_cb_arg);
+    }
+    else {
+        selftest_params.event_cb = NULL;
+        selftest_params.event_cb_arg = NULL;
+    }
+
     if (!c_get_params(provider, core_params))
         return 0;