Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5936,6 +5936,12 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
ret = SendKexDhReply(ssh);
}

/* RFC 8731 sec. 3: a rejected key exchange input aborts with a
* disconnect */
if (ret == WS_CRYPTO_FAILED || ret == WS_PUBKEY_REJECTED_E) {
(void)SendDisconnect(ssh, WOLFSSH_DISCONNECT_KEY_EXCHANGE_FAILED);
}

return ret;
}

Expand Down Expand Up @@ -7619,6 +7625,15 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)

if (sigKeyBlock_ptr)
WFREE(sigKeyBlock_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY);
/* RFC 4253 11.1: WS_PUBKEY_REJECTED_E here is only the host key check,
* which is server authentication, so it gets its own reason. */
if (ret == WS_CRYPTO_FAILED) {
(void)SendDisconnect(ssh, WOLFSSH_DISCONNECT_KEY_EXCHANGE_FAILED);
Comment thread
yosuke-wolfssl marked this conversation as resolved.
Comment thread
yosuke-wolfssl marked this conversation as resolved.
}
else if (ret == WS_PUBKEY_REJECTED_E) {
(void)SendDisconnect(ssh,
WOLFSSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE);
}
WLOG(WS_LOG_DEBUG, "Leaving DoKexDhReply(), ret = %d", ret);
return ret;
}
Expand Down Expand Up @@ -8019,6 +8034,12 @@ static int DoKexDhGexGroup(WOLFSSH* ssh,
ret = SendKexDhInit(ssh);
}

/* RFC 4419 sec. 3: a group outside the requested range fails the key
* exchange */
if (ret == WS_CRYPTO_FAILED || ret == WS_DH_SIZE_E) {
Comment thread
yosuke-wolfssl marked this conversation as resolved.
(void)SendDisconnect(ssh, WOLFSSH_DISCONNECT_KEY_EXCHANGE_FAILED);
Comment thread
yosuke-wolfssl marked this conversation as resolved.
}

return ret;
}

Expand Down
Loading
Loading