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 6051 - (hide annotations) (download) (as text)
Tue Oct 20 02:29:21 2015 UTC (8 years, 5 months ago) by doda
Original Path: trunk/ttssh2/ttxssh/ttxssh.h
File MIME type: text/x-chdr
File size: 9826 byte(s)
_snprintf_s() してから notify_verbose_message() を呼ぶのが面倒なので、
printf() ライクにログを出力する為の logprintf() を追加。

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

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