Skip to content

Commit be9d8d2

Browse files
internal: send a disconnect when key exchange fails
- Send SSH_MSG_DISCONNECT with KEY_EXCHANGE_FAILED from DoKexDhReply() and DoKexDhInit() when the peer's key material is rejected. - Add KEXDH_REPLY f-truncation and KEXDH_INIT e-truncation and e-empty mutator modes to the regression harness. - Record outbound disconnects on the duplex endpoints and assert the reason code in the host-key rejection tests. Issue: F-8838
1 parent 326d181 commit be9d8d2

2 files changed

Lines changed: 264 additions & 15 deletions

File tree

src/internal.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5708,6 +5708,12 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
57085708
ret = SendKexDhReply(ssh);
57095709
}
57105710

5711+
/* RFC 4253 7.1: tell the peer the key exchange failed. Both codes are
5712+
* fatal, never a would-block. */
5713+
if (ret == WS_CRYPTO_FAILED || ret == WS_PUBKEY_REJECTED_E) {
5714+
(void)SendDisconnect(ssh, WOLFSSH_DISCONNECT_KEY_EXCHANGE_FAILED);
5715+
}
5716+
57115717
return ret;
57125718
}
57135719

@@ -7391,6 +7397,11 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
73917397

73927398
if (sigKeyBlock_ptr)
73937399
WFREE(sigKeyBlock_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY);
7400+
/* RFC 4253 7.1: tell the peer the key exchange failed. Both codes are
7401+
* fatal, never a would-block. */
7402+
if (ret == WS_CRYPTO_FAILED || ret == WS_PUBKEY_REJECTED_E) {
7403+
(void)SendDisconnect(ssh, WOLFSSH_DISCONNECT_KEY_EXCHANGE_FAILED);
7404+
}
73947405
WLOG(WS_LOG_DEBUG, "Leaving DoKexDhReply(), ret = %d", ret);
73957406
return ret;
73967407
}

0 commit comments

Comments
 (0)