Skip to content

JSSE: check if inRemaining == 0#351

Merged
cconlon merged 2 commits intowolfSSL:masterfrom
rlm2002:sunJSSE_ServerName
Apr 6, 2026
Merged

JSSE: check if inRemaining == 0#351
cconlon merged 2 commits intowolfSSL:masterfrom
rlm2002:sunJSSE_ServerName

Conversation

@rlm2002
Copy link
Copy Markdown
Contributor

@rlm2002 rlm2002 commented Apr 3, 2026

Adds a check for inRemaining == 0 when detecting if status needs to be set to BUFFER_UNDERFLOW. inRemaining is the input buffer size at unwrap entry, while in.remaining() is after processing. Requiring both to be 0 limits this path to the “no bytes were supplied this call” case. Avoids “all supplied bytes were consumed but more ciphertext is still needed” case being handled the same way.

Adds regression test testHandshakeUnwrapConsumedNotBufferUnderflow().

Fixes SunJSSE ServerName tests: ServerName/SSLEngineExplorerMatchedSNI.java, ServerName/SSLEngineExplorerWithCli.java, ServerName/SSLEngineExplorerWithSrv.java

@rlm2002 rlm2002 self-assigned this Apr 3, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines wolfJSSE SSLEngine.unwrap() status mapping to avoid returning BUFFER_UNDERFLOW when the caller did provide input bytes (but those bytes were consumed and native wolfSSL still needs more ciphertext). It also adds a regression test covering this specific “consumed input but still WANT_READ” handshake scenario in TLS 1.3.

Changes:

  • Tighten the BUFFER_UNDERFLOW detection condition by additionally requiring inRemaining == 0 (no bytes supplied at unwrap entry).
  • Add a TLS 1.3 regression test ensuring unwrap() does not return BUFFER_UNDERFLOW when it consumed non-empty handshake input.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java Adds inRemaining == 0 guard to restrict BUFFER_UNDERFLOW to the “no input provided” case.
src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java Adds regression test testHandshakeUnwrapConsumedNotBufferUnderflow() for the adjusted unwrap-status behavior in TLS 1.3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cconlon cconlon merged commit d7de709 into wolfSSL:master Apr 6, 2026
105 checks passed
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