Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ WC_DILITHIUM_CACHE_PUB_VECTORS
WC_DILITHIUM_FIXED_ARRAY
WC_DISABLE_RADIX_ZERO_PAD
WC_ECC_NONBLOCK_ONLY
WC_FLAG_DONT_USE_AESNI
WC_KDF_NIST_SP_800_56C
WC_LMS_FULL_HASH
WC_NO_RNG_SIMPLE
Expand All @@ -617,7 +618,7 @@ WC_SHA512
WC_SKIP_INCLUDED_C_FILES
WC_SSIZE_TYPE
WC_STRICT_SIG
WC_WANT_FLAG_DONT_USE_AESNI
WC_WANT_FLAG_DONT_USE_VECTOR_OPS
WC_XMSS_FULL_HASH
WIFIESPAT
WIFI_101
Expand Down
48 changes: 24 additions & 24 deletions linuxkm/linuxkm_wc_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@
#endif
#define WOLFSSL_LINUXKM_SIMD
#define WOLFSSL_LINUXKM_SIMD_X86
#ifndef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#define WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifndef WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#define WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#endif
#elif defined(WOLFSSL_ARMASM) || defined(WOLFSSL_SP_ARM32_ASM) || \
defined(WOLFSSL_SP_ARM64_ASM) || defined(WOLFSSL_SP_ARM_THUMB_ASM) ||\
Expand All @@ -158,8 +158,8 @@
#endif
#define WOLFSSL_LINUXKM_SIMD
#define WOLFSSL_LINUXKM_SIMD_ARM
#ifndef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#define WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifndef WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#define WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#endif
#endif

Expand Down Expand Up @@ -469,11 +469,11 @@
* SAVE_VECTOR_REGISTERS().
*/
#if defined(WOLFSSL_LINUXKM_BENCHMARKS) && \
!defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)
#define WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
!defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
#define WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#endif

#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && \
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && \
defined(CONFIG_X86)

extern __must_check int allocate_wolfcrypt_linuxkm_fpu_states(void);
Expand Down Expand Up @@ -526,7 +526,7 @@
#define REENABLE_VECTOR_REGISTERS() wc_restore_vector_registers_x86(WC_SVR_FLAG_INHIBIT)
#endif

#elif defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && (defined(CONFIG_ARM) || defined(CONFIG_ARM64))
#elif defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && (defined(CONFIG_ARM) || defined(CONFIG_ARM64))

#error kernel module ARM SIMD is not yet tested or usable.

Expand Down Expand Up @@ -562,9 +562,9 @@
#define RESTORE_VECTOR_REGISTERS() restore_vector_registers_arm()
#endif

#elif defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS */
#elif defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* WOLFSSL_USE_SAVE_VECTOR_REGISTERS */

_Pragma("GCC diagnostic pop");

Expand Down Expand Up @@ -817,7 +817,7 @@

struct task_struct *(*get_current)(void);

#ifdef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifdef WOLFSSL_USE_SAVE_VECTOR_REGISTERS

#ifdef CONFIG_X86
typeof(allocate_wolfcrypt_linuxkm_fpu_states) *allocate_wolfcrypt_linuxkm_fpu_states;
Expand All @@ -826,10 +826,10 @@
typeof(wc_restore_vector_registers_x86) *wc_restore_vector_registers_x86;
typeof(wc_save_vector_registers_x86) *wc_save_vector_registers_x86;
#else /* !CONFIG_X86 */
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* arch */

#endif /* WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS */
#endif /* WOLFSSL_USE_SAVE_VECTOR_REGISTERS */

typeof(__mutex_init) *__mutex_init;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
Expand Down Expand Up @@ -1113,15 +1113,15 @@
#undef get_current
#define get_current WC_LKM_INDIRECT_SYM(get_current)

#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
#define allocate_wolfcrypt_linuxkm_fpu_states WC_LKM_INDIRECT_SYM(allocate_wolfcrypt_linuxkm_fpu_states)
#define wc_can_save_vector_registers_x86 WC_LKM_INDIRECT_SYM(wc_can_save_vector_registers_x86)
#define free_wolfcrypt_linuxkm_fpu_states WC_LKM_INDIRECT_SYM(free_wolfcrypt_linuxkm_fpu_states)
#define wc_restore_vector_registers_x86 WC_LKM_INDIRECT_SYM(wc_restore_vector_registers_x86)
#define wc_save_vector_registers_x86 WC_LKM_INDIRECT_SYM(wc_save_vector_registers_x86)
#elif defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS */
#elif defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* WOLFSSL_USE_SAVE_VECTOR_REGISTERS */

