Commit Graph
10519 Commits
Author SHA1 Message Date
Daniel PouzznerandGitHub fc74ebdc74 Merge pull request #10885 from philljj/fips_v7_guards
random.c: fix fips v7 define guards.
2026-07-15 16:34:22 -05:00
Tobias FrauenschlägerandGitHub 986fed770c Merge pull request #10907 from SparkiDev/asm_include_fix
Include the correct wolfSSL header for inline C asm.
2026-07-15 10:44:47 +02:00
Tobias FrauenschlägerandGitHub c327ea36bf Merge pull request #10904 from aidangarske/fix/pkcs7-stream-signed-content
Fix PKCS7 streamed SignedData dropping content
2026-07-15 09:43:34 +02:00
Sean Parkinson b0dfa35bbe Include the correct wolfSSL header for inline C asm.
wolfssl/wolfcrypt/libwolfssl_sources_asm.h is for assembly files.
wolfssl/wolfcrypt/libwolfssl_sources.h is for C files.
2026-07-15 17:40:19 +10:00
Tobias FrauenschlägerandGitHub 2494da4a46 Merge pull request #10895 from danielinux/aes-gcm-fix-ct-compare
AES-GCM: constant-time output clear on decrypt auth failure
2026-07-15 08:54:27 +02:00
aidan garske 9b1aad457d Fix PKCS7 streamed SignedData dropping content 2026-07-14 16:47:31 -07:00
JacobBarthelmehandGitHub 26538a252c Merge pull request #10884 from kareem-wolfssl/zd22127_2
Adjust wolfEntropy size calculation and error out if an invalid combination of settings is given.
2026-07-14 16:12:50 -06:00
JacobBarthelmehandGitHub 6722de5635 Merge pull request #10882 from kareem-wolfssl/zd22127
Use safe sum in PKCS7_VerifySignedData.
2026-07-14 10:00:50 -06:00
JacobBarthelmehandGitHub 7b501242b8 Merge pull request #10876 from danielinux/mcdc-test-coverage
Mcdc test coverage campaign - part 2
2026-07-14 09:59:45 -06:00
Daniele Lacamera 23ad1c1d7a AES-GCM: skip output clear for AUTH_EARLY; test auth-fail output zeroing
Review follow-ups for the constant-time AES-GCM decrypt output clear:

- Guard the output-masking pass with #ifndef WC_AES_GCM_DEC_AUTH_EARLY. In
  that configuration the tag is verified before decryption and a mismatch
  returns before any output is written, so the masking pass is a guaranteed
  no-op; skipping it avoids a wasted O(sz) pass.

- Add a test in aesgcm_test: decrypt with a corrupted tag into a pre-filled
  buffer and assert wc_AesGcmDecrypt returns AES_GCM_AUTH_E and, on the
  software C path, that the output buffer is cleared to zero. The AES-NI/asm
  decrypt paths and the FIPS module do not clear the output on auth failure,
  so the zero check forces the C path (use_aesni = 0) and is limited to it
  (and skipped under HAVE_FIPS). The AES_GCM_AUTH_E comparison uses
  WC_NO_ERR_TRACE().

Verified (gcc 15.2): make check passes on the default (C path) build;
testwolfcrypt AES-GCM passes with --enable-aesni and with
-DWC_AES_GCM_DEC_AUTH_EARLY; ct-valgrind aes_gcm reports 0 errors.
2026-07-14 17:12:42 +02:00
Daniele Lacamera 9dffa3ce63 AES-GCM: constant-time output clear on decrypt auth failure
AES_GCM_decrypt_C cleared the output on a tag mismatch with
'if (ret != 0) ForceZero(out, sz)'. That is a conditional branch on the
secret-dependent authentication result, which is not constant time and is
flagged by the ct-valgrind constant-time test (Conditional jump depends on
uninitialised value in AES_GCM_decrypt_C).

Mask the output with 'res' (already computed as all-ones on tag mismatch,
zero on match) instead of branching, matching the constant-time idiom used
for the tag comparison itself. C path only; the AES-NI/ASM paths are
unaffected.
2026-07-14 10:43:25 +02:00
Daniel PouzznerandGitHub e87f7e83c7 Merge pull request #10867 from philljj/wc_const_comp
memory.c: add wc_ConstantCompare wrapper.
2026-07-14 00:57:47 -05:00
philljjandGitHub ef50d85430 Merge pull request #10881 from douzzer/20260710-linuxkm-fixes
20260710-linuxkm-fixes
2026-07-13 22:22:42 -05:00
Daniel Pouzzner 2cf826f03d KCAPI and linuxkm fixes from peer review:
linuxkm/lkcapi_aes_glue.c: zero the ephemeral ivOut in AesGcmCrypt_1().

