Skip to content

Commit 2985755

Browse files
author
Andras Fekete
committed
Add in required FIPS callbacks
1 parent 2704dbd commit 2985755

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/wp_wolfprov.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,34 @@ static const OSSL_DISPATCH wolfprov_dispatch_table[] = {
11231123
{ 0, NULL }
11241124
};
11251125

1126+
#ifdef HAVE_FIPS
1127+
#include <wolfssl/wolfcrypt/fips_test.h>
1128+
1129+
static void wp_fipsCb(int ok, int err, const char* hash)
1130+
{
1131+
(void)ok;
1132+
(void)err;
1133+
(void)hash;
1134+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1135+
"in my Fips callback, ok = %d, err = %d\n", ok, err);
1136+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1137+
"message = %s\n", wc_GetErrorString(err));
1138+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1139+
"hash = %s\n", hash);
1140+
1141+
#ifdef WC_NO_ERR_TRACE
1142+
if (err == WC_NO_ERR_TRACE(IN_CORE_FIPS_E)) {
1143+
#else
1144+
if (err == IN_CORE_FIPS_E) {
1145+
#endif
1146+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1147+
"In core integrity hash check failure, copy above hash\n");
1148+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1149+
"into verifyCore[] in fips_test.c and rebuild\n");
1150+
}
1151+
}
1152+
#endif
1153+
11261154
/*
11271155
* Initializes the wolfSSL provider.
11281156
*
@@ -1144,6 +1172,10 @@ int wolfssl_provider_init(const OSSL_CORE_HANDLE* handle,
11441172
wolfSSL_SetLoggingPrefix("wolfSSL");
11451173
#endif
11461174

1175+
#ifdef HAVE_FIPS
1176+
wolfCrypt_SetCb_fips(wp_fipsCb);
1177+
#endif
1178+
11471179
for (; in->function_id != 0; in++) {
11481180
switch (in->function_id) {
11491181
case OSSL_FUNC_CORE_GETTABLE_PARAMS:

0 commit comments

Comments
 (0)