# HG changeset patch # User Matt Johnston # Date 1365004498 -28800 # Node ID 24172f555f9cdd997bd81c8f5eb852c5e72b4433 # Parent 685d05f1cc5c1a2f21509c209397f423845af473 Fix MAC bug which would prevent asymmetric hashes diff -r 685d05f1cc5c -r 24172f555f9c packet.c --- a/packet.c Wed Apr 03 19:23:53 2013 +0800 +++ b/packet.c Wed Apr 03 23:54:58 2013 +0800 @@ -74,6 +74,8 @@ len = writebuf->len - 1 - writebuf->pos; dropbear_assert(len > 0); all_ignore &= (packet_type == SSH_MSG_IGNORE); + TRACE2(("write_packet writev #%d type %d len %d/%d", i, packet_type, + len, writebuf->len-1)) iov[i].iov_base = buf_getptr(writebuf, len); iov[i].iov_len = len; } @@ -366,7 +368,7 @@ unsigned char mac_bytes[MAX_MAC_LEN]; unsigned int mac_size, contents_len; - mac_size = ses.keys->trans.algo_mac->hashsize; + mac_size = ses.keys->recv.algo_mac->hashsize; contents_len = ses.readbuf->len - mac_size; buf_setpos(ses.readbuf, 0); @@ -455,7 +457,6 @@ ses.reply_queue_head = new_item; } ses.reply_queue_tail = new_item; - TRACE2(("leave enqueue_reply_packet")) } void maybe_flush_reply_queue() { @@ -500,16 +501,12 @@ TRACE2(("encrypt_packet type is %d", packet_type)) - if ((!ses.dataallowed && !packet_is_okay_kex(packet_type)) - || ses.kexstate.sentnewkeys) { + if ((!ses.dataallowed && !packet_is_okay_kex(packet_type))) { /* 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. */ + TRACE2(("Delay sending reply packet. dataallowed %d, type %d, sentnewkeys %d", + ses.dataallowed, packet_type, ses.kexstate.sentnewkeys)) enqueue_reply_packet(); return; }