#define __mutex_init WC_LKM_INDIRECT_SYM(__mutex_init)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
Expand Down Expand Up @@ -1217,11 +1217,11 @@
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) || \
(defined(RHEL_MAJOR) && \
((RHEL_MAJOR > 9) || ((RHEL_MAJOR == 9) && (RHEL_MINOR >= 5))))
#define lkm_printf(format, args...) _printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args)
#define wc_km_printf(format, args...) _printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args)
#else
#define lkm_printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args)
#define wc_km_printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args)
#endif
#define printf(...) lkm_printf(__VA_ARGS__)
#define printf(...) wc_km_printf(__VA_ARGS__)

#ifdef HAVE_FIPS
extern void fipsEntry(void);
Expand Down Expand Up @@ -1250,7 +1250,7 @@

#if !defined(BUILDING_WOLFSSL)
/* some caller code needs these. */
#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
#if defined(CONFIG_X86)
WOLFSSL_API __must_check int wc_can_save_vector_registers_x86(void);
WOLFSSL_API __must_check int wc_save_vector_registers_x86(enum wc_svr_flags flags);
Expand All @@ -1262,9 +1262,9 @@
#define REENABLE_VECTOR_REGISTERS() wc_restore_vector_registers_x86(WC_SVR_FLAG_INHIBIT)
#endif
#else /* !CONFIG_X86 */
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS is set for an unimplemented architecture.
#endif /* !CONFIG_X86 */
#endif /* WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS */
#endif /* WOLFSSL_USE_SAVE_VECTOR_REGISTERS */
#endif /* !BUILDING_WOLFSSL */

/* Copied from wc_port.h: For FIPS keep the function names the same */
Expand Down
19 changes: 12 additions & 7 deletions linuxkm/lkcapi_aes_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@

#include <wolfssl/wolfcrypt/aes.h>

#if defined(WC_LINUXKM_C_FALLBACK_IN_SHIMS) && !defined(WC_FLAG_DONT_USE_AESNI)
#error WC_LINUXKM_C_FALLBACK_IN_SHIMS is defined but WC_FLAG_DONT_USE_AESNI is missing.
#if defined(WC_FLAG_DONT_USE_AESNI) && !defined(WC_FLAG_DONT_USE_VECTOR_OPS)
/* backward compat */
#define WC_FLAG_DONT_USE_VECTOR_OPS WC_FLAG_DONT_USE_AESNI
#endif

#if defined(WC_LINUXKM_C_FALLBACK_IN_SHIMS) && !defined(WC_FLAG_DONT_USE_VECTOR_OPS)
#error WC_LINUXKM_C_FALLBACK_IN_SHIMS is defined but WC_FLAG_DONT_USE_VECTOR_OPS is missing.
#endif

/* note the FIPS code will be returned on failure even in non-FIPS builds. */
Expand Down Expand Up @@ -500,7 +505,7 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS

if (ctx->aes_encrypt->use_aesni) {
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_AESNI;
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;

err = wc_AesSetKey(ctx->aes_encrypt_C, in_key, key_len, NULL, AES_ENCRYPTION);

Expand All @@ -516,7 +521,7 @@ static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
}

