Visitar URL original
kex: skip signaling-type kex entries when negotiating by vszakats · Pull Request #2199 · libssh2/libssh2 · GitHub
Skip to content
Open
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
38 changes: 22 additions & 16 deletions src/kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,8 @@ static int kex_agree_kex_hostkey(LIBSSH2_SESSION *session,
/* We have agreed on a key exchange method,
* Can we agree on a hostkey that works with this kex?
*/
if(kex_agree_hostkey(session, method->flags, hostkey,
if(method->exchange_keys &&
kex_agree_hostkey(session, method->flags, hostkey,
hostkey_len) == 0) {
session->kex = method;
if(session->burn_optimistic_kexinit && kex == q)
Expand All @@ -3344,22 +3345,27 @@ static int kex_agree_kex_hostkey(LIBSSH2_SESSION *session,
}

while(*kexp && (*kexp)->name) {
s = ssh2_kex_agree_instr(kex, kex_len,
(*kexp)->name, strlen((*kexp)->name));
if(s) {
/* We have agreed on a key exchange method,
* Can we agree on a hostkey that works with this kex?
*/
if(kex_agree_hostkey(session, (*kexp)->flags, hostkey,
hostkey_len) == 0) {
session->kex = *kexp;
if(session->burn_optimistic_kexinit && kex == s)
/* Server sent an optimistic packet, and client agrees
* with preference cancel burning the first KEX_INIT
* packet that comes in */
session->burn_optimistic_kexinit = 0;
/* Skip signalling-only entries (ext-info-c,
* kex-strict-c-v00@openssh.com) that carry no real KEX implementation
* and must never be selected as the negotiated method. */
if((*kexp)->exchange_keys) {
s = ssh2_kex_agree_instr(kex, kex_len,
(*kexp)->name, strlen((*kexp)->name));
if(s) {
/* We have agreed on a key exchange method,
* Can we agree on a hostkey that works with this kex?
*/
if(kex_agree_hostkey(session, (*kexp)->flags, hostkey,
hostkey_len) == 0) {
session->kex = *kexp;
if(session->burn_optimistic_kexinit && kex == s)
/* Server sent an optimistic packet, and client agrees
* with preference cancel burning the first KEX_INIT
* packet that comes in */
session->burn_optimistic_kexinit = 0;

return 0;
return 0;
}
}
}
kexp++;
Expand Down
Loading