version 1.235, 2016/08/03 05:41:57 |
version 1.236, 2016/09/06 09:22:56 |
|
|
struct sshmac *mac; |
struct sshmac *mac; |
struct sshcomp *comp; |
struct sshcomp *comp; |
struct sshcipher_ctx **ccp; |
struct sshcipher_ctx **ccp; |
|
struct packet_state *ps; |
u_int64_t *max_blocks; |
u_int64_t *max_blocks; |
const char *wmsg; |
const char *wmsg, *dir; |
int r, crypt_type; |
int r, crypt_type; |
|
|
debug2("set_newkeys: mode %d", mode); |
debug2("set_newkeys: mode %d", mode); |
|
|
if (mode == MODE_OUT) { |
if (mode == MODE_OUT) { |
|
dir = "output"; |
ccp = &state->send_context; |
ccp = &state->send_context; |
crypt_type = CIPHER_ENCRYPT; |
crypt_type = CIPHER_ENCRYPT; |
state->p_send.packets = state->p_send.blocks = 0; |
ps = &state->p_send; |
max_blocks = &state->max_blocks_out; |
max_blocks = &state->max_blocks_out; |
} else { |
} else { |
|
dir = "input"; |
ccp = &state->receive_context; |
ccp = &state->receive_context; |
crypt_type = CIPHER_DECRYPT; |
crypt_type = CIPHER_DECRYPT; |
state->p_read.packets = state->p_read.blocks = 0; |
ps = &state->p_read; |
max_blocks = &state->max_blocks_in; |
max_blocks = &state->max_blocks_in; |
} |
} |
if (state->newkeys[mode] != NULL) { |
if (state->newkeys[mode] != NULL) { |
debug("set_newkeys: rekeying, input %llu bytes %llu blocks, " |
debug("%s: rekeying after %llu %s blocks" |
"output %llu bytes %llu blocks", |
" (%llu bytes total)", __func__, |
(unsigned long long)state->p_read.bytes, |
(unsigned long long)ps->blocks, dir, |
(unsigned long long)state->p_read.blocks, |
(unsigned long long)ps->bytes); |
(unsigned long long)state->p_send.bytes, |
|
(unsigned long long)state->p_send.blocks); |
|
cipher_free(*ccp); |
cipher_free(*ccp); |
*ccp = NULL; |
*ccp = NULL; |
enc = &state->newkeys[mode]->enc; |
enc = &state->newkeys[mode]->enc; |
|
|
free(comp->name); |
free(comp->name); |
free(state->newkeys[mode]); |
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 */ |
/* move newkeys from kex to state */ |
if ((state->newkeys[mode] = ssh->kex->newkeys[mode]) == NULL) |
if ((state->newkeys[mode] = ssh->kex->newkeys[mode]) == NULL) |
return SSH_ERR_INTERNAL_ERROR; |
return SSH_ERR_INTERNAL_ERROR; |