Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3221 by maya, Tue Mar 24 09:37:20 2009 UTC revision 3227 by maya, Tue Mar 24 15:10:33 2009 UTC
# Line 1  Line 1 
1  /*  /*
2  Copyright (c) 1998-2001, Robert O'Callahan  Copyright (c) 1998-2001, Robert O'Callahan
3  All rights reserved.  All rights reserved.
4    
5  Redistribution and use in source and binary forms, with or without modification,  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:  are permitted provided that the following conditions are met:
7    
8  Redistributions of source code must retain the above copyright notice, this list of  Redistributions of source code must retain the above copyright notice, this list of
9  conditions and the following disclaimer.  conditions and the following disclaimer.
10    
11  Redistributions in binary form must reproduce the above copyright notice, this list  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  of conditions and the following disclaimer in the documentation and/or other materials
13  provided with the distribution.  provided with the distribution.
14    
15  The name of Robert O'Callahan may not be used to endorse or promote products derived from  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.  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 COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES  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  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,  THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  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)  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,  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  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.  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */  */
28    
29  /*  /*
30  This code is copyright (C) 1998-1999 Robert O'Callahan.  This code is copyright (C) 1998-1999 Robert O'Callahan.
31  See LICENSE.TXT for the license.  See LICENSE.TXT for the license.
32  */  */
33    
34  #ifndef __TTXSSH_H  #ifndef __TTXSSH_H
35  #define __TTXSSH_H  #define __TTXSSH_H
36    
37  #pragma warning(3 : 4035)  #pragma warning(3 : 4035)
38    
39  #ifndef NO_INET6  #ifndef NO_INET6
40  #include <winsock2.h>  #include <winsock2.h>
41  #include <ws2tcpip.h>  #include <ws2tcpip.h>
42  /* actual body of in6addr_any and in6addr_loopback is disappeared?? */  /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
43  #undef IN6_IS_ADDR_LOOPBACK  #undef IN6_IS_ADDR_LOOPBACK
44  #define IN6_IS_ADDR_LOOPBACK(a)         \  #define IN6_IS_ADDR_LOOPBACK(a)         \
45          ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) &&     \          ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) &&     \
46           (*(unsigned int *)(&(a)->s6_addr[4]) == 0) &&     \           (*(unsigned int *)(&(a)->s6_addr[4]) == 0) &&     \
47           (*(unsigned int *)(&(a)->s6_addr[8]) == 0) &&     \           (*(unsigned int *)(&(a)->s6_addr[8]) == 0) &&     \
48           (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))           (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
49  /* work around for MS Platform SDK Oct 2000 */  /* work around for MS Platform SDK Oct 2000 */
50  #include <malloc.h> /* prevent of conflict stdlib.h */  #include <malloc.h> /* prevent of conflict stdlib.h */
51  #endif /* NO_INET6 */  #endif /* NO_INET6 */
52  #include <stdlib.h>  #include <stdlib.h>
53  #include <crtdbg.h>  #include <crtdbg.h>
54    
55  #include "i18n.h"  #include "i18n.h"
56    
57    
58  typedef struct _TInstVar FAR * PTInstVar;  typedef struct _TInstVar FAR * PTInstVar;
59    
60  #include "util.h"  #include "util.h"
61  #include "pkt.h"  #include "pkt.h"
62  #include "ssh.h"  #include "ssh.h"
63  #include "auth.h"  #include "auth.h"
64  #include "crypt.h"  #include "crypt.h"
65  #include "hosts.h"  #include "hosts.h"
66  #include "fwd.h"  #include "fwd.h"
67    
68  #include <openssl/dh.h>  #include <openssl/dh.h>
69  #include <openssl/evp.h>  #include <openssl/evp.h>
70  #include "buffer.h"  #include "buffer.h"
71    
72  /* tttypes.h で定義されている EM マクロが openssl/rsa.h (OpenSSL 0.9.8)の関数プロトタイプ宣言に  /* tttypes.h で定義されている EM マクロが openssl/rsa.h (OpenSSL 0.9.8)の関数プロトタイプ宣言に
73   * ある引数名と重複してしまうので、ビルドエラーとなる。下記3ヘッダのinclude位置を下記に移動した。   * ある引数名と重複してしまうので、ビルドエラーとなる。下記3ヘッダのinclude位置を下記に移動した。
74   * (2005.7.9 yutaka)   * (2005.7.9 yutaka)
75   */   */
76  #include "teraterm.h"  #include "teraterm.h"
77  #include "tttypes.h"  #include "tttypes.h"
78  #include "ttplugin.h"  #include "ttplugin.h"
79    
80  HANDLE hInst; /* Instance handle of TTXSSH.DLL */  HANDLE hInst; /* Instance handle of TTXSSH.DLL */
81    
82  #define ID_SSHSCPMENU       52110  #define ID_SSHSCPMENU       52110
83  #define ID_SSHSETUPMENU     52310  #define ID_SSHSETUPMENU     52310
84  #define ID_SSHAUTHSETUPMENU 52320  #define ID_SSHAUTHSETUPMENU 52320
85  #define ID_SSHFWDSETUPMENU  52330  #define ID_SSHFWDSETUPMENU  52330
86  #define ID_SSHKEYGENMENU    52340  #define ID_SSHKEYGENMENU    52340
87  #define ID_ABOUTMENU        52910  #define ID_ABOUTMENU        52910
88    
89  #define ID_SSHAUTH            62501  #define ID_SSHAUTH            62501
90  #define ID_SSHUNKNOWNHOST     62502  #define ID_SSHUNKNOWNHOST     62502
91  #define ID_SSHDIFFERENTHOST   62503  #define ID_SSHDIFFERENTHOST   62503
92  #define ID_SSHASYNCMESSAGEBOX 62504  #define ID_SSHASYNCMESSAGEBOX 62504
93    
94  #define OPTION_NONE     0  #define OPTION_NONE     0
95  #define OPTION_CLEAR    1  #define OPTION_CLEAR    1
96  #define OPTION_REPLACE  2  #define OPTION_REPLACE  2
97    
98  /*  /*
99  These are the fields that WOULD go in Tera Term's 'ts' structure, if  These are the fields that WOULD go in Tera Term's 'ts' structure, if
100  we could put them there.  we could put them there.
101  */  */
102  typedef struct _TS_SSH {  typedef struct _TS_SSH {
103          BOOL Enabled;          BOOL Enabled;
104          int CompressionLevel; /* 0 = NONE, else 1-9 */          int CompressionLevel; /* 0 = NONE, else 1-9 */
105          char DefaultUserName[256];          char DefaultUserName[256];
106    
107          /* this next option is a string of digits. Each digit represents a          /* this next option is a string of digits. Each digit represents a
108             cipher. The first digit is the most preferred cipher, and so on.             cipher. The first digit is the most preferred cipher, and so on.
109             The digit SSH_CIPHER_NONE signifies that any ciphers after it are             The digit SSH_CIPHER_NONE signifies that any ciphers after it are
110             disabled. */             disabled. */
111          char CipherOrder[SSH_CIPHER_MAX+1];          char CipherOrder[SSH_CIPHER_MAX+1];
112    
113          char KnownHostsFiles[2048];          char KnownHostsFiles[2048];
114          int DefaultAuthMethod;          int DefaultAuthMethod;
115          char DefaultRhostsLocalUserName[256];          char DefaultRhostsLocalUserName[256];
116          char DefaultRhostsHostPrivateKeyFile[1024];          char DefaultRhostsHostPrivateKeyFile[1024];
117          char DefaultRSAPrivateKeyFile[1024];          char DefaultRSAPrivateKeyFile[1024];
118    
119          char DefaultForwarding[2048];          char DefaultForwarding[2048];
120          BOOL TryDefaultAuth;          BOOL TryDefaultAuth;
121    
122          int LogLevel;      /* 0 = NONE, 100 = Verbose */          int LogLevel;      /* 0 = NONE, 100 = Verbose */
123          int WriteBufferSize;          int WriteBufferSize;
124          int LocalForwardingIdentityCheck;          int LocalForwardingIdentityCheck;
125    
126          int ssh_protocol_version; // SSH version (2004.10.11 yutaka)          int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
127          int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)          int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
128          // whether password will permanently store on heap memory (2006.8.5 yutaka)          // whether password will permanently store on heap memory (2006.8.5 yutaka)
129          int remember_password;          int remember_password;
130    
131          // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)          // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)
132          BOOL CheckAuthListFirst;          BOOL CheckAuthListFirst;
133    
134          // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)          // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)
135          BOOL EnableRsaShortKeyServer;          BOOL EnableRsaShortKeyServer;
136    
137          // Enable Agent forwarding          // Enable Agent forwarding
138          BOOL ForwardAgent;          BOOL ForwardAgent;
139  } TS_SSH;  } TS_SSH;
140    
141  typedef struct _TInstVar {  typedef struct _TInstVar {
142          PTTSet ts;          PTTSet ts;
143          PComVar cv;          PComVar cv;
144    
145          /* shared memory for settings across instances. Basically it's          /* shared memory for settings across instances. Basically it's
146             a cache for the INI file.*/             a cache for the INI file.*/
147          TS_SSH FAR * ts_SSH;          TS_SSH FAR * ts_SSH;
148    
149          int fatal_error;          int fatal_error;
150          int showing_err;          int showing_err;
151          char FAR * err_msg;          char FAR * err_msg;
152    
153          Tconnect Pconnect;          Tconnect Pconnect;
154          Trecv Precv;          Trecv Precv;
155          Tsend Psend;          Tsend Psend;
156          TWSAAsyncSelect PWSAAsyncSelect;          TWSAAsyncSelect PWSAAsyncSelect;
157          TWSAGetLastError PWSAGetLastError;          TWSAGetLastError PWSAGetLastError;
158    
159          PReadIniFile ReadIniFile;          PReadIniFile ReadIniFile;
160          PWriteIniFile WriteIniFile;          PWriteIniFile WriteIniFile;
161          PParseParam ParseParam;          PParseParam ParseParam;
162    
163          SOCKET socket;          SOCKET socket;
164          HWND NotificationWindow;          HWND NotificationWindow;
165          unsigned int notification_msg;          unsigned int notification_msg;
166          long notification_events;          long notification_events;
167          HICON OldSmallIcon;          HICON OldSmallIcon;
168          HICON OldLargeIcon;          HICON OldLargeIcon;
169    
170          BOOL hostdlg_activated;          BOOL hostdlg_activated;
171          BOOL hostdlg_Enabled;          BOOL hostdlg_Enabled;
172    
173          int protocol_major;          int protocol_major;
174          int protocol_minor;          int protocol_minor;
175    
176          PKTState pkt_state;          PKTState pkt_state;
177          SSHState ssh_state;          SSHState ssh_state;
178          AUTHState auth_state;          AUTHState auth_state;
179          CRYPTState crypt_state;          CRYPTState crypt_state;
180          HOSTSState hosts_state;          HOSTSState hosts_state;
181          FWDState fwd_state;          FWDState fwd_state;
182    
183  /* The settings applied to the current session. The user may change  /* The settings applied to the current session. The user may change
184     the settings but usually we don't want that to affect the session     the settings but usually we don't want that to affect the session
185     in progress (race conditions). So user setup changes usually     in progress (race conditions). So user setup changes usually
186     modify the 'settings' field below. */     modify the 'settings' field below. */
187          TS_SSH session_settings;          TS_SSH session_settings;
188    
189  /* our copy of the global settings. This is synced up with the shared  /* our copy of the global settings. This is synced up with the shared
190     memory only when we do a ReadIniFile or WriteIniFile     memory only when we do a ReadIniFile or WriteIniFile
191     (i.e. the user loads or saves setup) */     (i.e. the user loads or saves setup) */
192          TS_SSH settings;          TS_SSH settings;
193    
194          // SSH2          // SSH2
195          DH *kexdh;          DH *kexdh;
196          char server_version_string[128];          char server_version_string[128];
197          char client_version_string[128];          char client_version_string[128];
198          buffer_t *my_kex;          buffer_t *my_kex;
199          buffer_t *peer_kex;          buffer_t *peer_kex;
200          enum kex_exchange kex_type; // KEX algorithm          enum kex_exchange kex_type; // KEX algorithm
201          enum hostkey_type hostkey_type;          enum hostkey_type hostkey_type;
202          SSHCipher ctos_cipher;          SSHCipher ctos_cipher;
203          SSHCipher stoc_cipher;          SSHCipher stoc_cipher;
204          enum hmac_type ctos_hmac;          enum hmac_type ctos_hmac;
205          enum hmac_type stoc_hmac;          enum hmac_type stoc_hmac;
206          enum compression_algorithm ctos_compression;          enum compression_algorithm ctos_compression;
207          enum compression_algorithm stoc_compression;          enum compression_algorithm stoc_compression;
208          int we_need;          int we_need;
209          int key_done;          int key_done;
210          int rekeying;          int rekeying;
211          char *session_id;          char *session_id;
212          int session_id_len;          int session_id_len;
213          Newkeys ssh2_keys[MODE_MAX];          Newkeys ssh2_keys[MODE_MAX];
214          EVP_CIPHER_CTX evpcip[MODE_MAX];          EVP_CIPHER_CTX evpcip[MODE_MAX];
215          int userauth_success;          int userauth_success;
216          int shell_id;          int shell_id;
217          /*int remote_id;*/          /*int remote_id;*/
218          int session_nego_status;          int session_nego_status;
219          /*          /*
220          unsigned int local_window;          unsigned int local_window;
221          unsigned int local_window_max;          unsigned int local_window_max;
222          unsigned int local_consumed;          unsigned int local_consumed;
223          unsigned int local_maxpacket;          unsigned int local_maxpacket;
224          unsigned int remote_window;          unsigned int remote_window;
225          unsigned int remote_maxpacket;          unsigned int remote_maxpacket;
226          */          */
227          int client_key_bits;          int client_key_bits;
228          int server_key_bits;          int server_key_bits;
229          int kexgex_min;          int kexgex_min;
230          int kexgex_bits;          int kexgex_bits;
231          int kexgex_max;          int kexgex_max;
232          int ssh2_autologin;          int ssh2_autologin;
233          int ask4passwd;          int ask4passwd;
234          SSHAuthMethod ssh2_authmethod;          SSHAuthMethod ssh2_authmethod;
235          char ssh2_username[MAX_PATH];          char ssh2_username[MAX_PATH];
236          char ssh2_password[MAX_PATH];          char ssh2_password[MAX_PATH];
237          char ssh2_keyfile[MAX_PATH];          char ssh2_keyfile[MAX_PATH];
238          time_t ssh_heartbeat_tick;          time_t ssh_heartbeat_tick;
239          HANDLE ssh_heartbeat_thread;          HANDLE ssh_heartbeat_thread;
240          int keyboard_interactive_password_input;          int keyboard_interactive_password_input;
241          int userauth_retry_count;          int userauth_retry_count;
242          buffer_t *decomp_buffer;          buffer_t *decomp_buffer;
243          char *ssh2_authlist;          char *ssh2_authlist;
244          BOOL tryed_ssh2_authlist;          BOOL tryed_ssh2_authlist;
245          HWND ssh_hearbeat_dialog;          HWND ssh_hearbeat_dialog;
246    
247          /* Pageant との通信用 */          /* Pageant との通信用 */
248          unsigned char *pageant_key;          unsigned char *pageant_key;
249          unsigned char *pageant_curkey;          unsigned char *pageant_curkey;
250          int pageant_keylistlen;          int pageant_keylistlen;
251          int pageant_keycount;          int pageant_keycount;
252          int pageant_keycurrent;          int pageant_keycurrent;
253          BOOL pageant_keyfinal;// SSH2 PK_OK が来たときに TRUE にする          BOOL pageant_keyfinal;// SSH2 PK_OK が来たときに TRUE にする
254    
255          // agent forward          // agent forward
256          BOOL agentfwd_enable;          BOOL agentfwd_enable;
257  } TInstVar;  } TInstVar;
258    
259  #define LOG_LEVEL_FATAL      5  #define LOG_LEVEL_FATAL      5
260  #define LOG_LEVEL_ERROR      10  #define LOG_LEVEL_ERROR      10
261  #define LOG_LEVEL_URGENT     20  #define LOG_LEVEL_URGENT     20
262  #define LOG_LEVEL_WARNING    30  #define LOG_LEVEL_WARNING    30
263  #define LOG_LEVEL_VERBOSE    100  #define LOG_LEVEL_VERBOSE    100
264  #define LOG_LEVEL_SSHDUMP    200  #define LOG_LEVEL_SSHDUMP    200
265    
266  #define SSHv1(pvar) ((pvar)->protocol_major == 1)  #define SSHv1(pvar) ((pvar)->protocol_major == 1)
267  #define SSHv2(pvar) ((pvar)->protocol_major == 2)  #define SSHv2(pvar) ((pvar)->protocol_major == 2)
268    
269  void notify_established_secure_connection(PTInstVar pvar);  void notify_established_secure_connection(PTInstVar pvar);
270  void notify_closed_connection(PTInstVar pvar);  void notify_closed_connection(PTInstVar pvar);
271  void notify_nonfatal_error(PTInstVar pvar, char FAR * msg);  void notify_nonfatal_error(PTInstVar pvar, char FAR * msg);
272  void notify_fatal_error(PTInstVar pvar, char FAR * msg);  void notify_fatal_error(PTInstVar pvar, char FAR * msg);
273  void notify_verbose_message(PTInstVar pvar, char FAR * msg, int level);  void notify_verbose_message(PTInstVar pvar, char FAR * msg, int level);
274    
275  void get_teraterm_dir_relative_name(char FAR * buf, int bufsize, char FAR * basename);  void get_teraterm_dir_relative_name(char FAR * buf, int bufsize, char FAR * basename);
276  int copy_teraterm_dir_relative_path(char FAR * dest, int destsize, char FAR * basename);  int copy_teraterm_dir_relative_path(char FAR * dest, int destsize, char FAR * basename);
277  void get_file_version(char *exefile, int *major, int *minor, int *release, int *build);  void get_file_version(char *exefile, int *major, int *minor, int *release, int *build);
278  int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);  int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);
279    
280  #endif  #endif

Legend:
Removed from v.3221  
changed lines
  Added in v.3227

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