wolfcrypt/src/port/kcapi/kcapi_aes.c: tighten the test on the return value from kcapi_aead_decrypt().
2026-07-13 17:12:20 -05:00
jordan 3c06b0e6db random.c: correct comment per review. 2026-07-13 12:13:58 -05:00
Mattia MoffaandGitHub 0568743c55 Merge pull request #10880 from dgarske/stm32_bare2
Fix STM32 DHUK AES-CBC in-place decrypt chaining IV and correct stale CTR comment
2026-07-13 18:03:33 +02:00
Daniele Lacamera d868aa2299 sha: reorder update arg guards to make the empty-update decision coverable
wc_ShaUpdate, wc_Sha3Update, wc_Shake128_Update and wc_Shake256_Update
guarded inputs as:
    if (obj == NULL || (data == NULL && len > 0)) return BAD_FUNC_ARG;
    if (data == NULL && len == 0) return 0;
The first guard rejected (data==NULL, len>0) before the second decision,
so that decision's len==0 condition could only ever be observed true --
its MC/DC independence pair was structurally unreachable.

Reorder to the same idiom sha256.c/sha512.c already use:
    if (obj == NULL) return BAD_FUNC_ARG;
    if (data == NULL && len == 0) return 0;   /* (NULL,len>0) now reaches: len==0 false */
    if (data == NULL) return BAD_FUNC_ARG;
