| 1 |
/* |
/* |
| 2 |
Copyright (c) 1998-2001, Robert O'Callahan |
* Copyright (c) 1998-2001, Robert O'Callahan |
| 3 |
All rights reserved. |
* (C) 2004-2017 TeraTerm Project |
| 4 |
|
* All rights reserved. |
| 5 |
Redistribution and use in source and binary forms, with or without modification, |
* |
| 6 |
are permitted provided that the following conditions are met: |
* Redistribution and use in source and binary forms, with or without |
| 7 |
|
* modification, are permitted provided that the following conditions |
| 8 |
Redistributions of source code must retain the above copyright notice, this list of |
* are met: |
| 9 |
conditions and the following disclaimer. |
* |
| 10 |
|
* 1. Redistributions of source code must retain the above copyright |
| 11 |
Redistributions in binary form must reproduce the above copyright notice, this list |
* notice, this list of conditions and the following disclaimer. |
| 12 |
of conditions and the following disclaimer in the documentation and/or other materials |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
provided with the distribution. |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
|
* documentation and/or other materials provided with the distribution. |
| 15 |
The name of Robert O'Callahan may not be used to endorse or promote products derived from |
* 3. The name of the author may not be used to endorse or promote products |
| 16 |
this software without specific prior written permission. |
* derived from this software without specific prior written permission. |
| 17 |
|
* |
| 18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| 19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 |
THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 |
*/ |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
|
*/ |
| 29 |
|
|
| 30 |
/* |
/* |
| 31 |
This code is copyright (C) 1998-1999 Robert O'Callahan. |
This code is copyright (C) 1998-1999 Robert O'Callahan. |
| 145 |
-- reads data from the sshd and feeds the SSH protocol packets to ssh.c |
-- reads data from the sshd and feeds the SSH protocol packets to ssh.c |
| 146 |
-- copies any available decrypted session data into the application buffer |
-- copies any available decrypted session data into the application buffer |
| 147 |
*/ |
*/ |
| 148 |
int PKT_recv(PTInstVar pvar, char FAR * buf, int buflen) |
int PKT_recv(PTInstVar pvar, char *buf, int buflen) |
| 149 |
{ |
{ |
| 150 |
int amount_in_buf = 0; |
int amount_in_buf = 0; |
| 151 |
BOOL connection_closed = FALSE; |
BOOL connection_closed = FALSE; |
| 198 |
} else if (pvar->pkt_state.seen_server_ID |
} else if (pvar->pkt_state.seen_server_ID |
| 199 |
&& pvar->pkt_state.datalen >= |
&& pvar->pkt_state.datalen >= |
| 200 |
(unsigned int) SSH_get_min_packet_size(pvar)) { |
(unsigned int) SSH_get_min_packet_size(pvar)) { |
| 201 |
char FAR *data = |
char *data = |
| 202 |
pvar->pkt_state.buf + pvar->pkt_state.datastart; |
pvar->pkt_state.buf + pvar->pkt_state.datastart; |
| 203 |
uint32 padding; |
uint32 padding; |
| 204 |
uint32 pktsize; |
uint32 pktsize; |
| 206 |
|
|
| 207 |
//debug_print(10, data, pvar->pkt_state.datalen); |
//debug_print(10, data, pvar->pkt_state.datalen); |
| 208 |
|
|
| 209 |
// SSH2なら暗号化パケットの一部を復号化する。 |
// 暗号化パケットの一部を復号化する。 |
| 210 |
if (!pvar->pkt_state.predecrypted_packet) { |
if (!pvar->pkt_state.predecrypted_packet) { |
|
//DEBUG_PRINT_TO_FILE(0, data, pvar->pkt_state.datalen); |
|
| 211 |
SSH_predecrpyt_packet(pvar, data); |
SSH_predecrpyt_packet(pvar, data); |
| 212 |
|
pvar->pkt_state.predecrypted_packet = TRUE; |
|
if (SSHv1(pvar)) { |
|
|
pvar->pkt_state.predecrypted_packet = TRUE; |
|
|
} else { // for SSH2(yutaka) |
|
|
// do nothing |
|
|
pvar->pkt_state.predecrypted_packet = TRUE; |
|
|
} |
|
| 213 |
} |
} |
| 214 |
|
|
| 215 |
if (SSHv1(pvar)) { |
if (SSHv1(pvar)) { |