version 1.28, 2000/04/14 10:09:15 |
version 1.29, 2000/04/14 10:30:32 |
|
|
/* |
/* |
* |
* |
* packet.c |
* packet.c |
* |
* |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
* |
* |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
* All rights reserved |
* All rights reserved |
* |
* |
* Created: Sat Mar 18 02:40:40 1995 ylo |
* Created: Sat Mar 18 02:40:40 1995 ylo |
* |
* |
* This file contains code implementing the packet protocol and communication |
* This file contains code implementing the packet protocol and communication |
* with the other side. This same code is used both on client and server side. |
* with the other side. This same code is used both on client and server side. |
* |
* |
|
|
unsigned int packet_length = 0; |
unsigned int packet_length = 0; |
unsigned int i, padlen, len; |
unsigned int i, padlen, len; |
u_int32_t rand = 0; |
u_int32_t rand = 0; |
static unsigned int seqnr = 0; |
static unsigned int seqnr = 0; |
int type; |
int type; |
Enc *enc = NULL; |
Enc *enc = NULL; |
Mac *mac = NULL; |
Mac *mac = NULL; |
|
|
fprintf(stderr, "encrypted: "); |
fprintf(stderr, "encrypted: "); |
buffer_dump(&output); |
buffer_dump(&output); |
#endif |
#endif |
/* increment sequence number for outgoing packets */ |
/* increment sequence number for outgoing packets */ |
if (++seqnr == 0) |
if (++seqnr == 0) |
log("outgoing seqnr wraps around"); |
log("outgoing seqnr wraps around"); |
buffer_clear(&outgoing_packet); |
buffer_clear(&outgoing_packet); |
|
|
if (type == SSH2_MSG_NEWKEYS) { |
if (type == SSH2_MSG_NEWKEYS) { |
|
|
* compute MAC over seqnr and packet, |
* compute MAC over seqnr and packet, |
* increment sequence number for incoming packet |
* increment sequence number for incoming packet |
*/ |
*/ |
if (mac && mac->enabled) { |
if (mac && mac->enabled) { |
macbuf = hmac( mac->md, seqnr, |
macbuf = hmac( mac->md, seqnr, |
(unsigned char *) buffer_ptr(&incoming_packet), |
(unsigned char *) buffer_ptr(&incoming_packet), |
buffer_len(&incoming_packet), |
buffer_len(&incoming_packet), |
|
|
DBG(debug("HMAC #%d ok", seqnr)); |
DBG(debug("HMAC #%d ok", seqnr)); |
buffer_consume(&input, mac->mac_len); |
buffer_consume(&input, mac->mac_len); |
} |
} |
if (++seqnr == 0) |
if (++seqnr == 0) |
log("incoming seqnr wraps around"); |
log("incoming seqnr wraps around"); |
|
|
/* get padlen */ |
/* get padlen */ |
cp = buffer_ptr(&incoming_packet) + 4; |
cp = buffer_ptr(&incoming_packet) + 4; |