Behavior is identical for every input; the existing DIGEST_UPDATE_TEST
cases wc_*Update(&dgst, NULL, 1) and (&dgst, NULL, 0) now exercise both
sides of the decision. Closes the four guard-ordering MC/DC residuals in
the sha campaign module (sha.c and sha3.c).
2026-07-13 11:19:23 +02:00
Yosuke Shimizu b1d558c8d5 Fix PKCS#7 padding for block-aligned input in wc_EncryptPKCS8Key_ex 2026-07-13 08:38:46 +09:00
jordan 11c53ab808 random.c: fix fips v7 define guards. 2026-07-10 22:55:25 -05:00
Kareem f8d5905597 Code review feedback 2026-07-10 16:35:33 -07:00
Kareem e1876968aa Adjust wolfEntropy size calculation and error out if an invalid combination of settings is given. 2026-07-10 16:32:40 -07:00
Kareem 8f3f18a1d1 Also use safe sum for length in PKCS7_VerifySignedData. 2026-07-10 16:14:05 -07:00
Kareem 42f453dd24 Use safe sum for certSz in PKCS7_VerifySignedData.
Reported-by: Andrew Chin
2026-07-10 16:05:55 -07:00
David GarskeandGitHub 5d0da8e173 Merge pull request #10871 from SparkiDev/ppc64_le_and_elf1_fix
PPC64 Assembly: ELF V1 headers added. Little-endian asm added.
2026-07-10 15:54:08 -07:00
David Garske e9aebd220c Fix STM32 DHUK AES-CBC in-place decrypt chaining IV and correct stale CTR comment 2026-07-10 15:35:29 -07:00
Daniel Pouzzner 436bce8f41 wolfcrypt/src/port/af_alg/afalg_aes.c, wolfcrypt/src/port/kcapi/kcapi_aes.c, tests/api/test_aes.c: fixes for AF_ALG and KCAPI ports.
fixes longstanding bug in afalg_aes.c that made no-AAD handles non-interchangeable with AAD handles.  also adds missing arg validation and KEYUSAGE_E checks throughout AF_ALG.
2026-07-10 17:29:44 -05:00
jordan 3c5682664a memory.c: add wc_ConstantCompare wrapper. 2026-07-10 13:44:48 -05:00
aidan garske 159c7a65a2 Merge upstream/master into feature/x509-tiny 2026-07-10 10:02:36 -07:00
David GarskeandGitHub 3538c4db7a Merge pull request #10875 from danielinux/fixes-2026-07-10
Minor bugfixes
2026-07-10 09:05:03 -07:00
David GarskeandGitHub a962793323 Merge pull request #10704 from aidangarske/length-width-hardening
Length Width Hardening
2026-07-10 08:00:39 -07:00
David GarskeandGitHub 772bae44b4 Merge pull request #10821 from wolfSSL/feature/x509-no-malloc-verify
Add true zero-allocation X.509 certificate verification under WOLFSSL_NO_MALLOC
2026-07-10 07:56:03 -07:00
Mattia MoffaandGitHub 3ea9dd5231 Merge pull request #10395 from dgarske/stm32_bare
STM32 bare-metal crypto port (HASH / AES / PKA / RNG, DHUK, CCB)
2026-07-10 16:27:26 +02:00
Daniele Lacamera 3fed5f90f2 rsa: zero wc_MakeRsaKey stack temporaries for mem-zero check
wc_MakeRsaKey()'s non-small-stack path declares p/q/tmp1..3 as stack
mp_ints and only mp_init's them after the argument and size checks. An
early 'goto out' from those checks reaches the WOLFSSL_CHECK_MEM_ZERO
cleanup, which calls mp_memzero_check() on the still-uninitialized structs;
the garbage size field makes the check scan an arbitrary stack range and
can false-abort on unrelated registered memory. Zero the temporaries up
front (under WOLFSSL_CHECK_MEM_ZERO) so the early-out cleanup is safe.
2026-07-10 14:13:14 +02:00
Sean Parkinson 3f3ebcac58 PPC64 Assembly: ELF V1 headers added. Little-endian asm added.
ELF V1 headers are need for cross-compiles.
PPC64 is big or little endian so assembly code modified to be able to be built for both.
Fix wiring of vector AES implementations in aes.c.
2026-07-10 19:52:13 +10:00
Daniele Lacamera cf5c126a40 dh: deregister mem-zero entries in wc_FreeDhKey
wc_DhImportKeyPair() registers key->priv for zero-on-free tracking via
mp_memzero_add() under WOLFSSL_CHECK_MEM_ZERO, but wc_FreeDhKey() cleared
priv with mp_forcezero(), which zeroes the data without removing the
registration. Unlike wc_FreeRsaKey(), wc_FreeDhKey() had no
wc_MemZero_Check() to remove the entry, so the registration leaked past
the DhKey's lifetime and a later, unrelated wc_MemZero_Check() over reused
stack could false-abort on it. Add wc_MemZero_Check(key, sizeof(*key)) at
the end of wc_FreeDhKey(), mirroring wc_FreeRsaKey().
2026-07-10 11:46:38 +02:00
Daniele Lacamera 0a0e08470b random: reject NULL output in Unix wc_GenerateSeed
wc_GenerateSeed only checked os for NULL, so a NULL output passed straight
into the entropy backend. glibc's vDSO getrandom() dereferences the buffer
without validating it and segfaults instead of returning an error. Add the
output NULL check (matching wc_RNG_GenerateBlock's convention) so the public
seed API fails cleanly with BAD_FUNC_ARG.
2026-07-10 08:37:02 +02:00
Daniele Lacamera 666de7d0bb random: guard PollAndReSeed with !CUSTOM_RAND_GENERATE_BLOCK
PollAndReSeed was compiled under #ifdef HAVE_HASHDRBG alone, but its only
callers (in wc_RNG_GenerateBlock) sit in the #else of CUSTOM_RAND_GENERATE_
BLOCK, and it references wc_GenerateSeed which is not provided when a custom
block generator replaces the seed layer. Defining HAVE_HASHDRBG together
with CUSTOM_RAND_GENERATE_BLOCK therefore produced an undefined-symbol link
error. Match _InitRng's guard so the function is compiled exactly when it
can be called.
2026-07-10 08:37:02 +02:00
Daniele Lacamera 30ceba03c5 dsa: gate CheckDsaLN on err==MP_OKAY in _DsaImportParamsRaw
The (L,N) size check ran unconditionally, so after an earlier failure it
overwrote the specific error (e.g. DH_CHECK_PUB_E from the p primality
check) with BAD_FUNC_ARG, and computed qSz from a q that was never read
(the q read is itself gated on err==MP_OKAY). Gate the size check the same
way as the surrounding steps so the first, most specific error is returned.
2026-07-10 08:37:02 +02:00
Daniele Lacamera 600880a0a4 curve25519: fix big-endian public-key order check operand
wc_curve25519_check_public's BIG_ENDIAN branch checked pub[i] != 0 in its
top-order boundary loop where the mirrored LITTLE_ENDIAN branch checks
pub[i] != 0xff. The field prime p = 2^255 - 19 has 0xff middle bytes, so
the != 0 test broke out on the first non-0xff byte and the near-prime
rejection was effectively non-functional for big-endian inputs. Match the
little-endian branch so out-of-range big-endian public keys are rejected.
2026-07-10 08:37:02 +02:00
ZackeryandGitHub 69bf010918 Merge pull request #10677 from dgarske/realtek_huk
Add RealTek AmebaPro2 (RTL8735B) HUK crypto-callback port
2026-07-09 18:09:37 -06:00
David Garske 949976b856 Add STM32 DHUK crypto-callback ECDSA verify handler for callback-only ECC 2026-07-09 15:39:03 -07:00
David Garske 986e114dde Let WOLF_CRYPTO_CB_ONLY_AES compose with the STM32 bare AES path 2026-07-09 15:39:03 -07:00
David Garske 040043c747 Fix STM32 DHUK AES-CBC callback routing and RNG init robustness 2026-07-09 15:39:02 -07:00
David Garske 3b3b47a9d5 Add STM32 DHUK full wrapped AES-GCM and TRNG crypto-callback cases 2026-07-09 15:39:02 -07:00
David Garske f3f7425807 Add STM32C5 CCB ECDSA hardware blob-create support 2026-07-09 15:39:02 -07:00
David Garske d0b2d76d90 Refactor STM32 CCB driver and expand STM32 port docs and doxygen 2026-07-09 15:39:02 -07:00
David Garske 33ce6e7e7e Add STM32 CCB and STM32C5 HW PKA ECDSA support 2026-07-09 15:39:02 -07:00
David Garske f143edff6a Add STM32 DHUK (Device Hardware Unique Key) support via crypto callbacks 2026-07-09 15:39:02 -07:00
David Garske d43bc1d319 Add STM32 bare-metal support for Hash, SAES/AES, PKA and RNG 2026-07-09 15:39:02 -07:00
David GarskeandGitHub 4c6852372f Merge pull request #10872 from Frauschi/force_zero_pkcs12
Add missing ForceZero in PKCS#12
2026-07-09 12:11:20 -07:00