Commit Graph

25791 Commits

Author SHA1 Message Date
Sean Parkinson
08ec3642f0 Merge pull request #8931 from julek-wolfssl/MAX_ENCODED_SIG_SZ-detected
Detect correct `MAX_ENCODED_SIG_SZ` based on max support in math lib
2025-07-08 09:38:52 +10:00
Sean Parkinson
9b92b4c902 Merge pull request #8962 from rlm2002/coverity
Coverity: Dereference after NULL check and Use after free
2025-07-08 08:30:35 +10:00
Ruby Martin
de59e9d25e change to BIO_free_all() on EXPECT_FAIL() 2025-07-07 09:17:29 -06:00
Ruby Martin
61e4142fe0 add null check for ssl before use in wc_DhGenerateKeyPair 2025-07-07 09:17:29 -06:00
Ruby Martin
65f9cdb498 free p2 before reassigning to reEncoded value 2025-07-07 09:17:29 -06:00
Juliusz Sosinowicz
51c9448aa1 Detect correct MAX_ENCODED_SIG_SZ based on max support in math lib 2025-07-07 16:42:33 +02:00
Daniel Pouzzner
a40b56ccb5 Merge pull request #8964 from douzzer/20250703-linuxkm-fixes
20250703-linuxkm-fixes

Note, final commit reviewed by @SparkiDev, and earlier commit reviewed by @philljj.
2025-07-04 08:45:55 -05:00
Daniel Pouzzner
ef3a1a28d9 linuxkm/linuxkm_wc_port.h, linuxkm/module_hooks.c, and wolfcrypt/src/wc_port.c: fixes for spinlocks on CONFIG_ARM64;
wolfcrypt/src/wc_port.c: include random.h, for Entropy_Init().
2025-07-03 22:09:34 -05:00
Daniel Pouzzner
688bc168de wolfcrypt/src/random.c: small stack refactor of noise[] in wc_Entropy_Get(). 2025-07-03 18:30:46 -05:00
David Garske
fb691fac94 Merge pull request #8947 from SparkiDev/mldsa_openssl_der
ML-DSA/Dilithium: support OpenSSL format
2025-07-03 16:10:55 -07:00
Daniel Pouzzner
478bfafea3 linuxkm/lkcapi_sha_glue.c:
* add wc_linuxkm_drbg_ctx.n_rngs, and in wc_linuxkm_drbg_init_tfm(), set it to max(4, nr_cpu_ids), to avoid stalling on unicore targets;

* add explanatory comments re architecture to get_drbg() and get_drbg_n();

* add opportunistic cond_sched() to get_drbg_n();

* add runtime asserts in get_drbg(), wc_linuxkm_drbg_seed(), and get_default_drbg_ctx(), checking that we have the right tfm with an allocated DRBG array;

* wc_linuxkm_drbg_startup(): return failure if registering the random_bytes handlers fails;

