version 1.130, 2006/03/25 18:56:55 |
version 1.131, 2006/03/30 09:58:16 |
|
|
#include "packet.h" |
#include "packet.h" |
#include "bufaux.h" |
#include "bufaux.h" |
#include "crc32.h" |
#include "crc32.h" |
#include "getput.h" |
|
|
|
#include "compress.h" |
#include "compress.h" |
#include "deattack.h" |
#include "deattack.h" |
|
|
/* Add check bytes. */ |
/* Add check bytes. */ |
checksum = ssh_crc32(buffer_ptr(&outgoing_packet), |
checksum = ssh_crc32(buffer_ptr(&outgoing_packet), |
buffer_len(&outgoing_packet)); |
buffer_len(&outgoing_packet)); |
PUT_32BIT(buf, checksum); |
put_u32(buf, checksum); |
buffer_append(&outgoing_packet, buf, 4); |
buffer_append(&outgoing_packet, buf, 4); |
|
|
#ifdef PACKET_DEBUG |
#ifdef PACKET_DEBUG |
|
|
#endif |
#endif |
|
|
/* Append to output. */ |
/* Append to output. */ |
PUT_32BIT(buf, len); |
put_u32(buf, len); |
buffer_append(&output, buf, 4); |
buffer_append(&output, buf, 4); |
cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); |
cp = buffer_append_space(&output, buffer_len(&outgoing_packet)); |
cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), |
cipher_crypt(&send_context, cp, buffer_ptr(&outgoing_packet), |
|
|
/* packet_length includes payload, padding and padding length field */ |
/* packet_length includes payload, padding and padding length field */ |
packet_length = buffer_len(&outgoing_packet) - 4; |
packet_length = buffer_len(&outgoing_packet) - 4; |
cp = buffer_ptr(&outgoing_packet); |
cp = buffer_ptr(&outgoing_packet); |
PUT_32BIT(cp, packet_length); |
put_u32(cp, packet_length); |
cp[4] = padlen; |
cp[4] = padlen; |
DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); |
DBG(debug("send: len %d (includes padlen %d)", packet_length+4, padlen)); |
|
|
|
|
return SSH_MSG_NONE; |
return SSH_MSG_NONE; |
/* Get length of incoming packet. */ |
/* Get length of incoming packet. */ |
cp = buffer_ptr(&input); |
cp = buffer_ptr(&input); |
len = GET_32BIT(cp); |
len = get_u32(cp); |
if (len < 1 + 2 + 2 || len > 256 * 1024) |
if (len < 1 + 2 + 2 || len > 256 * 1024) |
packet_disconnect("Bad packet length %u.", len); |
packet_disconnect("Bad packet length %u.", len); |
padded_len = (len + 8) & ~7; |
padded_len = (len + 8) & ~7; |
|
|
len, buffer_len(&incoming_packet)); |
len, buffer_len(&incoming_packet)); |
|
|
cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; |
cp = (u_char *)buffer_ptr(&incoming_packet) + len - 4; |
stored_checksum = GET_32BIT(cp); |
stored_checksum = get_u32(cp); |
if (checksum != stored_checksum) |
if (checksum != stored_checksum) |
packet_disconnect("Corrupted check bytes on input."); |
packet_disconnect("Corrupted check bytes on input."); |
buffer_consume_end(&incoming_packet, 4); |
buffer_consume_end(&incoming_packet, 4); |
|
|
cipher_crypt(&receive_context, cp, buffer_ptr(&input), |
cipher_crypt(&receive_context, cp, buffer_ptr(&input), |
block_size); |
block_size); |
cp = buffer_ptr(&incoming_packet); |
cp = buffer_ptr(&incoming_packet); |
packet_length = GET_32BIT(cp); |
packet_length = get_u32(cp); |
if (packet_length < 1 + 4 || packet_length > 256 * 1024) { |
if (packet_length < 1 + 4 || packet_length > 256 * 1024) { |
#ifdef PACKET_DEBUG |
#ifdef PACKET_DEBUG |
buffer_dump(&incoming_packet); |
buffer_dump(&incoming_packet); |