diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2016-09-06 09:22:57 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2016-09-06 09:22:57 +0000 |
commit | f0244c3e2dcad0db892c185d8dfadceb7c792d65 (patch) | |
tree | 3f7452d01e47003f4824807881762d944c3d4e77 /usr.bin/ssh | |
parent | 1c87b31e8069c2cfabd2ba0a333d7af5aeb31f72 (diff) |
ssh_set_newkeys: print correct block counters on rekeying; ok djm@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/packet.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c index ff7a0e57631..f4eb43c7934 100644 --- a/usr.bin/ssh/packet.c +++ b/usr.bin/ssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.235 2016/08/03 05:41:57 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.236 2016/09/06 09:22:56 markus Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -966,30 +966,31 @@ ssh_set_newkeys(struct ssh *ssh, int mode) struct sshmac *mac; struct sshcomp *comp; struct sshcipher_ctx **ccp; + struct packet_state *ps; u_int64_t *max_blocks; - const char *wmsg; + const char *wmsg, *dir; int r, crypt_type; debug2("set_newkeys: mode %d", mode); if (mode == MODE_OUT) { + dir = "output"; ccp = &state->send_context; crypt_type = CIPHER_ENCRYPT; - state->p_send.packets = state->p_send.blocks = 0; + ps = &state->p_send; max_blocks = &state->max_blocks_out; } else { + dir = "input"; ccp = &state->receive_context; crypt_type = CIPHER_DECRYPT; - state->p_read.packets = state->p_read.blocks = 0; + ps = &state->p_read; max_blocks = &state->max_blocks_in; } if (state->newkeys[mode] != NULL) { - debug("set_newkeys: rekeying, input %llu bytes %llu blocks, " - "output %llu bytes %llu blocks", - (unsigned long long)state->p_read.bytes, - (unsigned long long)state->p_read.blocks, - (unsigned long long)state->p_send.bytes, - (unsigned long long)state->p_send.blocks); + debug("%s: rekeying after %llu %s blocks" + " (%llu bytes total)", __func__, + (unsigned long long)ps->blocks, dir, + (unsigned long long)ps->bytes); cipher_free(*ccp); *ccp = NULL; enc = &state->newkeys[mode]->enc; @@ -1007,6 +1008,8 @@ ssh_set_newkeys(struct ssh *ssh, int mode) free(comp->name); free(state->newkeys[mode]); } + /* note that both bytes and the seqnr are not reset */ + ps->packets = ps->blocks = 0; /* move newkeys from kex to state */ if ((state->newkeys[mode] = ssh->kex->newkeys[mode]) == NULL) return SSH_ERR_INTERNAL_ERROR; |