Skip to content

Fix SHE master ECU key fallback writing metadata to wrong variable#294

Merged
bigbrett merged 1 commit intowolfSSL:mainfrom
sameehj:fix
Mar 2, 2026
Merged

Fix SHE master ECU key fallback writing metadata to wrong variable#294
bigbrett merged 1 commit intowolfSSL:mainfrom
sameehj:fix

Conversation

@sameehj
Copy link
Copy Markdown
Contributor

@sameehj sameehj commented Feb 27, 2026

In wh_Server_KeystoreReadKey, the SHE master ECU key fallback path (when the key is not found in cache or NVM) correctly zeroed outMeta but then wrote len and id to the local stack variable meta instead of the caller's output parameter outMeta. This left the caller with a zeroed metadata struct (len=0, id=0), contradicting the intended behavior of returning WH_SHE_KEY_SZ and the correct keyId.

Add a direct server-side test that exercises the fallback by reading the master ECU key without provisioning it, verifying the returned metadata contains the correct len and id.

In wh_Server_KeystoreReadKey, the SHE master ECU key fallback path
(when the key is not found in cache or NVM) correctly zeroed outMeta
but then wrote len and id to the local stack variable `meta` instead
of the caller's output parameter `outMeta`. This left the caller with
a zeroed metadata struct (len=0, id=0), contradicting the intended
behavior of returning WH_SHE_KEY_SZ and the correct keyId.

Also fix two related issues in the same function:
 - Use sizeof(*outMeta) instead of sizeof(meta) in memset/memcpy
   calls targeting outMeta, for clarity and consistency with the
   target variable.
 - Add a NULL check on `out` before memset in the SHE fallback,
   matching the guards already present in the cache and NVM paths.

Add a direct server-side test that exercises the fallback by reading
the master ECU key without provisioning it, verifying the returned
metadata contains the correct len and id.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
@bigbrett bigbrett merged commit 3d6f973 into wolfSSL:main Mar 2, 2026
51 checks passed
@bigbrett
Copy link
Copy Markdown
Contributor

bigbrett commented Mar 2, 2026

Thanks @sameehj !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants