summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2011-06-07 11:55:44 +0000
committerMatt Johnston <matt@ucc.asn.au>2011-06-07 11:55:44 +0000
commit4b42ee4a3d866e6ccdb1ed49a742cd73764da227 (patch)
treee5621d96aad5611e969fb6c09c9cee2b5a228e1d
parent24c6d458699893a70bee9e12f0c2851a164c1048 (diff)
downloaddropbear-4b42ee4a3d866e6ccdb1ed49a742cd73764da227.tar.gz
Fix case where "-K 1" would cause a SSH_MSG_IGNORE packet to be sent
with the wrong encryption key ("bad packet length" symptom) while key exchange was happening.
-rw-r--r--kex.h4
-rw-r--r--packet.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/kex.h b/kex.h
index a3bdc7a..c89b0a3 100644
--- a/kex.h
+++ b/kex.h
@@ -52,8 +52,8 @@ struct KEXState {
unsigned sentkexinit : 1; /*set when we've sent/recv kexinit packet */
unsigned recvkexinit : 1;
unsigned firstfollows : 1; /* true when first_kex_packet_follows is set */
- unsigned sentnewkeys : 1; /* set once we've send/recv'ed MSG_NEWKEYS*/
- unsigned recvnewkeys : 1;
+ unsigned sentnewkeys : 1; /* set once we've send MSG_NEWKEYS (will be cleared once we have also received */
+ unsigned recvnewkeys : 1; /* set once we've received MSG_NEWKEYS (cleared once we have also sent */
unsigned donefirstkex : 1; /* Set to 1 after the first kex has completed,
ie the transport layer has been set up */
diff --git a/packet.c b/packet.c
index 80eb177..349ed40 100644
--- a/packet.c
+++ b/packet.c
@@ -441,10 +441,16 @@ void encrypt_packet() {
TRACE(("encrypt_packet type is %d", packet_type))
- if (!ses.dataallowed && !packet_is_okay_kex(packet_type)) {
+ if ((!ses.dataallowed && !packet_is_okay_kex(packet_type))
+ || ses.kexstate.sentnewkeys) {
/* During key exchange only particular packets are allowed.
Since this packet_type isn't OK we just enqueue it to send
after the KEX, see maybe_flush_reply_queue */
+
+ /* We also enqueue packets here when we have sent a MSG_NEWKEYS
+ * packet but are yet to received one. For simplicity we just switch
+ * over all the keys at once. This is the 'ses.kexstate.sentnewkeys'
+ * case. */
enqueue_reply_packet();
return;
}