Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fe8319e
F-1970: Treat a zero-length SE050 hash update as a no-op
LinuxJedi Nov 27, 2026
d5296fe
F-11174: Validate pointers in the SE050 SHA-256 and SHA-224 wrappers
LinuxJedi Nov 27, 2026
b5b946d
F-11175: Validate pointers in the SE050 SHA-512 and SHA-384 final/free
LinuxJedi Nov 27, 2026
d089409
Deep-copy the SE050 hash buffer in the SHA-2 Copy functions
LinuxJedi Nov 27, 2026
beed8a7
F-12323: Wipe the SE050 hash input buffer before freeing it
LinuxJedi Nov 27, 2026
7f85617
F-11245: Release the SE050 AES key object when storing the key fails
LinuxJedi Nov 27, 2026
ec8c1ff
F-12324: Erase the SE050 AES key object in se050_aes_free()
LinuxJedi Nov 27, 2026
860e14e
F-15216: Stop the SE050 replacing the requested RSA-OAEP parameters
LinuxJedi Nov 27, 2026
68daf94
F-9983: Make the EdDSA sign-time key check work and enable it for fau…
LinuxJedi Nov 27, 2026
7ea0821
F-15132: Zero CMAC storage before init in the Rust wrapper and one-shots
LinuxJedi Nov 27, 2026
13c3b82
Use stateless one-shot SE050 AES operations
LinuxJedi Nov 27, 2026
05923ef
Send wc_AesEcbEncrypt() and wc_AesEcbDecrypt() to the SE050
LinuxJedi Nov 27, 2026
cbbc1a5
Sign and verify empty messages with SE050 Ed25519 keys
LinuxJedi Nov 30, 2026
676eae8
Drop the per-call key lookup APDUs from the SE050 AES offload
LinuxJedi Nov 30, 2026
5c676f8
Skip SE050 object IDs that are in use when creating an AES key
LinuxJedi Nov 30, 2026
33f64fd
Reject SE050 RSA keys over RSA_MAX_SIZE in the host OAEP path
LinuxJedi Nov 30, 2026
9b1bc48
Free the SE050 hash buffer in wc_Sha224Free()
LinuxJedi Nov 30, 2026
dcae1f6
Clean up the SHA-2 Copy destination when an SE050 copy step fails
LinuxJedi Nov 30, 2026
cd83007
Leave room for SCP03 padding in the empty-message EdDSA command
LinuxJedi Nov 30, 2026
d7b1930
Refuse the parent's SE05x session in a fork() child
LinuxJedi Nov 30, 2026
6483c77
Keep options.h out of the SE050 port's SDK includes
LinuxJedi Nov 30, 2026
d37095d
Keep the Hash DRBG's SHA-256 and SHA-512 off the SE050
LinuxJedi Nov 30, 2026
b0640fe
Fix raw hash APIs and context init for SE050 hashes
LinuxJedi Nov 30, 2026
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4228,6 +4228,7 @@ add_option("WOLFSSL_FAULTHARDEN"
if(WOLFSSL_FAULTHARDEN)
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_CHECK_SIG_FAULTS" "-DWOLFSSL_CHECK_VER_FAULTS" "-DWC_SHA3_FAULT_HARDEN" "-DWC_MLKEM_FAULT_HARDEN" "-DWC_MLDSA_FAULT_HARDEN"
"-DWOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN"
)
endif()