if (ctx->aes_decrypt_C && ctx->aes_decrypt->use_aesni) {
ctx->aes_decrypt_C->use_aesni = WC_FLAG_DONT_USE_AESNI;
ctx->aes_decrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;

err = wc_AesSetKey(ctx->aes_decrypt_C, in_key, key_len, NULL,
AES_DECRYPTION);
Expand Down Expand Up @@ -927,7 +932,7 @@ static int km_AesGcmSetKey(struct crypto_aead *tfm, const u8 *in_key,

#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
if (ctx->aes_encrypt->use_aesni) {
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_AESNI;
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;

err = wc_AesGcmSetKey(ctx->aes_encrypt_C, in_key, key_len);

Expand Down Expand Up @@ -975,7 +980,7 @@ static int km_AesGcmSetKey_Rfc4106(struct crypto_aead *tfm, const u8 *in_key,

#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
if (ctx->aes_encrypt->use_aesni) {
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_AESNI;
ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;

err = wc_AesGcmSetKey(ctx->aes_encrypt_C, in_key, key_len);

Expand Down Expand Up @@ -1612,7 +1617,7 @@ static int km_AesXtsSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
}

/* It's possible to set ctx->aesXts->{tweak,aes,aes_decrypt}.use_aesni to
* WC_FLAG_DONT_USE_AESNI here, for WC_LINUXKM_C_FALLBACK_IN_SHIMS in
* WC_FLAG_DONT_USE_VECTOR_OPS here, for WC_LINUXKM_C_FALLBACK_IN_SHIMS in
* AES-XTS, but we can use the WC_C_DYNAMIC_FALLBACK mechanism
* unconditionally because there's no AES-XTS in Cert 4718.
*/
Expand Down
10 changes: 5 additions & 5 deletions linuxkm/module_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ int wc_linuxkm_GenerateSeed_IntelRD(struct OS_Seed* os, byte* output, word32 sz)

#endif /* WC_LINUXKM_RDSEED_IN_GLUE_LAYER */

#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
#include "linuxkm/x86_vector_register_glue.c"
#endif

Expand Down Expand Up @@ -1025,15 +1025,15 @@ static int set_up_wolfssl_linuxkm_pie_redirect_table(void) {

wolfssl_linuxkm_pie_redirect_table.get_current = my_get_current_thread;

#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
wolfssl_linuxkm_pie_redirect_table.allocate_wolfcrypt_linuxkm_fpu_states = allocate_wolfcrypt_linuxkm_fpu_states;
wolfssl_linuxkm_pie_redirect_table.wc_can_save_vector_registers_x86 = wc_can_save_vector_registers_x86;
wolfssl_linuxkm_pie_redirect_table.free_wolfcrypt_linuxkm_fpu_states = free_wolfcrypt_linuxkm_fpu_states;
wolfssl_linuxkm_pie_redirect_table.wc_restore_vector_registers_x86 = wc_restore_vector_registers_x86;
wolfssl_linuxkm_pie_redirect_table.wc_save_vector_registers_x86 = wc_save_vector_registers_x86;
#elif defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS is set for an unsupported architecture.
#endif /* WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS */
#elif defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS is set for an unsupported architecture.
#endif /* WOLFSSL_USE_SAVE_VECTOR_REGISTERS */

wolfssl_linuxkm_pie_redirect_table.__mutex_init = __mutex_init;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
Expand Down
4 changes: 2 additions & 2 deletions linuxkm/x86_vector_register_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/* included by linuxkm/module_hooks.c */
#ifndef WC_SKIP_INCLUDED_C_FILES

#if !defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) || !defined(CONFIG_X86)
#if !defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) || !defined(CONFIG_X86)
#error x86_vector_register_glue.c included in non-vectorized/non-x86 project.
#endif

Expand All @@ -39,7 +39,7 @@
* checks in __kernel_fpu_begin(), and lacks TIF_NEED_FPU_LOAD.
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0))
#error WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS on x86 requires kernel 5.4.0 or higher.
#error WOLFSSL_USE_SAVE_VECTOR_REGISTERS on x86 requires kernel 5.4.0 or higher.
#endif

static unsigned int wc_linuxkm_fpu_states_n_tracked = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CRL Options:
#include <wolfssl/error-ssl.h>
#include <wolfssl/wolfcrypt/logging.h>

#ifndef WOLFSSL_LINUXKM
#ifndef NO_STRING_H
#include <string.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/dtls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static int Dtls13GetRnMask(WOLFSSL* ssl, const byte* ciphertext, byte* mask,
return BAD_STATE_E;
#if !defined(HAVE_SELFTEST) && \
(!defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)) \
|| defined(WOLFSSL_LINUXKM))
|| defined(WOLFSSL_KERNEL_MODE))
return wc_AesEncryptDirect(c->aes, mask, ciphertext);
#else
wc_AesEncryptDirect(c->aes, mask, ciphertext);
Expand Down
2 changes: 1 addition & 1 deletion src/ssl_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -3102,7 +3102,7 @@ void wolfSSL_AES_encrypt(const unsigned char* input, unsigned char* output,
else
#if !defined(HAVE_SELFTEST) && \
(!defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3)) \
|| defined(WOLFSSL_LINUXKM))
|| defined(WOLFSSL_KERNEL_MODE))
/* Encrypt a block with wolfCrypt AES. */
if (wc_AesEncryptDirect((Aes*)key, output, input) != 0) {
WOLFSSL_MSG("wc_AesEncryptDirect failed");
Expand Down
10 changes: 5 additions & 5 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,7 @@ static WC_INLINE void bench_stats_start(int* count, double* start)
#endif
}

