mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-13 17:17:37 -05:00
New system for tracking data-limit-based rekeys.
I've removed the encrypted_len fields from PktIn and PktOut, which were used to communicate from the BPP to ssh.c how much each packet contributed to the amount of data encrypted with a given set of cipher keys. It seems more sensible to have the BPP itself keep that counter - especially since only one of the three BPPs even needs to count it at all. So now there's a new DataTransferStats structure which the BPP updates, and ssh.c only needs to check it for overflow and reset the limits.
This commit is contained in:
27
sshbpp.h
27
sshbpp.h
@ -36,7 +36,32 @@ void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
|
||||
const void *session_key);
|
||||
void ssh1_bpp_start_compression(BinaryPacketProtocol *bpp);
|
||||
|
||||
BinaryPacketProtocol *ssh2_bpp_new(void);
|
||||
/*
|
||||
* Structure that tracks how much data is sent and received, for
|
||||
* purposes of triggering an SSH-2 rekey when either one gets over a
|
||||
* configured limit. In each direction, the flag 'running' indicates
|
||||
* that we haven't hit the limit yet, and 'remaining' tracks how much
|
||||
* longer until we do. The macro DTS_CONSUME subtracts a given amount
|
||||
* from the counter in a particular direction, and evaluates to a
|
||||
* boolean indicating whether the limit has been hit.
|
||||
*
|
||||
* The limit is sticky: once 'running' has flipped to false,
|
||||
* 'remaining' is no longer decremented, so it shouldn't dangerously
|
||||
* wrap round.
|
||||
*/
|
||||
struct DataTransferStats {
|
||||
struct {
|
||||
int running;
|
||||
unsigned long remaining;
|
||||
} in, out;
|
||||
};
|
||||
#define DTS_CONSUME(stats, direction, size) \
|
||||
((stats)->direction.running && \
|
||||
(stats)->direction.remaining <= (size) ? \
|
||||
((stats)->direction.running = FALSE, TRUE) : \
|
||||
((stats)->direction.remaining -= (size), FALSE))
|
||||
|
||||
BinaryPacketProtocol *ssh2_bpp_new(struct DataTransferStats *stats);
|
||||
void ssh2_bpp_new_outgoing_crypto(
|
||||
BinaryPacketProtocol *bpp,
|
||||
const struct ssh2_cipheralg *cipher, const void *ckey, const void *iv,
|
||||
|
Reference in New Issue
Block a user