Expand Down
2 changes: 2 additions & 0 deletions cmake/options.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ extern "C" {
#cmakedefine WC_MLKEM_FAULT_HARDEN
#undef WC_MLDSA_FAULT_HARDEN
#cmakedefine WC_MLDSA_FAULT_HARDEN
#undef WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN
#cmakedefine WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN
#undef WOLFSSL_SM3
#cmakedefine WOLFSSL_SM3
#undef WOLFSSL_SM3_SMALL
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3640,7 +3640,7 @@ AC_ARG_ENABLE([faultharden],

if test "$ENABLED_FAULTHARDEN" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CHECK_SIG_FAULTS -DWOLFSSL_CHECK_VER_FAULTS -DWC_SHA3_FAULT_HARDEN -DWC_MLKEM_FAULT_HARDEN -DWC_MLDSA_FAULT_HARDEN"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CHECK_SIG_FAULTS -DWOLFSSL_CHECK_VER_FAULTS -DWC_SHA3_FAULT_HARDEN -DWC_MLKEM_FAULT_HARDEN -DWC_MLDSA_FAULT_HARDEN -DWOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN"
fi

AC_ARG_ENABLE([compileharden],
Expand Down
16 changes: 16 additions & 0 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -17508,6 +17508,14 @@ static WARN_UNUSED_RESULT int _AesEcbEncrypt(
return MISSING_KEY;
}

#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT)
/* The key is only on the SE050, so there is no software schedule. */
if (aes->useSWCrypt == 0) {
return se050_aes_crypt(aes, in, out, sz, AES_ENCRYPTION,
kAlgorithm_SSS_AES_ECB);
}
#endif

VECTOR_REGISTERS_PUSH;

#if defined(WOLFSSL_RISCV_ASM)
Expand Down Expand Up @@ -17627,6 +17635,14 @@ static WARN_UNUSED_RESULT int _AesEcbDecrypt(
return MISSING_KEY;
}

#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT)
/* The key is only on the SE050, so there is no software schedule. */
if (aes->useSWCrypt == 0) {
return se050_aes_crypt(aes, in, out, sz, AES_DECRYPTION,
kAlgorithm_SSS_AES_ECB);
}
#endif

VECTOR_REGISTERS_PUSH;

#if defined(WOLFSSL_RISCV_ASM)
Expand Down
10 changes: 10 additions & 0 deletions wolfcrypt/src/cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ int wc_AesCmacGenerate(byte* out, word32* outSz,
wc_MemZero_Add("wc_AesCmacGenerate_ex cmac",
((unsigned char *)cmac) + sizeof(Aes), sizeof(Cmac) - sizeof(Aes));
#endif
#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT)
/* wc_InitCmac_ex() carries useSWCrypt over its reset of the object, so
* give it the default (use the SE050) rather than whatever this
* uninitialized buffer holds. */
cmac->useSWCrypt = 0;
#endif

ret = wc_AesCmacGenerate_ex(cmac,
out, outSz,
Expand Down Expand Up @@ -754,6 +760,10 @@ int wc_AesCmacVerify(const byte* check, word32 checkSz,
wc_MemZero_Add("wc_AesCmacGenerate_ex cmac",
((unsigned char *)cmac) + sizeof(Aes), sizeof(Cmac) - sizeof(Aes));
#endif
#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_CRYPT)
/* See wc_AesCmacGenerate(). */
cmac->useSWCrypt = 0;
#endif

ret = wc_AesCmacVerify_ex(cmac,
check, checkSz,
Expand Down
18 changes: 16 additions & 2 deletions wolfcrypt/src/ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
/* Possible Ed25519 enable options:
* WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN Default: OFF
* Check that the private key didn't change during the signing operations.
* Enabled by --enable-faultharden. Covers the software signer only: a
* signature made by a device (SE050, crypto callback) uses the key the
* device holds and is that device's responsibility.
*/

#define WC_FIPS_LL_CRYPTO
Expand Down Expand Up @@ -663,7 +666,9 @@ int wc_ed25519_sign_msg_ex(const byte* in, word32 inLen, byte* out,

#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_ONLY_KEY_ID)
/* Key resident in the SE050: sign in hardware. Software keys fall through
* to the wolfCrypt software implementation below. */
* to the wolfCrypt software implementation below. The private key never
* leaves the SE050 here, so WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN has no host
* copy to compare; protecting it is the secure element's job. */
if (key->keyIdSet) {
/* The SE050 performs only PureEdDSA; it cannot apply the Ed25519ctx or
* Ed25519ph variants, so reject them rather than silently signing with
Expand All @@ -686,6 +691,9 @@ int wc_ed25519_sign_msg_ex(const byte* in, word32 inLen, byte* out,
if (key->devId != INVALID_DEVID)
#endif
{
/* A device that signs uses the key it holds, so the
* WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN check below, which guards the
* software signer's copy of the key, is the device's to provide. */
ret = wc_CryptoCb_Ed25519Sign(in, inLen, out, outLen, key, type,
context, contextLen);
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
Expand Down Expand Up @@ -860,7 +868,13 @@ int wc_ed25519_sign_msg_ex(const byte* in, word32 inLen, byte* out,
for (i = 0; i < ED25519_KEY_SIZE; i++) {
c |= key->k[i] ^ orig_k[i];
}
ret = ctMaskGT(c, 0) & SIG_VERIFY_E;
/* ctMaskGT() gives a byte mask: select the error code with it rather
* than AND it into the (negative) error code. */
ret = ctMaskSelInt(ctMaskGT(c, 0), SIG_VERIFY_E, 0);
if (ret != 0) {
/* Do not hand out a signature made while the key changed. */
ForceZero(out, ED25519_SIG_SIZE);
}
}
ForceZero(orig_k, sizeof(orig_k));
#ifdef WOLFSSL_CHECK_MEM_ZERO
Expand Down
15 changes: 14 additions & 1 deletion wolfcrypt/src/ed448.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/* Possible Ed448 enable options:
* WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN Default: OFF
* Check that the private key didn't change during the signing operations.
* Enabled by --enable-faultharden. Covers the software signer only: a
* signature made by a device (SE050, crypto callback) uses the key the
* device holds and is that device's responsibility.
*/

#define WC_FIPS_LL_CRYPTO
Expand Down Expand Up @@ -623,6 +626,10 @@ int wc_ed448_sign_msg_ex(const byte* in, word32 inLen, byte* out,
if (key->devId != INVALID_DEVID)
#endif
{
/* A device that signs uses the key it holds, so the
* WOLFSSL_EDDSA_CHECK_PRIV_ON_SIGN check below, which guards the
* software signer's copy of the key, is the device's to
* provide. */
ret = wc_CryptoCb_Ed448Sign(in, inLen, out, outLen, key, type,
context, contextLen);
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
Expand Down Expand Up @@ -777,7 +784,13 @@ int wc_ed448_sign_msg_ex(const byte* in, word32 inLen, byte* out,
for (i = 0; i < ED448_KEY_SIZE; i++) {
c |= key->k[i] ^ orig_k[i];
}
ret = ctMaskGT(c, 0) & SIG_VERIFY_E;
/* ctMaskGT() gives a byte mask: select the error code with it rather
* than AND it into the (negative) error code. */
ret = ctMaskSelInt(ctMaskGT(c, 0), SIG_VERIFY_E, 0);
if (ret != 0) {
/* Do not hand out a signature made while the key changed. */
ForceZero(out, ED448_SIG_SIZE);
}
}
ForceZero(orig_k, sizeof(orig_k));
#ifdef WOLFSSL_CHECK_MEM_ZERO
Expand Down
39 changes: 39 additions & 0 deletions wolfcrypt/src/port/nxp/README_SE050.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ SHA2-384, SHA2-512) to the SE050. This is MUCH slower than using wolfCrypt
software cryptography due to the I2C communication channel. This support is
disabled by default unless this define explicitly enables it.

The SHA-256 or SHA-512 inside wolfCrypt's Hash DRBG stays in software either
way, so the DRBG state (V, C and seed material) never crosses the I2C bus and
generating random data sends no commands to the SE050.

The SE050 keeps no intermediate digest, so the raw hash accessors
(`wc_ShaFinalRaw()`, `wc_Sha512FinalRaw()`, `wc_Sha256FinalRaw()` and the
`wc_Sha*Transform()` functions) return `NOT_COMPILED_IN` for a hash on the
SE050. This define therefore also defines `WOLFSSL_NO_HASH_RAW`, so TLS, LMS
and XMSS use the full hash calls.

**`WOLFSSL_SE050_CRYPT`**

wolfSSL supports offloading symmetric crypto operations (AES-ECB/CBC) to the
Expand Down Expand Up @@ -582,6 +592,35 @@ build routes to the SE05x, while holding this lock; those acquire it
internally. wolfCrypt operations on other hardware, such as an on-chip
accelerator, do not take this lock and may be used while it is held.

### SE05x Sessions and fork()

A child created with `fork()` inherits the parent's SE05x session: the
transport file descriptor, the T=1 protocol state and, with Platform SCP03,
the secure channel state. If both processes sent commands on it, the commands
would interleave and break the session for both. The child also inherits the
SE05x mutex, possibly locked by a parent thread that does not exist in the
child.

On systems with `getpid()`, the port records which process configured the
session and refuses the session in any other process. In a forked child,
`wc_se050_lock()` and every wolfCrypt operation that the build routes to the
SE05x fail with an error (for example `BAD_STATE_E`, `BAD_MUTEX_E` or
`WC_HW_E`) and send nothing. The parent's session is not affected. Without
`WOLFSSL_SE050_NO_TRNG` this includes the seed, so a child cannot reseed or
draw from a `WC_RNG` in those builds either. The DRBG's own hash runs in
software, also with `WOLFSSL_SE050_HASH`, so it does not stop a child.

A child that needs the SE05x must set up its own session, and only once the
parent no longer uses its session (for example after the parent of a
daemonizing `fork()` has exited):

- With `WOLFSSL_SE050_INIT`, call `wc_se050_close()` (or `wolfCrypt_Cleanup()`
for the last reference) in the child. In a child this discards the inherited
session without sending anything. Then call `wc_se050_init()` or
`wc_se050_init_ex()`, or `wolfCrypt_Init()`, to open a new one.
- With an application session, open a new one through the middleware and pass
it to `wc_se050_set_config()` in the child.

### wolfSSL SE050 Key Generation

wolfSSL includes APIs for key generation when `WOLFSSL_KEY_GEN` has been
Expand Down
Loading
Loading