Each time tokio::select polled the cipher, Thrussh attempted to read the length of the packet, consuming 4 bytes each times. For packets that didn't arrive in one TCP packet, this resulted in incorrect packet length, and a stall of the protocol.
XEKZBXNINGU2NELIKOQXWY5SS4MOVEVXX3QWQUSN42X7V46CQDKQC
let mut len = [0; 4];
stream.read_exact(&mut len).await?;
debug!("len = {:?}", len);
{
let key = pair.remote_to_local.as_opening_key();
let seqn = buffer.seqn.0;
buffer.buffer.clear();
buffer.buffer.extend(&len);
let len = key.decrypt_packet_length(seqn, len);
let len = BigEndian::read_u32(&len) as usize + key.tag_len();
debug!("clear len = {:?}", len);
buffer.buffer.resize(len + 4);
if buffer.len == 0 {
let mut len = [0; 4];
stream.read_exact(&mut len).await?;
debug!("reading, len = {:?}", len);
{
let key = pair.remote_to_local.as_opening_key();
let seqn = buffer.seqn.0;
buffer.buffer.clear();
buffer.buffer.extend(&len);
debug!("reading, seqn = {:?}", seqn);
let len = key.decrypt_packet_length(seqn, len);
buffer.len = BigEndian::read_u32(&len) as usize + key.tag_len();
debug!("reading, clear len = {:?}", buffer.len);
}