Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6813 - (hide annotations) (download) (as text)
Wed Jun 21 10:08:55 2017 UTC (6 years, 9 months ago) by doda
Original Path: trunk/ttssh2/ttxssh/ttxssh.h
File MIME type: text/x-chdr
File size: 10236 byte(s)
session_settings.LogLevel を外に見せないようにする為、LogLevel() マクロ経由でアクセスするようにした。

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

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