version 1.190, 2013/11/21 00:45:44 |
version 1.191, 2013/12/06 13:34:54 |
|
|
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, 0, cp, |
if (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) != 0) |
|
fatal("%s: cipher_crypt failed", __func__); |
|
|
#ifdef PACKET_DEBUG |
#ifdef PACKET_DEBUG |
fprintf(stderr, "encrypted: "); |
fprintf(stderr, "encrypted: "); |
|
|
} |
} |
/* 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, active_state->p_send.seqnr, |
if (cipher_crypt(&active_state->send_context, active_state->p_send.seqnr, |
cp, buffer_ptr(&active_state->outgoing_packet), |
cp, buffer_ptr(&active_state->outgoing_packet), |
len - aadlen, aadlen, authlen); |
len - aadlen, aadlen, authlen) != 0) |
|
fatal("%s: cipher_crypt failed", __func__); |
/* append unencrypted MAC */ |
/* append unencrypted MAC */ |
if (mac && mac->enabled) { |
if (mac && mac->enabled) { |
if (mac->etm) { |
if (mac->etm) { |
|
|
/* 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, 0, cp, |
if (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) != 0) |
|
fatal("%s: cipher_crypt failed", __func__); |
|
|
buffer_consume(&active_state->input, padded_len); |
buffer_consume(&active_state->input, padded_len); |
|
|
|
|
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, |
if (cipher_crypt(&active_state->receive_context, |
active_state->p_read.seqnr, cp, |
active_state->p_read.seqnr, cp, |
buffer_ptr(&active_state->input), block_size, 0, 0); |
buffer_ptr(&active_state->input), block_size, 0, 0) != 0) |
|
fatal("Decryption integrity check failed"); |
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); |
if (active_state->packlen < 1 + 4 || |
if (active_state->packlen < 1 + 4 || |
|
|
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, |
if (cipher_crypt(&active_state->receive_context, |
active_state->p_read.seqnr, cp, |
active_state->p_read.seqnr, cp, |
buffer_ptr(&active_state->input), need, aadlen, authlen); |
buffer_ptr(&active_state->input), need, aadlen, authlen) != 0) |
|
fatal("Decryption integrity check failed"); |
buffer_consume(&active_state->input, aadlen + need + authlen); |
buffer_consume(&active_state->input, aadlen + need + authlen); |
/* |
/* |
* compute MAC over seqnr and packet, |
* compute MAC over seqnr and packet, |