linuxkm/patches/6.1.73/WOLFSSL_LINUXKM_HAVE_GET_RANDOM_CALLBACKS-6v1v73.patch: fix flub.
2025-07-03 17:35:37 -05:00
David Garske
d8caa8493f Merge pull request #8959 from SparkiDev/disable_pk_algs
Testing disabling various PK algs
2025-07-03 15:20:57 -07:00
Sean Parkinson
519d1430d0 ML-DSA/Dilithium: support OpenSSL format
Support DER private key format.
2025-07-04 07:54:26 +10:00
David Garske
3fe84bf3c0 Merge pull request #8961 from douzzer/20250703-fixes-for-multi-test-reports
20250703-fixes-for-multi-test-reports
2025-07-03 11:07:46 -07:00
JacobBarthelmeh
01de7cc04b Merge pull request #8955 from anhu/signed
Explicitly declare dilithium_coeff_eta2[] as signed
2025-07-03 10:25:46 -06:00
JacobBarthelmeh
7abaa131d3 Merge pull request #8954 from dgarske/asm_introspection
Added introspection for Intel and ARM assembly speedups
2025-07-03 10:22:19 -06:00
philljj
c0837cb073 Merge pull request #8943 from douzzer/20250617-linuxkm-get_random_bytes
20250617-linuxkm-get_random_bytes
2025-07-03 11:22:08 -05:00
Daniel Pouzzner
1d1a87b0a2 wolfssl/wolfcrypt/tfm.h: fix arg names in fp_to_unsigned_bin_len_ct() prototype to match tfm.c (fixes readability-inconsistent-declaration-parameter-name in clang-tidy-fips-140-3-defaults etc.). 2025-07-03 10:21:30 -05:00
Daniel Pouzzner
bdd2056645 wolfcrypt/test/test.c: fix gate in dh_test() (fixes disable-sha256). 2025-07-03 10:19:07 -05:00
Daniel Pouzzner
a1fa897572 wolfcrypt/src/dilithium.c: fix cast flubs in dilithium_encode_gamma1_19_bits() (fixes quantum-safe-wolfssl-all-gcc-latest-m32). 2025-07-03 10:17:51 -05:00
Sean Parkinson
c925ba2fe1 Testing disabling various PK algs
Fix api.c: disable test_EccSigFailure_cm and test_RsaSigFailure_cm when
the PK algorithm they use is disabled.
2025-07-03 16:38:54 +10:00
David Garske
6be8a3710d Merge pull request #8937 from miyazakh/tsip_cryptcb_ut
Fix TSIP port using crypto callback
2025-07-02 17:42:51 -07:00
Hideki Miyazaki
b60a05f45e Fix TSIP port using crypto callback
- Add unit test using cb
2025-07-03 08:23:24 +09:00
JacobBarthelmeh
c48dd28741 Merge pull request #8957 from dgarske/bench_help
Fix issue with benchmark help options and descriptions not lining up
2025-07-02 17:17:42 -06:00
David Garske
7f50cd537e Merge pull request #8956 from gojimmypi/pr-workflow-owner
Remove duplicate repository_owner check
2025-07-02 15:01:29 -07:00
David Garske
59061aebec Fix issue with benchmark help options and descriptions not lining up due to new -aead_set_key added in #8160 on April 14, 2025. 2025-07-02 14:58:11 -07:00
Daniel Pouzzner
dd69d56e33 linuxkm/linuxkm_wc_port.h: in malloc/realloc, use GFP_KERNEL if it's safe to sleep;
linuxkm/lkcapi_sha_glue.c:

* in wc_linuxkm_drbg_init_tfm(), sleep if it's safe, and observe a wc_linuxkm_drbg_init_tfm_disable_vector_registers flag;

* in wc_crng_reseed(), preemptively execute the reseed if it's safe to sleep;

* in wc_linuxkm_drbg_startup(), in LINUXKM_DRBG_GET_RANDOM_BYTES section, add reseed test sequence if defined(DEBUG_DRBG_RESEEDS).
2025-07-02 16:46:27 -05:00
gojimmypi
adc3f1b3d7 Remove duplicate repository_owner check 2025-07-02 14:32:21 -07:00
Anthony Hu
f7ea8fca67 Explicitly declare dilithium_coeff_eta2[] as signed 2025-07-02 15:50:51 -04:00
Daniel Pouzzner
0160af0a0d linuxkm/patches/: update patches to reseed the wolfCrypt DRBG array only on explicit RNDRESEEDCRNG ioctl;
linuxkm/lkcapi_sha_glue.c: add error msg in wc_linuxkm_drbg_generate() if wc_InitRng() fails, and add "libwolfssl: " prefixes in pr_info() messages.
2025-07-02 14:25:05 -05:00
Daniel Pouzzner
d2083db6de wolfssl/wolfcrypt/settings.h: in WOLFSSL_LINUXKM && LINUXKM_LKCAPI_REGISTER setup for default WC_RESEED_INTERVAL, ignore WORD64_AVAILABLE because it isn't available at this stage of inclusion. 2025-07-02 14:25:05 -05:00
Daniel Pouzzner
6275f1f7e6 linuxkm/lkcapi_rsa_glue.c: update version threshold for the v6.16 change in crypto_sig_*size() semantics, now backported to 6.15.3. 2025-07-02 14:25:05 -05:00
Daniel Pouzzner
f0662e0578 wolfssl/wolfcrypt/settings.h: remove implicit define of WOLFSSL_NO_WORD64_OPS if !WOLFSSL_SHA384 && !WOLFSSL_SHA512 && NO_AES && !WOLFSSL_SHA3 (not compatible with word64 DRBG_internal.reseedCtr). 2025-07-02 14:25:05 -05:00
Daniel Pouzzner
dc05c4c01b wolfcrypt/src/random.c and wolfssl/wolfcrypt/random.h: refactor DRBG_internal.reseedCtr as a word64 if WORD64_AVAILABLE, to accommodate max reseed count per NIST SP 800-90A Rev. 1;
wolfssl/wolfcrypt/settings.h: if WOLFSSL_LINUXKM && LINUXKM_LKCAPI_REGISTER && WORD64_AVAILABLE, set default WC_RESEED_INTERVAL to max allowed (2^48);

