Skip to content

Zero TLS 1.3 traffic keys after AES SE offload#10246

Open
sameehj wants to merge 1 commit intowolfSSL:masterfrom
sameehj:aes-gcm-fix
Open

Zero TLS 1.3 traffic keys after AES SE offload#10246
sameehj wants to merge 1 commit intowolfSSL:masterfrom
sameehj:aes-gcm-fix

Conversation

@sameehj
Copy link
Copy Markdown
Contributor

@sameehj sameehj commented Apr 17, 2026

Description

When WOLF_CRYPTO_CB_AES_SETKEY is enabled and a CryptoCB callback imports the AES key into a Secure Element (aes->devCtx != NULL), the TLS-layer copy in keys->{client,server}_write_key has no further consumer: the software key schedule is not populated on offload. ForceZero it in SetKeysSide() per provisioned side.

The static IVs (keys->{client,server}write_IV and keys->aead{enc,dec}imp_IV) are left intact because BuildTls13Nonce() reads aead{enc,dec}_imp_IV on every record (RFC 8446 Section 5.3).

Scope: TLS 1.3, non-DTLS, non-QUIC. DTLS 1.3 needs the write keys in Dtls13EpochCopyKeys; TLS 1.2 needs them for rehandshake; QUIC is untouched pending audit.

Add two memio tests (test_wc_CryptoCb_Tls13_Key_{Zero_After_Offload, No_Zero_Without_Offload}) that pin AES-GCM and check key / IV state after the handshake and a KeyUpdate round.

Testing

Built and ran the full unit.test suite:
./configure --enable-cryptocb --enable-aesgcm --enable-tls13
CPPFLAGS='-DWOLF_CRYPTO_CB_AES_SETKEY
-DHAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES'
make && ./tests/unit.test
Result: 0 failed / 1036 skipped / 337 passed / 1373 total. The two new
memio tests (test_wc_CryptoCb_Tls13_Key_Zero_After_Offload and
test_wc_CryptoCb_Tls13_Key_No_Zero_Without_Offload)

Checklist

  • added tests
  • updated/added doxygen - N/A (no public API changed)
  • updated appropriate READMEs - N/A
  • Updated manual and documentation - ChangeLog.md entry added

When WOLF_CRYPTO_CB_AES_SETKEY is enabled and a CryptoCB callback
imports the AES key into a Secure Element (aes->devCtx != NULL), the
TLS-layer copy in keys->{client,server}_write_key has no further
consumer: the software key schedule is not populated on offload.
ForceZero it in SetKeysSide() per provisioned side.

The static IVs (keys->{client,server}_write_IV and
keys->aead_{enc,dec}_imp_IV) are left intact because BuildTls13Nonce()
reads aead_{enc,dec}_imp_IV on every record (RFC 8446 Section 5.3).

Scope: TLS 1.3, non-DTLS, non-QUIC.  DTLS 1.3 needs the write keys
in Dtls13EpochCopyKeys; TLS 1.2 needs them for rehandshake; QUIC is
untouched pending audit.

Add two memio tests (test_wc_CryptoCb_Tls13_Key_{Zero_After_Offload,
No_Zero_Without_Offload}) that pin AES-GCM and check key / IV state
after the handshake and a KeyUpdate round.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

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.

1 participant