#ifdef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifdef WOLFSSL_USE_SAVE_VECTOR_REGISTERS
#define bench_stats_start(count, start) do { \
SAVE_VECTOR_REGISTERS(pr_err( \
"ERROR: SAVE_VECTOR_REGISTERS failed for benchmark run."); \
Expand Down Expand Up @@ -2746,7 +2746,7 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
(void)useDeviceID;
(void)ret;

#ifdef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifdef WOLFSSL_USE_SAVE_VECTOR_REGISTERS
RESTORE_VECTOR_REGISTERS();
#elif defined(WOLFSSL_LINUXKM)
kernel_fpu_end();
Expand Down Expand Up @@ -3009,7 +3009,7 @@ static void bench_stats_asym_finish_ex(const char* algo, int strength,
(void)useDeviceID;
(void)ret;

#ifdef WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS
#ifdef WOLFSSL_USE_SAVE_VECTOR_REGISTERS
RESTORE_VECTOR_REGISTERS();
#elif defined(WOLFSSL_LINUXKM)
kernel_fpu_end();
Expand Down Expand Up @@ -5021,7 +5021,7 @@ static void bench_aesecb_internal(int useDeviceID,
if (bench_async_check(&ret, BENCH_ASYNC_GET_DEV(enc[i]), 0,
&times, outer_loop_limit, &pending)) {
#ifdef HAVE_FIPS
#if defined(WOLFSSL_LINUXKM) || FIPS_VERSION_GE(6, 0)
#if defined(WOLFSSL_KERNEL_MODE) || FIPS_VERSION_GE(6, 0)
ret = wc_AesEncryptDirect(enc[i], bench_cipher, bench_plain);
if (ret != 0)
goto exit_aes_enc;
Expand Down Expand Up @@ -5078,7 +5078,7 @@ static void bench_aesecb_internal(int useDeviceID,
if (bench_async_check(&ret, BENCH_ASYNC_GET_DEV(enc[i]), 0,
&times, outer_loop_limit, &pending)) {
#ifdef HAVE_FIPS
#if defined(WOLFSSL_LINUXKM) || FIPS_VERSION_GE(6, 0)
#if defined(WOLFSSL_KERNEL_MODE) || FIPS_VERSION_GE(6, 0)
ret = wc_AesDecryptDirect(enc[i], bench_plain, bench_cipher);
if (ret != 0)
goto exit_aes_dec;
Expand Down
27 changes: 15 additions & 12 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4682,12 +4682,12 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir)
* AES-NI is disabled, and a nonzero value if it's enabled.
*
* An additional, optional semantic is available via
* WC_FLAG_DONT_USE_AESNI, and is used in some kernel module builds to
* let the caller inhibit AES-NI. When this macro is defined,
* WC_FLAG_DONT_USE_VECTOR_OPS, and is used in some kernel module builds
* to let the caller inhibit AES-NI. When this macro is defined,
* wc_AesInit() before wc_AesSetKey() is imperative, to avoid a read of
* uninitialized data in aes->use_aesni. That's why support for
* WC_FLAG_DONT_USE_AESNI must remain optional -- wc_AesInit() was only
* added in release 3.11.0, so legacy applications inevitably call
* WC_FLAG_DONT_USE_VECTOR_OPS must remain optional -- wc_AesInit() was
* only added in release 3.11.0, so legacy applications inevitably call
* wc_AesSetKey() on uninitialized Aes contexts. This must continue to
* function correctly with default build settings.
*/
Expand All @@ -4697,25 +4697,28 @@ static void AesSetKey_C(Aes* aes, const byte* key, word32 keySz, int dir)
checkedAESNI = 1;
}
if (haveAESNI
#if defined(WC_FLAG_DONT_USE_AESNI) && !defined(WC_C_DYNAMIC_FALLBACK)
&& (aes->use_aesni != WC_FLAG_DONT_USE_AESNI)
#if defined(WC_FLAG_DONT_USE_VECTOR_OPS) && !defined(WC_C_DYNAMIC_FALLBACK)
&& (aes->use_aesni != WC_FLAG_DONT_USE_VECTOR_OPS)
#endif
)
{
#if defined(WC_FLAG_DONT_USE_AESNI)
if (aes->use_aesni == WC_FLAG_DONT_USE_AESNI) {
#if defined(WC_FLAG_DONT_USE_VECTOR_OPS)
if (aes->use_aesni == WC_FLAG_DONT_USE_VECTOR_OPS) {
aes->use_aesni = 0;
return 0;
}
#endif
aes->use_aesni = 0;
#ifdef WOLFSSL_LINUXKM
#ifdef WOLFSSL_KERNEL_MODE
/* runtime alignment check */
if ((wc_ptr_t)&aes->key & (wc_ptr_t)0xf) {
return BAD_ALIGN_E;
ret = BAD_ALIGN_E;
}
else
#endif /* WOLFSSL_KERNEL_MODE */
{
ret = SAVE_VECTOR_REGISTERS2();
}
#endif /* WOLFSSL_LINUXKM */
ret = SAVE_VECTOR_REGISTERS2();
if (ret == 0) {
if (dir == AES_ENCRYPTION)
ret = AES_set_encrypt_key_AESNI(userKey, (int)keylen * 8, aes);
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/curve25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#endif
#endif

#if defined(WOLFSSL_LINUXKM) && !defined(USE_INTEL_SPEEDUP)
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && !defined(USE_INTEL_SPEEDUP)
/* force off unneeded vector register save/restore. */
#undef SAVE_VECTOR_REGISTERS
#define SAVE_VECTOR_REGISTERS(fail_clause) SAVE_NO_VECTOR_REGISTERS(fail_clause)
Expand Down
Loading
Loading