diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -1,14 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * packet.c | 3 | * packet.c |
4 | * | 4 | * |
5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
6 | * | 6 | * |
7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
8 | * All rights reserved | 8 | * All rights reserved |
9 | * | 9 | * |
10 | * Created: Sat Mar 18 02:40:40 1995 ylo | 10 | * Created: Sat Mar 18 02:40:40 1995 ylo |
11 | * | 11 | * |
12 | * This file contains code implementing the packet protocol and communication | 12 | * This file contains code implementing the packet protocol and communication |
13 | * with the other side. This same code is used both on client and server side. | 13 | * with the other side. This same code is used both on client and server side. |
14 | * | 14 | * |
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "includes.h" | 19 | #include "includes.h" |
20 | RCSID("$Id: packet.c,v 1.17 2000/04/13 02:26:37 damien Exp $"); | 20 | RCSID("$Id: packet.c,v 1.18 2000/04/16 01:18:43 damien Exp $"); |
21 | 21 | ||
22 | #ifdef HAVE_OPENSSL | 22 | #ifdef HAVE_OPENSSL |
23 | # include <openssl/bn.h> | 23 | # include <openssl/bn.h> |
@@ -529,7 +529,7 @@ packet_send2() | |||
529 | unsigned int packet_length = 0; | 529 | unsigned int packet_length = 0; |
530 | unsigned int i, padlen, len; | 530 | unsigned int i, padlen, len; |
531 | u_int32_t rand = 0; | 531 | u_int32_t rand = 0; |
532 | static unsigned int seqnr = 0; | 532 | static unsigned int seqnr = 0; |
533 | int type; | 533 | int type; |
534 | Enc *enc = NULL; | 534 | Enc *enc = NULL; |
535 | Mac *mac = NULL; | 535 | Mac *mac = NULL; |
@@ -611,9 +611,9 @@ packet_send2() | |||
611 | fprintf(stderr, "encrypted: "); | 611 | fprintf(stderr, "encrypted: "); |
612 | buffer_dump(&output); | 612 | buffer_dump(&output); |
613 | #endif | 613 | #endif |
614 | /* increment sequence number for outgoing packets */ | 614 | /* increment sequence number for outgoing packets */ |
615 | if (++seqnr == 0) | 615 | if (++seqnr == 0) |
616 | log("outgoing seqnr wraps around"); | 616 | log("outgoing seqnr wraps around"); |
617 | buffer_clear(&outgoing_packet); | 617 | buffer_clear(&outgoing_packet); |
618 | 618 | ||
619 | if (type == SSH2_MSG_NEWKEYS) { | 619 | if (type == SSH2_MSG_NEWKEYS) { |
@@ -877,7 +877,7 @@ packet_read_poll2(int *payload_len_ptr) | |||
877 | * compute MAC over seqnr and packet, | 877 | * compute MAC over seqnr and packet, |
878 | * increment sequence number for incoming packet | 878 | * increment sequence number for incoming packet |
879 | */ | 879 | */ |
880 | if (mac && mac->enabled) { | 880 | if (mac && mac->enabled) { |
881 | macbuf = hmac( mac->md, seqnr, | 881 | macbuf = hmac( mac->md, seqnr, |
882 | (unsigned char *) buffer_ptr(&incoming_packet), | 882 | (unsigned char *) buffer_ptr(&incoming_packet), |
883 | buffer_len(&incoming_packet), | 883 | buffer_len(&incoming_packet), |
@@ -888,8 +888,8 @@ packet_read_poll2(int *payload_len_ptr) | |||
888 | DBG(debug("HMAC #%d ok", seqnr)); | 888 | DBG(debug("HMAC #%d ok", seqnr)); |
889 | buffer_consume(&input, mac->mac_len); | 889 | buffer_consume(&input, mac->mac_len); |
890 | } | 890 | } |
891 | if (++seqnr == 0) | 891 | if (++seqnr == 0) |
892 | log("incoming seqnr wraps around"); | 892 | log("incoming seqnr wraps around"); |
893 | 893 | ||
894 | /* get padlen */ | 894 | /* get padlen */ |
895 | cp = buffer_ptr(&incoming_packet) + 4; | 895 | cp = buffer_ptr(&incoming_packet) + 4; |
@@ -1063,6 +1063,12 @@ packet_get_raw(int *length_ptr) | |||
1063 | return buffer_ptr(&incoming_packet); | 1063 | return buffer_ptr(&incoming_packet); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | int | ||
1067 | packet_remaining(void) | ||
1068 | { | ||
1069 | return buffer_len(&incoming_packet); | ||
1070 | } | ||
1071 | |||
1066 | /* | 1072 | /* |
1067 | * Returns a string from the packet data. The string is allocated using | 1073 | * Returns a string from the packet data. The string is allocated using |
1068 | * xmalloc; it is the responsibility of the calling program to free it when | 1074 | * xmalloc; it is the responsibility of the calling program to free it when |