linuxkm/lkcapi_sha_glue.c: handle NO_LINUXKM_DRBG_GET_RANDOM_BYTES, for build-time override control of LINUXKM_DRBG_GET_RANDOM_BYTES, and handle WOLFSSL_LINUXKM_USE_GET_RANDOM_USER_KRETPROBE, for separate opt-in control of the buggy wc_get_random_bytes_user_kretprobe_enter().
2025-07-02 14:25:05 -05:00
Daniel Pouzzner
3a43109208 configure.ac: remove automatic --enable-hmac-copy, due to unit test failures when defined(WOLFSSL_HMAC_COPY_HASH), not previously detected because of broken option processing. 2025-07-02 14:25:05 -05:00
Daniel Pouzzner
b3944a73c2 linuxkm/lkcapi_sha_glue.c:
* implement interception of _get_random_bytes() and get_random_bytes_user() (implicitly intercepts /dev/random and /dev/urandom):

    * get_crypto_default_rng()
    * get_default_drbg_ctx()
    * wc__get_random_bytes()
    * wc_get_random_bytes_user()
    * wc_extract_crng_user()
    * wc_mix_pool_bytes()
    * wc_crng_reseed()
    * wc_get_random_bytes_by_kprobe()
    * wc_get_random_bytes_user_kretprobe_enter()
    * wc_get_random_bytes_user_kretprobe_exit()

    * add LINUXKM_DRBG_GET_RANDOM_BYTES sections to wc_linuxkm_drbg_startup() and wc_linuxkm_drbg_cleanup()

    * add linuxkm/patches/*/WOLFSSL_LINUXKM_HAVE_GET_RANDOM_CALLBACKS-*.patch, initially for versions:
      * 5.10.17
      * 5.10.236
      * 5.15
      * 5.17
      * 6.1.73
      * 6.12
      * 6.15

    * remove "*.patch" from .gitignore.

    * add linuxkm/patches/regen-patches.sh.

  * in wc_linuxkm_drbg_ctx_clear(), check lock count before freeing.

  * in get_drbg() and put_drbg(), use migrate_disable(), not DISABLE_VECTOR_REGISTERS().

  * in wc_linuxkm_drbg_generate(), explicitly DISABLE_VECTOR_REGISTERS() for the crypto_default_rng.

  * in wc_linuxkm_drbg_generate(), add DRBG reinitialization code to handle RNG_FAILURE_E.  This handles the situation where a DRBG was instantiated in a vector-ops-allowed context, caching a vectorized SHA256 ethod, but later used in a no-vector-ops-allowed context.

  * in wc_linuxkm_drbg_seed(), add DISABLE_VECTOR_REGISTERS() wrapper around wc_RNG_DRBG_Reseed() for crypto_default_rng.

linuxkm/x86_vector_register_glue.c:

  * add crash recovery logic to wc_linuxkm_fpu_state_assoc_unlikely()

  * in wc_linuxkm_fpu_state_assoc(), when wc_linuxkm_fpu_states is null, don't call wc_linuxkm_fpu_state_assoc_unlikely() if !assume_fpu_began.

  * in can_save_vector_registers_x86(), save_vector_registers_x86(), and restore_vector_registers_x86(), check for hard interrupt context first, to return early failure if current->pid is unusable.

  * in save_vector_registers_x86(), tweak logic around WC_FPU_INHIBITED_FLAG, adding local_bh_disable()...local_bh_enable() to provide for safe recursion.

wolfcrypt/src/random.c: optimization: in Hash_df(), for WOLFSSL_LINUXKM, don't put digest[WC_SHA256_DIGEST_SIZE] in the heap, keep it on the stack.

wolfssl/wolfcrypt/types.h: add WOLFSSL_NO_ASM no-op definitions for DISABLE_VECTOR_REGISTERS() and REENABLE_VECTOR_REGISTERS().

configure.ac:

* move --enable-linuxkm and --enable-linuxkm-defaults initial detection early, so that HMAC_COPY_DEFAULT picks it up.

* add ENABLED_ENTROPY_MEMUSE_DEFAULT, and enable it by default when ENABLED_LINUXKM_DEFAULTS.

* update linuxkm-lkcapi-register help message.

linuxkm/linuxkm_wc_port.h:

* add my_kallsyms_lookup_name().

* add preempt_count, _raw_spin_lock_irqsave, _raw_spin_trylock, _raw_spin_unlock_irqrestore, and _cond_resched, to wolfssl_linuxkm_pie_redirect_table, and add spin_unlock_irqrestore() macro to mask native inline.

* move linuxkm mutex wrappers from wolfcrypt/src/wc_port.c to linuxkm_wc_port.h, make them inlines, and add new default spinlock-based implementation, with old method now gated on WOLFSSL_LINUXKM_USE_MUTEXES.

* change malloc() and realloc() wrappers from GFP_KERNEL to GFP_ATOMIC.

linuxkm/lkcapi_glue.c: make misc.h/misc.c inclusion unconditional, and trim now-redundant inclusions out of lkcapi_dh_glue.c and lkcapi_ecdh_glue.c.
2025-07-02 14:25:05 -05:00
Daniel Pouzzner
b25d484a4e linuxkm/lkcapi_sha_glue.c: implement mutex-free sync mechanism for wc_linuxkm_drbg_ctx in new get_drbg(), get_drbg_n(), and put_drbg();
linuxkm/x86_vector_register_glue.c: implement support for WC_FPU_INHIBITED_FLAG, and an `int inhibit_p` argument to save_vector_registers_x86();

wolfcrypt/src/random.c: implement linuxkm support for RDSEED and HAVE_ENTROPY_MEMUSE;

wolfssl/wolfcrypt/error-crypt.h and wolfcrypt/src/error.c: add WC_ACCEL_INHIBIT_E "Crypto acceleration is currently inhibited";

linuxkm/module_hooks.c and linuxkm/x86_vector_register_glue.c: remove broken and bit-rotten WOLFSSL_COMMERCIAL_LICENSE and LINUXKM_FPU_STATES_FOLLOW_THREADS code paths.
2025-07-02 14:25:05 -05:00
Daniel Pouzzner
8cc2ba7153 Merge pull request #8953 from philljj/fedora_linuxkm_uninit_errors
linuxkm fedora: fix uninitialized build errors.
2025-07-02 14:20:26 -05:00
David Garske
221330df0b Added introspection for Intel and ARM assembly speedups (useful for benchmarking output). Added STM32F439ZI benchmarks.
`--enable-armasm` : `Assembly Speedups: ARMASM ALIGN`
`--enable-intelasm` : `Assembly Speedups: INTELASM ALIGN X86_64_BUILD`
2025-07-02 10:57:24 -07:00
jordan
9e811b5bd5 wolfcrypt misc: avoid frivolous initialization. 2025-07-02 10:46:38 -05:00
David Garske
fa9e122f1c Merge pull request #8952 from SparkiDev/mem_fail_fixes_3
Unit Test: fix test case for memory allocation failure testing
2025-07-02 08:01:20 -07:00
jordan
9ac480a60d linuxkm fedora: fix uninitialized build errors. 2025-07-02 10:00:28 -05:00
Sean Parkinson
af05fa874f Unit Test: fix test case for memory allocation failure testing
test_ocsp_basic_verify() not freeing and setting pointer to NULL. Second
free occuring on freed pointer.
2025-07-02 09:27:25 +10:00
JacobBarthelmeh
ff80d62db2 Merge pull request #8942 from rlm2002/coverity
Coverity: address unresolved issue from previous change
2025-07-01 16:09:32 -06:00
David Garske
33510ad714 Merge pull request #8949 from holtrop/asn-fn-prototype-names
wc/asn: fix several inconsistent function prototype parameter names
2025-07-01 14:50:51 -07:00
Ruby Martin
c06fa48e75 return NULL on negative length 2025-07-01 14:25:35 -06:00
Kaleb Himes
f2abadb777 Merge pull request #8950 from douzzer/20250701-Hash_DRBG_Generate-DEBUG_WOLFSSL
20250701-Hash_DRBG_Generate-DEBUG_WOLFSSL
2025-07-01 14:03:59 -06:00
Daniel Pouzzner
a8fc68d81b wolfcrypt/src/random.c: in Hash_DRBG_Generate(), gate the verbose reseed message on DEBUG_WOLFSSL or DEBUG_DRBG_RESEEDS, use WOLFSSL_MSG_EX(), and refactor the condition from drbg->reseedCtr == RESEED_INTERVAL to drbg->reseedCtr >= WC_RESEED_INTERVAL.
also some unrelated cleanup in .wolfssl_known_macro_extras.
2025-07-01 13:05:00 -05:00
JacobBarthelmeh
8fa0f6b3df Merge pull request #8944 from SparkiDev/evp_hmac_copy_hash_fix
EVP HMAC: get working with WOLFSSL_HMAC_COPY_HASH
2025-07-01 09:50:53 -06:00
JacobBarthelmeh
77792ace65 Merge pull request #8945 from SparkiDev/mem_fail_fixes_2
Memory allocation failure testing fixes
2025-07-01 09:35:11 -06:00