Skip to content

Commit 0765095

Browse files
committed
First packet follows check needs pubkey guess
When processing the KEX Init message, also stash a guess for the peer's public key algorithm. When checking first_packet_follows when handling the KEX Dh Init message, need to check both KEX and public key guesses. Affected functions: DoKexInit, DoKexDhInit. Issue: F-1686
1 parent e9d288e commit 0765095

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/internal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4350,6 +4350,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
43504350
}
43514351
}
43524352
if (ret == WS_SUCCESS) {
4353+
ssh->handshake->pubKeyIdGuess = list[0];
43534354
algoId = MatchIdLists(side, list, listSz, cannedList, cannedListSz);
43544355
if (algoId == ID_UNKNOWN) {
43554356
WLOG(WS_LOG_DEBUG, "Unable to negotiate Server Host Key Algo");
@@ -4816,7 +4817,8 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
48164817

48174818
if (ret == WS_SUCCESS) {
48184819
if (ssh->handshake->kexPacketFollows
4819-
&& ssh->handshake->kexIdGuess != ssh->handshake->kexId) {
4820+
&& (ssh->handshake->kexIdGuess != ssh->handshake->kexId ||
4821+
ssh->handshake->pubKeyIdGuess != ssh->handshake->pubKeyId)) {
48204822

48214823
/* skip this message. */
48224824
WLOG(WS_LOG_DEBUG, "Skipping the client's KEX init function.");

wolfssh/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ typedef struct HandshakeInfo {
628628
byte kexIdGuess;
629629
byte kexHashId;
630630
byte pubKeyId;
631+
byte pubKeyIdGuess;
631632
byte encryptId;
632633
byte macId;
633634
byte kexPacketFollows;

0 commit comments

Comments
 (0)