Skip to content

Commit 0ccab03

Browse files
committed
Call wolfCrypt_SetCb_fips in wolfengine_bind for FIPS builds.
We've had a lot of users come to us for support when wolfEngine can't be found, and the resolution often ends up being that the FIPS module integrity check failed and the expected HMAC value needs to be updated. This commit sets up a callback that will indicate the problem and how to fix it, just like we do for testwolfcrypt in wolfSSL.
1 parent 38ea470 commit 0ccab03

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

include/wolfengine/we_internal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@
8282
#include <wolfssl/wolfcrypt/random.h>
8383
#include <wolfssl/wolfcrypt/pwdbased.h>
8484
#ifdef HAVE_WOLFSSL_WOLFCRYPT_KDF_H
85-
#include <wolfssl/wolfcrypt/kdf.h>
85+
#include <wolfssl/wolfcrypt/kdf.h>
86+
#endif
87+
#ifdef HAVE_FIPS
88+
#include <wolfssl/wolfcrypt/fips_test.h>
8689
#endif
8790

8891
/* The DES3-CBC code won't compile unless wolfCrypt has support for it. */

src/we_internal.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,23 @@ static const ECDSA_METHOD *we_ecdsa(void)
13111311
#endif
13121312
#endif /* WE_HAVE_ECDSA */
13131313

1314+
#ifdef HAVE_FIPS
1315+
static void we_fips_cb(int ok, int err, const char* hash)
1316+
{
1317+
printf("*******************************************\n");
1318+
printf("we_fips_cb: ok = %d, err = %d\n", ok, err);
1319+
printf("error message = %s\n", wc_GetErrorString(err));
1320+
printf("hash = %s\n", hash);
1321+
1322+
if (err == IN_CORE_FIPS_E) {
1323+
printf("FIPS module integrity check failure. Copy above hash value "
1324+
"into verifyCore[] in wolfSSL's (NOT wolfEngine) fips_test.c "
1325+
"and rebuild wolfSSL.\n");
1326+
}
1327+
printf("*******************************************\n");
1328+
}
1329+
#endif
1330+
13141331
/**
13151332
* Bind the wolfengine into an engine object.
13161333
*
@@ -1324,6 +1341,10 @@ int wolfengine_bind(ENGINE *e, const char *id)
13241341

13251342
WOLFENGINE_ENTER(WE_LOG_ENGINE, "wolfengine_bind");
13261343

1344+
#ifdef HAVE_FIPS
1345+
wolfCrypt_SetCb_fips(we_fips_cb);
1346+
#endif
1347+
13271348
if ((id != NULL) &&
13281349
(XSTRNCMP(id, wolfengine_id, XSTRLEN(wolfengine_id)) != 0)) {
13291350
ret = 0;

0 commit comments

Comments
 (0)