Skip to content

First packet follows check needs pubkey guess#927

Open
ejohnstown wants to merge 2 commits intowolfSSL:masterfrom
ejohnstown:first-kex-follows
Open

First packet follows check needs pubkey guess#927
ejohnstown wants to merge 2 commits intowolfSSL:masterfrom
ejohnstown:first-kex-follows

Conversation

@ejohnstown
Copy link
Copy Markdown
Contributor

@ejohnstown ejohnstown commented Apr 16, 2026

When processing the KEX Init message, stash guesses for the peer's KEX and public key algorithms. When reading first_packet_follows, if set check the guesses and set the handshake info flag ignoreNextKexMsg. When processing the KexDhInit message, check that flag.

Affected functions: DoKexInit, DoKexDhInit.
Issue: F-1686

Copilot AI review requested due to automatic review settings April 16, 2026 21:15
Copy link
Copy Markdown
Contributor

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

Updates KEX negotiation handling to correctly evaluate the SSH first_packet_follows optimization by tracking and validating both the peer’s guessed KEX algorithm and guessed server host key algorithm (Issue F-1686).

Changes:

  • Add pubKeyIdGuess to HandshakeInfo to store the peer’s first “server host key algorithms” preference from KEXINIT.
  • In DoKexInit(), stash the peer’s host-key-algorithm guess (list[0]) alongside the existing KEX guess.
  • In DoKexDhInit(), skip the first packet that follows KEXINIT when either the KEX guess or host-key guess differs from the negotiated algorithms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
wolfssh/internal.h Extends handshake state to track the peer’s host-key algorithm guess for first_packet_follows validation.
src/internal.c Records host-key guess during KEXINIT parsing and uses it in the first_packet_follows skip decision during KEXDH/ECDH init handling.

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

Comment thread src/internal.c Outdated
Copilot AI review requested due to automatic review settings April 16, 2026 23:33
Copy link
Copy Markdown
Contributor

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

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


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

Comment thread src/internal.c
Comment thread src/internal.c Outdated
Comment thread tests/regress.c
When processing the KEX Init message, stash guesses for the peer's
KEX and public key algorithms. When reading first_packet_follows, if set
check the guesses and set the handshake info flag ignoreNextKexMsg. When
processing the KexDhInit message, check that flag.

Affected functions: DoKexInit, DoKexDhInit.
Issue: F-1686
Copilot AI review requested due to automatic review settings April 17, 2026 00:57
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


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

Comment thread src/internal.c
Add a regression for checking the `first_kex_packet_follows` flag versus
the guesses for KEX algorithm and public key algorithm.
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