Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/ttssh2/ttxssh/ttxssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7632 - (show annotations) (download) (as text)
Fri Apr 26 17:18:36 2019 UTC (4 years, 11 months ago) by zmatsuo
File MIME type: text/x-chdr
File size: 10521 byte(s)
Merge branch 'ssh_auth_dialog' into trunk
1 /*
2 * Copyright (c) 1998-2001, Robert O'Callahan
3 * (C) 2004-2019 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 #include <wspiapi.h>
53 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
54 #undef IN6_IS_ADDR_LOOPBACK
55 #define IN6_IS_ADDR_LOOPBACK(a) \
56 ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) && \
57 (*(unsigned int *)(&(a)->s6_addr[4]) == 0) && \
58 (*(unsigned int *)(&(a)->s6_addr[8]) == 0) && \
59 (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
60 /* work around for MS Platform SDK Oct 2000 */
61 #include <malloc.h> /* prevent of conflict stdlib.h */
62 #include <stdlib.h>
63 #include <stdarg.h>
64 #include <crtdbg.h>
65
66 #include "i18n.h"
67 #include "ttlib.h"
68
69 typedef struct _TInstVar *PTInstVar;
70
71 #include "ttxssh-version.h"
72 #include "util.h"
73 #include "pkt.h"
74 #include "ssh.h"
75 #include "auth.h"
76 #include "crypt.h"
77 #include "hosts.h"
78 #include "fwd.h"
79
80 #include <openssl/dh.h>
81 #include <openssl/ec.h>
82 #include <openssl/evp.h>
83 #include "buffer.h"
84
85 /* tttypes.h �����`���������� EM �}�N���� openssl/rsa.h (OpenSSL 0.9.8)�������v���g�^�C�v������
86 * �������������d�����������������A�r���h�G���[�������B���L3�w�b�_��include���u�����L�����������B
87 * (2005.7.9 yutaka)
88 */
89 #include "teraterm.h"
90 #include "tttypes.h"
91 #include "ttplugin.h"
92
93 HANDLE hInst; /* Instance handle of TTXSSH.DLL */
94
95 #define ID_SSHSCPMENU 52110
96 #define ID_SSHSETUPMENU 52310
97 #define ID_SSHAUTHSETUPMENU 52320
98 #define ID_SSHFWDSETUPMENU 52330
99 #define ID_SSHKEYGENMENU 52340
100 #define ID_ABOUTMENU 52910
101
102 #define ID_SSHAUTH 62501
103 #define ID_SSHUNKNOWNHOST 62502
104 #define ID_SSHDIFFERENTKEY 62503
105 #define ID_SSHASYNCMESSAGEBOX 62504
106
107 #define OPTION_NONE 0
108 #define OPTION_CLEAR 1
109 #define OPTION_REPLACE 2
110
111 /*
112 * DisablePopupMessage �p���r�b�g���`
113 */
114 #define POPUP_MSG_default 0
115 #define POPUP_MSG_FWD_received_data (1 << 0)
116
117
118 /*
119 * Host key rotation
120 */
121 #define SSH_UPDATE_HOSTKEYS_NO 0
122 #define SSH_UPDATE_HOSTKEYS_YES 1
123 #define SSH_UPDATE_HOSTKEYS_ASK 2
124 #define SSH_UPDATE_HOSTKEYS_MAX 3
125
126 /*
127 * Server compatibility flag
128 */
129 #define SSH_BUG_DHGEX_LARGE 0x00000001
130
131
132 /*
133 These are the fields that WOULD go in Tera Term's 'ts' structure, if
134 we could put them there.
135 */
136 typedef struct _TS_SSH {
137 BOOL Enabled;
138 int CompressionLevel; /* 0 = NONE, else 1-9 */
139
140 int DefaultUserType; /* 0/1/2 = no input/DefaultUserName/Windows logon user */
141 char DefaultUserName[256];
142
143 /* this next option is a string of digits. Each digit represents a
144 cipher. The first digit is the most preferred cipher, and so on.
145 The digit SSH_CIPHER_NONE signifies that any ciphers after it are
146 disabled. */
147 char CipherOrder[SSH_CIPHER_MAX+2];
148
149 char KnownHostsFiles[2048];
150 int DefaultAuthMethod;
151 char DefaultRhostsLocalUserName[256];
152 char DefaultRhostsHostPrivateKeyFile[1024];
153 char DefaultRSAPrivateKeyFile[1024];
154
155 char DefaultForwarding[4096];
156 BOOL TryDefaultAuth;
157
158 int LogLevel; /* 0 = NONE, 100 = Verbose */
159 int WriteBufferSize;
160
161 int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
162 int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
163 // whether password will permanently store on heap memory (2006.8.5 yutaka)
164 int remember_password;
165
166 // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)
167 BOOL CheckAuthListFirst;
168
169 // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)
170 BOOL EnableRsaShortKeyServer;
171
172 // Enable Agent forwarding
173 BOOL ForwardAgent;
174
175 // Confirm Agent forwarding
176 BOOL ForwardAgentConfirm;
177
178 // Confirm Agent forwarding
179 BOOL ForwardAgentNotify;
180
181 // KEX order(derived from teraterm.ini)
182 char KexOrder[KEX_DH_MAX+1];
183 char HostKeyOrder[KEY_MAX+1];
184 char MacOrder[HMAC_MAX+1];
185 char CompOrder[COMP_MAX+1];
186
187 BOOL VerifyHostKeyDNS;
188
189 int IconID;
190
191 int DisablePopupMessage;
192
193 char X11Display[128];
194
195 int UpdateHostkeys;
196
197 int GexMinimalGroupSize;
198
199 int AuthBanner;
200 } TS_SSH;
201
202 typedef struct _TInstVar {
203 PTTSet ts;
204 PComVar cv;
205
206 /* shared memory for settings across instances. Basically it's
207 a cache for the INI file.*/
208 TS_SSH *ts_SSH;
209
210 int fatal_error;
211 int showing_err;
212 char *err_msg;
213
214 Tconnect Pconnect;
215 Trecv Precv;
216 Tsend Psend;
217 TWSAAsyncSelect PWSAAsyncSelect;
218 TWSAGetLastError PWSAGetLastError;
219
220 PReadIniFile ReadIniFile;
221 PWriteIniFile WriteIniFile;
222 PParseParam ParseParam;
223
224 HMENU FileMenu;
225
226 SOCKET socket;
227 HWND NotificationWindow;
228 unsigned int notification_msg;
229 long notification_events;
230 HICON OldSmallIcon;
231 HICON OldLargeIcon;
232
233 BOOL hostdlg_activated;
234 BOOL hostdlg_Enabled;
235
236 int protocol_major;
237 int protocol_minor;
238
239 PKTState pkt_state;
240 SSHState ssh_state;
241 AUTHState auth_state;
242 CRYPTState crypt_state;
243 HOSTSState hosts_state;
244 FWDState fwd_state;
245
246 /* The settings applied to the current session. The user may change
247 the settings but usually we don't want that to affect the session
248 in progress (race conditions). So user setup changes usually
249 modify the 'settings' field below. */
250 TS_SSH session_settings;
251
252 /* our copy of the global settings. This is synced up with the shared
253 memory only when we do a ReadIniFile or WriteIniFile
254 (i.e. the user loads or saves setup) */
255 TS_SSH settings;
256
257 // SSH2
258 DH *kexdh;
259 char server_version_string[128];
260 char client_version_string[128];
261 buffer_t *my_kex;
262 buffer_t *peer_kex;
263 kex_algorithm kex_type; // KEX algorithm
264 ssh_keytype hostkey_type;
265 SSH2Cipher *ciphers[MODE_MAX];
266 SSH2Mac *macs[MODE_MAX];
267 compression_type ctos_compression;
268 compression_type stoc_compression;
269 int we_need;
270 int key_done;
271 int rekeying;
272 char *session_id;
273 int session_id_len;
274 SSHKeys ssh2_keys[MODE_MAX];
275 EVP_CIPHER_CTX evpcip[MODE_MAX];
276 int userauth_success;
277 int shell_id;
278 /*int remote_id;*/
279 int session_nego_status;
280 /*
281 unsigned int local_window;
282 unsigned int local_window_max;
283 unsigned int local_consumed;
284 unsigned int local_maxpacket;
285 unsigned int remote_window;
286 unsigned int remote_maxpacket;
287 */
288 int client_key_bits;
289 int server_key_bits;
290 int kexgex_min;
291 int kexgex_bits;
292 int kexgex_max;
293 int ssh2_autologin;
294 int ask4passwd;
295 SSHAuthMethod ssh2_authmethod;
296 char ssh2_username[MAX_PATH];
297 char ssh2_password[MAX_PATH];
298 char ssh2_keyfile[MAX_PATH];
299 time_t ssh_heartbeat_tick;
300 HANDLE ssh_heartbeat_thread;
301 int keyboard_interactive_password_input;
302 int userauth_retry_count;
303 buffer_t *decomp_buffer;
304 buffer_t *authbanner_buffer;
305 char *ssh2_authlist;
306 BOOL tryed_ssh2_authlist;
307 HWND ssh_hearbeat_dialog;
308
309 /* Pageant �������M�p */
310 unsigned char *pageant_key;
311 unsigned char *pageant_curkey;
312 int pageant_keylistlen;
313 int pageant_keycount;
314 int pageant_keycurrent;
315 BOOL pageant_keyfinal;// SSH2 PK_OK ������������ TRUE ������
316
317 // agent forward
318 BOOL agentfwd_enable;
319
320 BOOL origDisableTCPEchoCR;
321
322 BOOL nocheck_known_hosts;
323
324 EC_KEY *ecdh_client_key;
325
326 int dns_key_check;
327
328 unsigned int server_compat_flag;
329
330 void *hostkey_ctx;
331
332 BOOL use_subsystem;
333 char subsystem_name[256];
334
335 BOOL nosession;
336 } TInstVar;
337
338 // �o�[�W���������������������X�������B ��: TTSSH_2-81_TS_data
339 #define TTSSH_FILEMAPNAME "TTSSH_" TTSSH_VERSION_STR("-") "_TS_data"
340
341 #define LOG_LEVEL_FATAL 5
342 #define LOG_LEVEL_ERROR 10
343 #define LOG_LEVEL_WARNING 30
344 #define LOG_LEVEL_NOTICE 50
345 #define LOG_LEVEL_INFO 80
346 #define LOG_LEVEL_VERBOSE 100
347 #define LOG_LEVEL_SSHDUMP 200
348
349 #define SSHv1(pvar) ((pvar)->protocol_major == 1)
350 #define SSHv2(pvar) ((pvar)->protocol_major == 2)
351
352 #define LogLevel(pvar, level) ((pvar)->settings.LogLevel >= (level))
353
354 void notify_established_secure_connection(PTInstVar pvar);
355 void notify_closed_connection(PTInstVar pvar, char *send_msg);
356 void notify_nonfatal_error(PTInstVar pvar, char *msg);
357 void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect);
358 void logputs(int level, char *msg);
359 void logprintf(int level, char *fmt, ...);
360 void logprintf_hexdump(int level, char *data, int len, char *fmt, ...);
361
362 void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename);
363 int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename);
364 int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);
365
366 #endif

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