1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Add 'next_message' methods to cipher and MAC vtables.

This provides a convenient hook to be called between SSH messages, for
the crypto components to do any per-message processing like
incrementing a sequence number.
This commit is contained in:
Simon Tatham
2022-08-16 18:27:06 +01:00
parent 9160c41e7b
commit 840043f06e
12 changed files with 66 additions and 0 deletions

View File

@ -513,6 +513,10 @@ static void ssh2_bpp_handle_input(BinaryPacketProtocol *bpp)
dts_consume(&s->stats->in, s->packetlen);
s->pktin->sequence = s->in.sequence++;
if (s->in.cipher)
ssh_cipher_next_message(s->in.cipher);
if (s->in.mac)
ssh2_mac_next_message(s->in.mac);
s->length = s->packetlen - s->pad;
assert(s->length >= 0);
@ -819,6 +823,10 @@ static void ssh2_bpp_format_packet_inner(struct ssh2_bpp_state *s, PktOut *pkt)
}
s->out.sequence++; /* whether or not we MACed */
if (s->out.cipher)
ssh_cipher_next_message(s->out.cipher);
if (s->out.mac)
ssh2_mac_next_message(s->out.mac);
dts_consume(&s->stats->out, origlen + padding);
}