version 1.189, 2013/11/08 00:39:15 |
version 1.190, 2013/11/21 00:45:44 |
|
|
buffer_append(&active_state->output, buf, 4); |
buffer_append(&active_state->output, buf, 4); |
cp = buffer_append_space(&active_state->output, |
cp = buffer_append_space(&active_state->output, |
buffer_len(&active_state->outgoing_packet)); |
buffer_len(&active_state->outgoing_packet)); |
cipher_crypt(&active_state->send_context, cp, |
cipher_crypt(&active_state->send_context, 0, cp, |
buffer_ptr(&active_state->outgoing_packet), |
buffer_ptr(&active_state->outgoing_packet), |
buffer_len(&active_state->outgoing_packet), 0, 0); |
buffer_len(&active_state->outgoing_packet), 0, 0); |
|
|
|
|
} |
} |
/* encrypt packet and append to output buffer. */ |
/* encrypt packet and append to output buffer. */ |
cp = buffer_append_space(&active_state->output, len + authlen); |
cp = buffer_append_space(&active_state->output, len + authlen); |
cipher_crypt(&active_state->send_context, cp, |
cipher_crypt(&active_state->send_context, active_state->p_send.seqnr, |
buffer_ptr(&active_state->outgoing_packet), |
cp, buffer_ptr(&active_state->outgoing_packet), |
len - aadlen, aadlen, authlen); |
len - aadlen, aadlen, authlen); |
/* append unencrypted MAC */ |
/* append unencrypted MAC */ |
if (mac && mac->enabled) { |
if (mac && mac->enabled) { |
|
|
/* Decrypt data to incoming_packet. */ |
/* Decrypt data to incoming_packet. */ |
buffer_clear(&active_state->incoming_packet); |
buffer_clear(&active_state->incoming_packet); |
cp = buffer_append_space(&active_state->incoming_packet, padded_len); |
cp = buffer_append_space(&active_state->incoming_packet, padded_len); |
cipher_crypt(&active_state->receive_context, cp, |
cipher_crypt(&active_state->receive_context, 0, cp, |
buffer_ptr(&active_state->input), padded_len, 0, 0); |
buffer_ptr(&active_state->input), padded_len, 0, 0); |
|
|
buffer_consume(&active_state->input, padded_len); |
buffer_consume(&active_state->input, padded_len); |
|
|
aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0; |
aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0; |
|
|
if (aadlen && active_state->packlen == 0) { |
if (aadlen && active_state->packlen == 0) { |
if (buffer_len(&active_state->input) < 4) |
if (cipher_get_length(&active_state->receive_context, |
|
&active_state->packlen, |
|
active_state->p_read.seqnr, |
|
buffer_ptr(&active_state->input), |
|
buffer_len(&active_state->input)) != 0) |
return SSH_MSG_NONE; |
return SSH_MSG_NONE; |
cp = buffer_ptr(&active_state->input); |
|
active_state->packlen = get_u32(cp); |
|
if (active_state->packlen < 1 + 4 || |
if (active_state->packlen < 1 + 4 || |
active_state->packlen > PACKET_MAX_SIZE) { |
active_state->packlen > PACKET_MAX_SIZE) { |
#ifdef PACKET_DEBUG |
#ifdef PACKET_DEBUG |
|
|
buffer_clear(&active_state->incoming_packet); |
buffer_clear(&active_state->incoming_packet); |
cp = buffer_append_space(&active_state->incoming_packet, |
cp = buffer_append_space(&active_state->incoming_packet, |
block_size); |
block_size); |
cipher_crypt(&active_state->receive_context, cp, |
cipher_crypt(&active_state->receive_context, |
|
active_state->p_read.seqnr, cp, |
buffer_ptr(&active_state->input), block_size, 0, 0); |
buffer_ptr(&active_state->input), block_size, 0, 0); |
cp = buffer_ptr(&active_state->incoming_packet); |
cp = buffer_ptr(&active_state->incoming_packet); |
active_state->packlen = get_u32(cp); |
active_state->packlen = get_u32(cp); |
|
|
macbuf = mac_compute(mac, active_state->p_read.seqnr, |
macbuf = mac_compute(mac, active_state->p_read.seqnr, |
buffer_ptr(&active_state->input), aadlen + need); |
buffer_ptr(&active_state->input), aadlen + need); |
cp = buffer_append_space(&active_state->incoming_packet, aadlen + need); |
cp = buffer_append_space(&active_state->incoming_packet, aadlen + need); |
cipher_crypt(&active_state->receive_context, cp, |
cipher_crypt(&active_state->receive_context, |
|
active_state->p_read.seqnr, cp, |
buffer_ptr(&active_state->input), need, aadlen, authlen); |
buffer_ptr(&active_state->input), need, aadlen, authlen); |
buffer_consume(&active_state->input, aadlen + need + authlen); |
buffer_consume(&active_state->input, aadlen + need + authlen); |
/* |
/* |