Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/ttxssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6841 - (show annotations) (download) (as text)
Tue Jul 4 15:02:28 2017 UTC (6 years, 9 months ago) by doda
Original Path: trunk/ttssh2/ttxssh/ttxssh.h
File MIME type: text/x-chdr
File size: 10381 byte(s)
TeraTerm Project としてのライセンス表記を追加

・Tera Term 本体分を横 80 桁に収まるように改行位置を調整
・ttssh 関連の分を追加
1 /*
2 * Copyright (c) 1998-2001, Robert O'Callahan
3 * (C) 2004-2017 TeraTerm Project
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (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.
32 See LICENSE.TXT for the license.
33 */
34
35 #ifndef __TTXSSH_H
36 #define __TTXSSH_H
37
38 #pragma warning(3 : 4035)
39
40 /* VS2015(VC14.0)�����AWSASocketA(), inet_ntoa() ������API��deprecated��������
41 * �x�������������A�x�����}�~�����B�����������u���������AVS2005(VC8.0)���r���h
42 * �����������������A�x�����}�~���������������B
43 */
44 #if _MSC_VER >= 1800 // VSC2013(VC12.0) or later
45 #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
46 #define _WINSOCK_DEPRECATED_NO_WARNINGS
47 #endif
48 #endif
49
50 #include <winsock2.h>
51 #include <ws2tcpip.h>
52 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
53 #undef IN6_IS_ADDR_LOOPBACK
54 #define IN6_IS_ADDR_LOOPBACK(a) \
55 ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) && \
56 (*(unsigned int *)(&(a)->s6_addr[4]) == 0) && \
57 (*(unsigned int *)(&(a)->s6_addr[8]) == 0) && \
58 (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
59 /* work around for MS Platform SDK Oct 2000 */
60 #include <malloc.h> /* prevent of conflict stdlib.h */
61 #include <stdlib.h>
62 #include <stdarg.h>
63 #include <crtdbg.h>
64
65 #include "i18n.h"
66 #include "ttlib.h"
67
68 typedef struct _TInstVar *PTInstVar;
69
70 #include "ttxssh-version.h"
71 #include "util.h"
72 #include "pkt.h"
73 #include "ssh.h"
74 #include "auth.h"
75 #include "crypt.h"
76 #include "hosts.h"
77 #include "fwd.h"
78
79 #include <openssl/dh.h>
80 #include <openssl/ec.h>
81 #include <openssl/evp.h>
82 #include "buffer.h"
83
84 /* tttypes.h �����`���������� EM �}�N���� openssl/rsa.h (OpenSSL 0.9.8)�������v���g�^�C�v������
85 * �������������d�����������������A�r���h�G���[�������B���L3�w�b�_��include���u�����L�����������B
86 * (2005.7.9 yutaka)
87 */
88 #include "teraterm.h"
89 #include "tttypes.h"
90 #include "ttplugin.h"
91
92 HANDLE hInst; /* Instance handle of TTXSSH.DLL */
93
94 #define ID_SSHSCPMENU 52110
95 #define ID_SSHSETUPMENU 52310
96 #define ID_SSHAUTHSETUPMENU 52320
97 #define ID_SSHFWDSETUPMENU 52330
98 #define ID_SSHKEYGENMENU 52340
99 #define ID_ABOUTMENU 52910
100
101 #define ID_SSHAUTH 62501
102 #define ID_SSHUNKNOWNHOST 62502
103 #define ID_SSHDIFFERENTKEY 62503
104 #define ID_SSHASYNCMESSAGEBOX 62504
105
106 #define OPTION_NONE 0
107 #define OPTION_CLEAR 1
108 #define OPTION_REPLACE 2
109
110 /*
111 * DisablePopupMessage �p���r�b�g���`
112 */
113 #define POPUP_MSG_default 0
114 #define POPUP_MSG_FWD_received_data (1 << 0)
115
116
117 /*
118 * Host key rotation
119 */
120 #define SSH_UPDATE_HOSTKEYS_NO 0
121 #define SSH_UPDATE_HOSTKEYS_YES 1
122 #define SSH_UPDATE_HOSTKEYS_ASK 2
123 #define SSH_UPDATE_HOSTKEYS_MAX 3
124
125 /*
126 * Server compatibility flag
127 */
128 #define SSH_BUG_DHGEX_LARGE 0x00000001
129
130
131 /*
132 These are the fields that WOULD go in Tera Term's 'ts' structure, if
133 we could put them there.
134 */
135 typedef struct _TS_SSH {
136 BOOL Enabled;
137 int CompressionLevel; /* 0 = NONE, else 1-9 */
138 char DefaultUserName[256];
139
140 /* this next option is a string of digits. Each digit represents a
141 cipher. The first digit is the most preferred cipher, and so on.
142 The digit SSH_CIPHER_NONE signifies that any ciphers after it are
143 disabled. */
144 char CipherOrder[SSH_CIPHER_MAX+1];
145
146 char KnownHostsFiles[2048];
147 int DefaultAuthMethod;
148 char DefaultRhostsLocalUserName[256];
149 char DefaultRhostsHostPrivateKeyFile[1024];
150 char DefaultRSAPrivateKeyFile[1024];
151
152 char DefaultForwarding[4096];
153 BOOL TryDefaultAuth;
154
155 int LogLevel; /* 0 = NONE, 100 = Verbose */
156 int WriteBufferSize;
157
158 int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
159 int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
160 // whether password will permanently store on heap memory (2006.8.5 yutaka)
161 int remember_password;
162
163 // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)
164 BOOL CheckAuthListFirst;
165
166 // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)
167 BOOL EnableRsaShortKeyServer;
168
169 // Enable Agent forwarding
170 BOOL ForwardAgent;
171
172 // Confirm Agent forwarding
173 BOOL ForwardAgentConfirm;
174
175 // Confirm Agent forwarding
176 BOOL ForwardAgentNotify;
177
178 // KEX order(derived from teraterm.ini)
179 char KexOrder[KEX_DH_MAX+1];
180 char HostKeyOrder[KEY_MAX+1];
181 char MacOrder[HMAC_MAX+1];
182 char CompOrder[COMP_MAX+1];
183
184 BOOL VerifyHostKeyDNS;
185
186 int IconID;
187
188 int DisablePopupMessage;
189
190 char X11Display[128];
191
192 int UpdateHostkeys;
193
194 int GexMinimalGroupSize;
195 } TS_SSH;
196
197 typedef struct _TInstVar {
198 PTTSet ts;
199 PComVar cv;
200
201 /* shared memory for settings across instances. Basically it's
202 a cache for the INI file.*/
203 TS_SSH *ts_SSH;
204
205 int fatal_error;
206 int showing_err;
207 char *err_msg;
208
209 Tconnect Pconnect;
210 Trecv Precv;
211 Tsend Psend;
212 TWSAAsyncSelect PWSAAsyncSelect;
213 TWSAGetLastError PWSAGetLastError;
214
215 PReadIniFile ReadIniFile;
216 PWriteIniFile WriteIniFile;
217 PParseParam ParseParam;
218
219 HMENU FileMenu;
220
221 SOCKET socket;
222 HWND NotificationWindow;
223 unsigned int notification_msg;
224 long notification_events;
225 HICON OldSmallIcon;
226 HICON OldLargeIcon;
227
228 BOOL hostdlg_activated;
229 BOOL hostdlg_Enabled;
230
231 int protocol_major;
232 int protocol_minor;
233
234 PKTState pkt_state;
235 SSHState ssh_state;
236 AUTHState auth_state;
237 CRYPTState crypt_state;
238 HOSTSState hosts_state;
239 FWDState fwd_state;
240
241 /* The settings applied to the current session. The user may change
242 the settings but usually we don't want that to affect the session
243 in progress (race conditions). So user setup changes usually
244 modify the 'settings' field below. */
245 TS_SSH session_settings;
246
247 /* our copy of the global settings. This is synced up with the shared
248 memory only when we do a ReadIniFile or WriteIniFile
249 (i.e. the user loads or saves setup) */
250 TS_SSH settings;
251
252 // SSH2
253 DH *kexdh;
254 char server_version_string[128];
255 char client_version_string[128];
256 buffer_t *my_kex;
257 buffer_t *peer_kex;
258 kex_algorithm kex_type; // KEX algorithm
259 ssh_keytype hostkey_type;
260 SSHCipher ctos_cipher;
261 SSHCipher stoc_cipher;
262 hmac_type ctos_hmac;
263 hmac_type stoc_hmac;
264 compression_type ctos_compression;
265 compression_type stoc_compression;
266 int we_need;
267 int key_done;
268 int rekeying;
269 char *session_id;
270 int session_id_len;
271 Newkeys ssh2_keys[MODE_MAX];
272 EVP_CIPHER_CTX evpcip[MODE_MAX];
273 int userauth_success;
274 int shell_id;
275 /*int remote_id;*/
276 int session_nego_status;
277 /*
278 unsigned int local_window;
279 unsigned int local_window_max;
280 unsigned int local_consumed;
281 unsigned int local_maxpacket;
282 unsigned int remote_window;
283 unsigned int remote_maxpacket;
284 */
285 int client_key_bits;
286 int server_key_bits;
287 int kexgex_min;
288 int kexgex_bits;
289 int kexgex_max;
290 int ssh2_autologin;
291 int ask4passwd;
292 SSHAuthMethod ssh2_authmethod;
293 char ssh2_username[MAX_PATH];
294 char ssh2_password[MAX_PATH];
295 char ssh2_keyfile[MAX_PATH];
296 time_t ssh_heartbeat_tick;
297 HANDLE ssh_heartbeat_thread;
298 int keyboard_interactive_password_input;
299 int userauth_retry_count;
300 buffer_t *decomp_buffer;
301 char *ssh2_authlist;
302 BOOL tryed_ssh2_authlist;
303 HWND ssh_hearbeat_dialog;
304
305 /* Pageant �������M�p */
306 unsigned char *pageant_key;
307 unsigned char *pageant_curkey;
308 int pageant_keylistlen;
309 int pageant_keycount;
310 int pageant_keycurrent;
311 BOOL pageant_keyfinal;// SSH2 PK_OK ������������ TRUE ������
312
313 // agent forward
314 BOOL agentfwd_enable;
315
316 BOOL origDisableTCPEchoCR;
317
318 BOOL nocheck_known_hosts;
319
320 EC_KEY *ecdh_client_key;
321
322 int dns_key_check;
323
324 unsigned int server_compat_flag;
325
326 void *hostkey_ctx;
327
328 BOOL use_subsystem;
329 char subsystem_name[256];
330 } TInstVar;
331
332 // �o�[�W���������������������X�������B ��: TTSSH_2-81_TS_data
333 #define TTSSH_FILEMAPNAME "TTSSH_" TTSSH_VERSION_STR("-") "_TS_data"
334
335 #define LOG_LEVEL_FATAL 5
336 #define LOG_LEVEL_ERROR 10
337 #define LOG_LEVEL_WARNING 30
338 #define LOG_LEVEL_NOTICE 50
339 #define LOG_LEVEL_INFO 80
340 #define LOG_LEVEL_VERBOSE 100
341 #define LOG_LEVEL_SSHDUMP 200
342
343 #define SSHv1(pvar) ((pvar)->protocol_major == 1)
344 #define SSHv2(pvar) ((pvar)->protocol_major == 2)
345
346 #define LogLevel(pvar, level) ((pvar)->settings.LogLevel >= (level))
347
348 void notify_established_secure_connection(PTInstVar pvar);
349 void notify_closed_connection(PTInstVar pvar, char *send_msg);
350 void notify_nonfatal_error(PTInstVar pvar, char *msg);
351 void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect);
352 void logputs(int level, char *msg);
353 void logprintf(int level, char *fmt, ...);
354 void logprintf_hexdump(int level, char *data, int len, char *fmt, ...);
355
356 void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename);
357 int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename);
358 int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);
359
360 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26