wolfcrypt/src/aes.c: fix WOLFSSL_AESGCM_STREAM && WC_AES_C_DYNAMIC_FALLBACK: establish AESNI status dynamically at time of wc_AesGcmSetKey(), and stick to it (or return failure) until the next wc_AesGcmSetKey(). this matches the semantics of the Linux kernel in-tree implementation, allowing safe registration of the wolfCrypt AESNI implementation with the LKCAPI.
configure.ac: move enable_aesgcm_stream=yes clauses in enable-all and enable-all-crypto to the main section, from the !ENABLED_LINUXKM_DEFAULTS section, and in ENABLED_LINUXKM_LKCAPI_REGISTER setup, remove the !ENABLED_AESNI from the condition for forcing on ENABLED_AESGCM_STREAM. linuxkm/lkcapi_glue.c: * remove all special-casing for AES-GCM with AESNI. * add support for a LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING macro. wolfssl/wolfcrypt/memory.h: add missing definition of SAVE_VECTOR_REGISTERS2() when DEBUG_VECTOR_REGISTER_ACCESS_FUZZING && !DEBUG_VECTOR_REGISTER_ACCESS. wolfcrypt/src/memory.c: * define SAVE_VECTOR_REGISTERS2_fuzzer() if DEBUG_VECTOR_REGISTER_ACCESS_FUZZING, regardless of DEBUG_VECTOR_REGISTER_ACCESS. * add a DEBUG_VECTOR_REGISTER_ACCESS clause to the !HAVE_THREAD_LS version of SAVE_VECTOR_REGISTERS2_fuzzer(). wolfcrypt/test/test.c: remove several errant wc_AesFree()s in aes256_test().
This commit is contained in:
@@ -1508,16 +1508,21 @@ THREAD_LS_T const char *wc_svr_last_file = NULL;
|
||||
THREAD_LS_T int wc_svr_last_line = -1;
|
||||
THREAD_LS_T int wc_debug_vector_registers_retval =
|
||||
WC_DEBUG_VECTOR_REGISTERS_RETVAL_INITVAL;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_VECTOR_REGISTER_ACCESS_FUZZING
|
||||
|
||||
#ifdef HAVE_THREAD_LS
|
||||
|
||||
WOLFSSL_LOCAL int SAVE_VECTOR_REGISTERS2_fuzzer(void) {
|
||||
static THREAD_LS_T struct drand48_data wc_svr_fuzzing_state;
|
||||
static THREAD_LS_T int wc_svr_fuzzing_seeded = 0;
|
||||
long result;
|
||||
|
||||
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
|
||||
if (wc_debug_vector_registers_retval)
|
||||
return wc_debug_vector_registers_retval;
|
||||
#endif
|
||||
|
||||
if (wc_svr_fuzzing_seeded == 0) {
|
||||
long seed = WC_DEBUG_VECTOR_REGISTERS_FUZZING_SEED;
|
||||
@@ -1534,30 +1539,33 @@ WOLFSSL_LOCAL int SAVE_VECTOR_REGISTERS2_fuzzer(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* DEBUG_VECTOR_REGISTER_ACCESS_FUZZING */
|
||||
#else /* !HAVE_THREAD_LS */
|
||||
|
||||
#elif defined(DEBUG_VECTOR_REGISTER_ACCESS_FUZZING)
|
||||
|
||||
/* DEBUG_VECTOR_REGISTER_ACCESS is undefined but fuzzing requested --
|
||||
* fuzz vector register access without the detailed debugging.
|
||||
* this is useful for testing in the kernel module build, where glibc and
|
||||
* thread-local storage are unavailable.
|
||||
/* alternate implementation useful for testing in the kernel module build, where
|
||||
* glibc and thread-local storage are unavailable.
|
||||
*
|
||||
* note this is not a well-behaved PRNG, but is adequate for fuzzing purposes.
|
||||
* the prn sequence is incompressible according to ent and xz, and does not
|
||||
* cycle within 10M iterations with various seeds including zero, but the Chi
|
||||
* square distribution is poor, and the unconditioned lsb bit balance is ~54%
|
||||
* regardless of seed.
|
||||
*
|
||||
* deterministic only if access is single-threaded, but never degenerate.
|
||||
*/
|
||||
|
||||
WOLFSSL_LOCAL int SAVE_VECTOR_REGISTERS2_fuzzer(void) {
|
||||
static unsigned long prn = WC_DEBUG_VECTOR_REGISTERS_FUZZING_SEED;
|
||||
static int balance_bit = 0;
|
||||
/* access to prn is racey, but it doesn't matter. */
|
||||
unsigned long new_prn = prn ^ 0xba86943da66ee701ul; /* note this magic
|
||||
* random number is
|
||||
* bit-balanced.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
|
||||
if (wc_debug_vector_registers_retval)
|
||||
return wc_debug_vector_registers_retval;
|
||||
#endif
|
||||
|
||||
/* barrel-roll using the bottom 6 bits. */
|
||||
if (new_prn & 0x3f)
|
||||
new_prn = (new_prn << (new_prn & 0x3f)) |
|
||||
@@ -1569,9 +1577,9 @@ WOLFSSL_LOCAL int SAVE_VECTOR_REGISTERS2_fuzzer(void) {
|
||||
return ((prn & 1) ^ balance_bit) ? IO_FAILED_E : 0;
|
||||
}
|
||||
|
||||
#endif /* DEBUG_VECTOR_REGISTER_ACCESS ||
|
||||
* DEBUG_VECTOR_REGISTER_ACCESS_FUZZING
|
||||
*/
|
||||
#endif /* !HAVE_THREAD_LS */
|
||||
|
||||
#endif /* DEBUG_VECTOR_REGISTER_ACCESS_FUZZING */
|
||||
|
||||
#ifdef WOLFSSL_LINUXKM
|
||||
#include "../../linuxkm/linuxkm_memory.c"
|
||||
|
||||
Reference in New Issue
Block a user