12 #if defined( USE_SSH_EXTENDED ) && defined( _MSC_VER )
13 #pragma message( " Building with extended SSH facilities enabled." )
31 #define PADLENGTH_SIZE 1
32 #define BOOLEAN_SIZE 1
34 #define SSH1_COOKIE_SIZE 8
35 #define SSH1_HEADER_SIZE 5
36 #define SSH1_CRC_SIZE 4
37 #define SSH1_MPI_LENGTH_SIZE 2
38 #define SSH1_SESSIONID_SIZE 16
39 #define SSH1_SECRET_SIZE 32
40 #define SSH1_CHALLENGE_SIZE 32
41 #define SSH1_RESPONSE_SIZE 16
43 #define SSH2_COOKIE_SIZE 16
44 #define SSH2_HEADER_SIZE 5
45 #define SSH2_MIN_ALGOID_SIZE 4
46 #define SSH2_MIN_PADLENGTH_SIZE 4
47 #define SSH2_PAYLOAD_HEADER_SIZE 9
48 #define SSH2_FIXED_KEY_SIZE 16
49 #define SSH2_DEFAULT_KEYSIZE 128
55 #define MAX_PACKET_SIZE 262144L
56 #define EXTRA_PACKET_SIZE 512
57 #define DEFAULT_PACKET_SIZE 16384
58 #define MAX_WINDOW_SIZE ( MAX_INTLENGTH - 8192 )
68 #if defined( PREFER_ECC_SUITES ) && defined( _MSC_VER )
69 #pragma message( " Building with ECC preferred for SSH." )
71 #if defined( PREFER_ECC_SUITES ) && \
72 !( defined( USE_ECDH ) && defined( USE_ECDSA ) )
73 #error PREFER_ECC_SUITES can only be used with ECDH and ECDSA enabled
79 #define SSH_PFLAG_NONE 0x0000
80 #define SSH_PFLAG_HMACKEYSIZE 0x0001
81 #define SSH_PFLAG_SIGFORMAT 0x0002
82 #define SSH_PFLAG_NOHASHSECRET 0x0004
83 #define SSH_PFLAG_NOHASHLENGTH 0x0008
84 #define SSH_PFLAG_RSASIGPAD 0x0010
85 #define SSH_PFLAG_WINDOWSIZE 0x0020
86 #define SSH_PFLAG_TEXTDIAGS 0x0040
87 #define SSH_PFLAG_PAMPW 0x0080
88 #define SSH_PFLAG_DUMMYUSERAUTH 0x0100
89 #define SSH_PFLAG_EMPTYUSERAUTH 0x0200
90 #define SSH_PFLAG_ZEROLENIGNORE 0x0400
91 #define SSH_PFLAG_ASYMMCOPR 0x0800
92 #define SSH_PFLAG_EMPTYSVCACCEPT 0x1000
93 #define SSH_PFLAG_CUTEFTP 0x2000
94 #define SSH_PFLAG_MAX 0x3FFF
106 #define MIN_PACKET_SIZE 16
107 #define SSH2_HEADER_REMAINDER_SIZE \
108 ( MIN_PACKET_SIZE - LENGTH_SIZE )
109 #define SSH1_MAX_HEADER_SIZE ( LENGTH_SIZE + 8 + ID_SIZE + LENGTH_SIZE )
113 #define SSH_ID "SSH-"
114 #define SSH_ID_SIZE 4
115 #define SSH_VERSION_SIZE 4
116 #define SSH_ID_MAX_SIZE 255
117 #define SSH1_ID_STRING "SSH-1.5-cryptlib"
118 #define SSH2_ID_STRING "SSH-2.0-cryptlib"
119 #define SSH_ID_STRING_SIZE 16
123 #define SSH1_MSG_DISCONNECT 1
124 #define SSH1_SMSG_PUBLIC_KEY 2
125 #define SSH1_CMSG_SESSION_KEY 3
126 #define SSH1_CMSG_USER 4
127 #define SSH1_CMSG_AUTH_RSA 6
128 #define SSH1_SMSG_AUTH_RSA_CHALLENGE 7
129 #define SSH1_CMSG_AUTH_RSA_RESPONSE 8
130 #define SSH1_CMSG_AUTH_PASSWORD 9
131 #define SSH1_CMSG_REQUEST_PTY 10
132 #define SSH1_CMSG_WINDOW_SIZE 11
133 #define SSH1_CMSG_EXEC_SHELL 12
134 #define SSH1_CMSG_EXEC_CMD 13
135 #define SSH1_SMSG_SUCCESS 14
136 #define SSH1_SMSG_FAILURE 15
137 #define SSH1_CMSG_STDIN_DATA 16
138 #define SSH1_SMSG_STDOUT_DATA 17
139 #define SSH1_SMSG_EXITSTATUS 20
140 #define SSH1_MSG_IGNORE 32
141 #define SSH1_CMSG_EXIT_CONFIRMATION 33
142 #define SSH1_MSG_DEBUG 36
143 #define SSH1_CMSG_MAX_PACKET_SIZE 38
148 #define SSH1_CMSG_PORT_FORWARD_REQUEST 28
149 #define SSH1_CMSG_AGENT_REQUEST_FORWARDING 30
150 #define SSH1_CMSG_X11_REQUEST_FORWARDING 34
151 #define SSH1_CMSG_REQUEST_COMPRESSION 37
155 #define SSH1_CIPHER_NONE 0
156 #define SSH1_CIPHER_IDEA 1
157 #define SSH1_CIPHER_DES 2
158 #define SSH1_CIPHER_3DES 3
159 #define SSH1_CIPHER_TSS 4
160 #define SSH1_CIPHER_RC4 5
161 #define SSH1_CIPHER_BLOWFISH 6
162 #define SSH1_CIPHER_CRIPPLED 7
166 #define SSH1_AUTH_RHOSTS 1
167 #define SSH1_AUTH_RSA 2
168 #define SSH1_AUTH_PASSWORD 3
169 #define SSH1_AUTH_RHOSTS_RSA 4
170 #define SSH1_AUTH_TIS 5
171 #define SSH1_AUTH_KERBEROS 6
172 #define SSH1_PASS_KERBEROS_TGT 7
179 #define SSH_MSG_DISCONNECT 1
180 #define SSH_MSG_IGNORE 2
181 #define SSH_MSG_DEBUG 4
182 #define SSH_MSG_SERVICE_REQUEST 5
183 #define SSH_MSG_SERVICE_ACCEPT 6
184 #define SSH_MSG_KEXINIT 20
185 #define SSH_MSG_NEWKEYS 21
186 #define SSH_MSG_KEXDH_INIT 30
187 #define SSH_MSG_KEXDH_REPLY 31
188 #define SSH_MSG_KEXDH_GEX_REQUEST_OLD 30
189 #define SSH_MSG_KEXDH_GEX_GROUP 31
190 #define SSH_MSG_KEXDH_GEX_INIT 32
191 #define SSH_MSG_KEXDH_GEX_REPLY 33
192 #define SSH_MSG_KEXDH_GEX_REQUEST_NEW 34
193 #define SSH_MSG_KEX_ECDH_INIT 30
194 #define SSH_MSG_KEX_ECDH_REPLY 31
195 #define SSH_MSG_USERAUTH_REQUEST 50
196 #define SSH_MSG_USERAUTH_FAILURE 51
197 #define SSH_MSG_USERAUTH_SUCCESS 52
198 #define SSH_MSG_USERAUTH_BANNER 53
199 #define SSH_MSG_USERAUTH_INFO_REQUEST 60
200 #define SSH_MSG_USERAUTH_INFO_RESPONSE 61
201 #define SSH_MSG_GLOBAL_REQUEST 80
202 #define SSH_MSG_GLOBAL_SUCCESS 81
203 #define SSH_MSG_GLOBAL_FAILURE 82
204 #define SSH_MSG_CHANNEL_OPEN 90
205 #define SSH_MSG_CHANNEL_OPEN_CONFIRMATION 91
206 #define SSH_MSG_CHANNEL_OPEN_FAILURE 92
207 #define SSH_MSG_CHANNEL_WINDOW_ADJUST 93
208 #define SSH_MSG_CHANNEL_DATA 94
209 #define SSH_MSG_CHANNEL_EXTENDED_DATA 95
210 #define SSH_MSG_CHANNEL_EOF 96
211 #define SSH_MSG_CHANNEL_CLOSE 97
212 #define SSH_MSG_CHANNEL_REQUEST 98
213 #define SSH_MSG_CHANNEL_SUCCESS 99
214 #define SSH_MSG_CHANNEL_FAILURE 100
228 #define SSH1_MSG_SPECIAL_USEROPT 500
229 #define SSH1_MSG_SPECIAL_PWOPT 501
230 #define SSH1_MSG_SPECIAL_RSAOPT 502
231 #define SSH1_MSG_SPECIAL_ANY 503
233 #define SSH_MSG_SPECIAL_FIRST 500
234 #define SSH_MSG_SPECIAL_USERAUTH 501
235 #define SSH_MSG_SPECIAL_USERAUTH_PAM 502
236 #define SSH_MSG_SPECIAL_CHANNEL 503
237 #define SSH_MSG_SPECIAL_REQUEST 504
238 #define SSH_MSG_SPECIAL_LAST 505
242 #define SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1
243 #define SSH_DISCONNECT_PROTOCOL_ERROR 2
244 #define SSH_DISCONNECT_KEY_EXCHANGE_FAILED 3
245 #define SSH_DISCONNECT_RESERVED 4
246 #define SSH_DISCONNECT_MAC_ERROR 5
247 #define SSH_DISCONNECT_COMPRESSION_ERROR 6
248 #define SSH_DISCONNECT_SERVICE_NOT_AVAILABLE 7
249 #define SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8
250 #define SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9
251 #define SSH_DISCONNECT_CONNECTION_LOST 10
252 #define SSH_DISCONNECT_BY_APPLICATION 11
253 #define SSH_DISCONNECT_TOO_MANY_CONNECTIONS 12
254 #define SSH_DISCONNECT_AUTH_CANCELLED_BY_USER 13
255 #define SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14
256 #define SSH_DISCONNECT_ILLEGAL_USER_NAME 15
260 #define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1
261 #define SSH_OPEN_CONNECT_FAILED 2
262 #define SSH_OPEN_UNKNOWN_CHANNEL_TYPE 3
263 #define SSH_OPEN_RESOURCE_SHORTAGE 4
286 #define CRYPT_PSEUDOALGO_DHE ( CRYPT_ALGO_LAST_CONVENTIONAL - 9 )
287 #define CRYPT_PSEUDOALGO_DHE_ALT ( CRYPT_ALGO_LAST_CONVENTIONAL - 8 )
288 #define CRYPT_PSEUDOALGO_ECDH_P384 ( CRYPT_ALGO_LAST_CONVENTIONAL - 7 )
289 #define CRYPT_PSEUDOALGO_ECDH_P521 ( CRYPT_ALGO_LAST_CONVENTIONAL - 6 )
290 #define CRYPT_PSEUDOALGO_ECDSA_P384 ( CRYPT_ALGO_LAST_CONVENTIONAL - 5 )
291 #define CRYPT_PSEUDOALGO_ECDSA_P521 ( CRYPT_ALGO_LAST_CONVENTIONAL - 4 )
292 #define CRYPT_PSEUDOALGO_COPR ( CRYPT_ALGO_LAST_CONVENTIONAL - 3 )
293 #define CRYPT_PSEUDOALGO_PASSWORD ( CRYPT_ALGO_LAST_CONVENTIONAL - 2 )
294 #define CRYPT_PSEUDOALGO_PAM ( CRYPT_ALGO_LAST_CONVENTIONAL - 1 )
300 #define MAX_ENCODED_KEYEXSIZE ( CRYPT_MAX_PKCSIZE + 16 )
301 #define ENCODED_REQKEYSIZE ( UINT_SIZE * 3 )
306 #define isPseudoAlgo( algorithm ) \
307 ( algorithm >= CRYPT_PSEUDOALGO_DHE && \
308 algorithm <= CRYPT_PSEUDOALGO_PAM )
328 #define isValidDHsize( value, serverKeySize, extraLength ) \
329 ( ( value ) > ( ( serverKeySize ) - 8 ) + ( extraLength ) && \
330 ( value ) < ( ( serverKeySize ) + 2 ) + ( extraLength ) )
331 #define isValidECDHsize( value, serverKeySize, extraLength ) \
332 ( ( value ) / 2 > ( ( serverKeySize ) - 8 ) + ( extraLength ) && \
333 ( value ) / 2 < ( ( serverKeySize ) + 2 ) + ( extraLength ) )
386 #define hostModulus clientKeyexValue
387 #define serverModulus serverKeyexValue
388 #define hostModulusLength clientKeyexValueLength
389 #define serverModulusLength serverKeyexValueLength
436 #define UNUSED_CHANNEL_NO CRYPT_ERROR
437 #define UNUSED_CHANNEL_ID 0
456 #define streamBookmarkSet( stream, offset ) \
457 offset = stell( stream )
458 #define streamBookmarkSetFullPacket( stream, offset ) \
459 offset = stell( stream ) - ID_SIZE
475 IN_RANGE( 1, 100 )
const int noAlgoStringEntries,
514 IN const long channelNo,
519 IN const long channelNo,
562 IN_RANGE( 1, 255 )
const int type,
563 IN_RANGE( 0, 4 )
const int noParams,
570 IN_RANGE( 1, 255 )
const int type,
669 const int expectedType,
679 IN_RANGE( 1, 1024 )
const int minPacketSize );
687 int openPacketStreamSSH(
OUT STREAM *stream,
691 const int packetType );
693 int openPacketStreamSSHEx(
OUT STREAM *stream,
698 const int packetType );
703 const int packetType,
721 STDC_NONNULL_ARG( ( 1 ) );
734 #define initSSH1processing initSSH2processing