Repository navigation
Add missing fields to wolfSSL_clear to ensure the WOLFSSL struct is fully reset. Ensure ephemeral keys are always freed between each handshake. #11964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kareem-wolfssl
wants to merge
9
commits into
wolfSSL:master
Choose a base branch
from
kareem-wolfssl:zd22693
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,140
−88
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fa901e5
Ensure ephemeral keys are always freed between each handshake.
kareem-wolfssl 7d5b4da
Add missing fields to wolfSSL_clear to ensure the WOLFSSL struct is f…
kareem-wolfssl 634fe9e
Free old clSuitesStack when new suites are set, to avoid giving stale…
kareem-wolfssl 63fad54
Thoroughly test wolfSSL_clear for a variety of scenarios.
kareem-wolfssl 7f652e0
Reset alert history and peerVerify on wolfSSL_clear and on new connec…
kareem-wolfssl 758de64
Free ephemeral keys on renegotiation.
kareem-wolfssl 951192f
Fully clear async state in wolfSSL_clear before clearing keys.
kareem-wolfssl 20243e2
Fully clear the session ticket and ID on full handshake.
kareem-wolfssl fa57410
Restore default HMAC in wolfSSL_clear.
kareem-wolfssl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Resumed client connections now report X509_V_OK from wolfSSL_get_verify_result(), even when the cached session recorded a verify error. The new ResetPeerResults() call in ReinitSSL runs at the first wolfSSL_connect(). That is after wolfSSL_set_session() has copied session->peerVerifyRet into ssl->peerVerifyRet (ssl_sess.c:1750). A resumption verifies no certificate, so the value stays 0. Fix: keep a value restored from the session (and one set with wolfSSL_set_verify_result()) when the connection starts. For example, skip the peerVerifyRet reset when options.resuming is set, or re-apply ssl->session->peerVerifyRet after the reset.
Why this was flagged
An OPENSSL_EXTRA client using WOLFSSL_VERIFY_NONE completes a first handshake with a bad certificate, so peerVerifyRet is nonzero. For the next connection the app calls wolfSSL_set_session(). SetSession sets options.resuming and copies session->peerVerifyRet into ssl->peerVerifyRet (ssl_sess.c:1750). wolfSSL_connect() then calls ReinitSSL (ssl_api_hs.c:413, tls13.c:16992). At that point handShakeDone == 0 and connectState == CONNECT_BEGIN (0), so the new block at internal.c:9025-9030 calls ResetPeerResults(), which sets peerVerifyRet = 0 (internal.c:10968). The resumed handshake processes no Certificate, so wolfSSL_get_verify_result() returns 0 (X509_V_OK). An app that checks the verify result by hand then accepts an unverified peer. When the session is saved again, ssl_sess.c:4076 writes the 0 back, so the error is gone for every later resumption too. On the base branch, ReinitSSL never touched peerVerifyRet, so the restored error was still reported.
Verification: SetSession restores the result before connect (ssl_sess.c:1750). In wolfSSL_connect (ssl_api_hs.c:413), ReinitSSL runs while handShakeDone==0 and connectState==CONNECT_BEGIN, so the new block at internal.c:9025-9030 calls ResetPeerResults(), which sets
ssl->peerVerifyRet = 0;(internal.c:10968). On the base branch this reset did not exist. The new tests check only full handshakes and never resumption.