Skip to content

Commit

Permalink
linuxkm/module_hooks.c: in wolfssl_init(), #ifdef HAVE_FIPS, wc_RunAl…
Browse files Browse the repository at this point in the history
…lCast_fips();

wolfcrypt/src/aes.c: add missing parens in GHASH_ONE_BLOCK_SW() to mollify clang-tidy;

wolfssl/wolfcrypt/fips_test.h: add FIPS_CAST_AES_ECB;

wolfssl/wolfcrypt/settings.h: #ifdef WOLFSSL_LINUXKM, #undef HAVE_LIMITS_H.
  • Loading branch information
douzzer committed Jan 24, 2025
1 parent 3516c88 commit 7a55bc0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
57 changes: 32 additions & 25 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,38 @@ static int wolfssl_init(void)
}
return -ECANCELED;
}
#endif /* HAVE_FIPS */

#ifdef WC_RNG_SEED_CB
ret = wc_SetSeed_Cb(wc_GenerateSeed);
if (ret < 0) {
pr_err("wc_SetSeed_Cb() failed with return code %d.\n", ret);
(void)libwolfssl_cleanup();
msleep(10);
return -ECANCELED;
}
#endif

#ifdef WOLFCRYPT_ONLY
ret = wolfCrypt_Init();
if (ret != 0) {
pr_err("wolfCrypt_Init() failed: %s\n", wc_GetErrorString(ret));
return -ECANCELED;
}
#else
ret = wolfSSL_Init();
if (ret != WOLFSSL_SUCCESS) {
pr_err("wolfSSL_Init() failed: %s\n", wc_GetErrorString(ret));
return -ECANCELED;
}
#endif

#ifdef HAVE_FIPS
ret = wc_RunAllCast_fips();
if (ret != 0) {
pr_err("wc_RunAllCast_fips() failed with return value %d\n", ret);
return -ECANCELED;
}

pr_info("FIPS 140-3 wolfCrypt-fips v%d.%d.%d%s%s startup "
"self-test succeeded.\n",
Expand All @@ -270,33 +302,8 @@ static int wolfssl_init(void)
""
#endif
);

#endif /* HAVE_FIPS */

#ifdef WC_RNG_SEED_CB
ret = wc_SetSeed_Cb(wc_GenerateSeed);
if (ret < 0) {
pr_err("wc_SetSeed_Cb() failed with return code %d.\n", ret);
(void)libwolfssl_cleanup();
msleep(10);
return -ECANCELED;
}
#endif

#ifdef WOLFCRYPT_ONLY
ret = wolfCrypt_Init();
if (ret != 0) {
pr_err("wolfCrypt_Init() failed: %s\n", wc_GetErrorString(ret));
return -ECANCELED;
}
#else
ret = wolfSSL_Init();
if (ret != WOLFSSL_SUCCESS) {
pr_err("wolfSSL_Init() failed: %s\n", wc_GetErrorString(ret));
return -ECANCELED;
}
#endif

#ifndef NO_CRYPT_TEST
ret = wolfcrypt_test(NULL);
if (ret < 0) {
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -6886,7 +6886,7 @@ void GHASH(Gcm* gcm, const byte* a, word32 aSz, const byte* c,
#define GHASH_ONE_BLOCK_SW(aes, block) \
do { \
xorbuf(AES_TAG(aes), block, WC_AES_BLOCK_SIZE); \
GMULT(AES_TAG(aes), aes->gcm.H); \
GMULT(AES_TAG(aes), (aes)->gcm.H); \
} \
while (0)
#endif /* WOLFSSL_AESGCM_STREAM */
Expand Down
4 changes: 3 additions & 1 deletion wolfssl/wolfcrypt/fips_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ enum FipsCastId {
FIPS_CAST_ED25519 = 16,
FIPS_CAST_ED448 = 17,
FIPS_CAST_PBKDF2 = 18,
FIPS_CAST_COUNT = 19
/* v7.0.0 + */
FIPS_CAST_AES_ECB = 19,
FIPS_CAST_COUNT = 20
};

enum FipsCastStateId {
Expand Down
3 changes: 3 additions & 0 deletions wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3599,7 +3599,10 @@ extern void uITRON4_free(void *p) ;
#define WOLFSSL_TEST_SUBROUTINE static
#endif
#undef HAVE_PTHREAD
/* linuxkm uses linux/string.h, included by linuxkm_wc_port.h. */
#undef HAVE_STRINGS_H
/* linuxkm uses linux/limits.h, included by linuxkm_wc_port.h. */
#undef HAVE_LIMITS_H
#undef HAVE_ERRNO_H
#undef HAVE_THREAD_LS
#undef HAVE_ATEXIT
Expand Down

0 comments on commit 7a55bc0

Please sign in to comment.