TrustCore SDK NanoSSH API reference  version 7.0
sshc.h
Go to the documentation of this file.
1 /*
2  * sshc.h
3  *
4  * SSH Client Developer API
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
10 
33 #ifndef __SSHC_HEADER__
34 #define __SSHC_HEADER__
35 
36 #include "../../common/mtcp.h"
37 #include "../../crypto/pubcrypto.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #define SSHC_SFTP_MAX_READ_BYTES (MAX_SESSION_WINDOW_SIZE - (4 + 4 + 1 + 4))
44 #define SSHC_BUFFER_SIZE (SSHC_MAX_BUFFER_SIZE)
45 
46 #define CONNECT_CLOSING -1
47 #define CONNECT_DISABLED 0
48 #define CONNECT_CLOSED 1
49 #define CONNECT_NEGOTIATE 2
50 #define CONNECT_OPEN 3
51 
52 #define SSH_BYTE_SIZE 1
53 #define SSH_UINT64_FIELD_SIZE 8
54 
55 
56 /*------------------------------------------------------------------*/
57 
58 /* timeouts in milliseconds (zero indicates no timeout) */
59 #if 1
60  #define TIMEOUT_SSHC_OPEN (2000)
61  #ifdef __ENABLE_MOCANA_QS__
62  #define TIMEOUT_SSHC_KEX (120000)
63  #elif defined(__FSL_MSS_FIX_ENABLED__)
64  #define TIMEOUT_SSHC_KEX (40000)
65  #else
66  #define TIMEOUT_SSHC_KEX (10000)
67  #endif
68 
69  #define TIMEOUT_SSHC_NEWKEYS (15000)
70 #ifdef __ENABLE_MOCANA_QS__
71  #define TIMEOUT_SSHC_SERVICE_REQUEST (120000)
72 #else
73  #define TIMEOUT_SSHC_SERVICE_REQUEST (30000)
74 #endif
75  #define TIMEOUT_SSHC_OPEN_STATE (30000)
76  #define TIMEOUT_SSHC_UPPER_LAYER (15000)
77  #define TIMEOUT_SSHC_PORTFWD_MESG (500)
78  #define TIMEOUT_SSHC_PORTFWD_START (1000)
79 #else
80 #define TIMEOUT_SSHC_OPEN (0)
81 #define TIMEOUT_SSHC_KEX (0)
82 #define TIMEOUT_SSHC_NEWKEYS (0)
83 #define TIMEOUT_SSHC_SERVICE_REQUEST (0)
84 #define TIMEOUT_SSHC_OPEN_STATE (0)
85 #define TIMEOUT_SSHC_UPPER_LAYER (0)
86 #endif
87 
88 
89 /* the most interesting of these values, the amount of time we allow the user to authenticate */
90 #ifdef __ENABLE_MOCANA_QS__
91  #define TIMEOUT_SSHC_AUTH_LOGON (1000 * 60 * 200)
92 #else
93  #define TIMEOUT_SSHC_AUTH_LOGON (1000 * 60 * 10)
94 #endif
95 
96 /* suggested by SSHv2 standard, max number of authentication attempts */
97 #define MAX_SSHC_AUTH_ATTEMPTS (20)
98 
99 /* sizes */
100 #if 1
101  #ifndef SSHC_MAX_BUFFER_SIZE
102  #ifdef __ENABLE_MOCANA_QS__
103  #define SSHC_MAX_BUFFER_SIZE (2097152)
104  #elif defined(__FSL_MSS_FIX_ENABLED__)
105  #define SSHC_MAX_BUFFER_SIZE (2200)
106  #else
107  #define SSHC_MAX_BUFFER_SIZE (1024*4)
108  #endif
109  #endif
110 
111  #ifdef __FSL_MSS_FIX_ENABLED__
112  #define MAX_SESSION_WINDOW_SIZE (2500)
113  #else
114  #define MAX_SESSION_WINDOW_SIZE (1024*2)
115  #endif
116 
117  #define SSHC_SYNC_BUFFER_SIZE (1000)
118  #define SSHC_SFTP_GetMaxBytesToRead() (SSHC_SYNC_BUFFER_SIZE)
119 #else
120 /* fast sizes */
121  #ifndef SSHC_MAX_BUFFER_SIZE
122  #define SSHC_MAX_BUFFER_SIZE (16000)
123  #endif
124 
125  #define MAX_SESSION_WINDOW_SIZE (15000)
126  #define SSHC_SYNC_BUFFER_SIZE (8192)
127  #define SSHC_SFTP_GetMaxBytesToRead() (SSHC_SYNC_BUFFER_SIZE)
128 #endif
129 
130 /* SSH Key Blob Types */
131 #define SSH_PUBLIC_KEY_BLOB 1
132 #define SSH_PRIVATE_KEY_BLOB 2
133 
134 /* SSH Advertised Authentication Methods (OR for multiple types) */
135 #define MOCANA_SSH_AUTH_PUBLIC_KEY 0x80
136 #define MOCANA_SSH_AUTH_PASSWORD 0x40
137 #define MOCANA_SSH_AUTH_NONE 0x10
138 #define MOCANA_SSH_AUTH_KEYBOARD_INTERACTIVE 0x20
139 #define MOCANA_SSH_AUTH_CERT 0x100
140 
141 /* OCSP responders */
142 #define MAX_OCSP_TRUSTED_RESPONDERS 3
143 
144 #define SSH_MAX_RPF_HOSTS 16
145 #define SSH_MAX_REMOTE_PORT_FWD_CHANNEL 64
146 
147 /* authentication keyboard interactive */
148 #define AUTH_ECHO (1)
149 #define AUTH_NO_ECHO (0)
150 
151 #ifndef AUTH_MAX_NUM_PROMPTS
152 #define AUTH_MAX_NUM_PROMPTS 3
153 #endif
154 
155 #ifndef MAX_SSH_DH_SIZE
156 #define MAX_SSH_DH_SIZE (8192)
157 #endif
158 
159 /*------------------------------------------------------------------*/
160 
161 /* message types */
162 enum sshcSessionTypes
163 {
164  SSH_SESSION_NOTHING,
165  SSH_SESSION_OPEN,
166  SSH_SESSION_PTY_REQUEST,
167  SSH_SESSION_OPEN_SHELL,
168  SSH_SESSION_OPEN_SFTP,
169  SSH_SESSION_OPEN_PTY,
170  SSH_SESSION_WINDOW_CHANGE,
171  SSH_SESSION_DATA,
172  SSH_SESSION_STDERR,
173  SSH_SESSION_EOF,
174  SSH_SESSION_CLOSED,
175  SSH_SESSION_BREAK_OP
176 };
177 
178 enum pfType
179 {
180  SSH_LOCAL_PORT_FORWARDING,
181  SSH_REMOTE_PORT_FORWARDING
182 };
183 
184 /*------------------------------------------------------------------*/
185 
190 typedef struct
191 {
192  ubyte4 width;
193  ubyte4 height;
194  ubyte4 pixelWidth;
195  ubyte4 pixelHeight;
196 
197  sbyte* pTerminalEnvironment;
198  ubyte4 terminalEnvironmentLength;
199 
200  sbyte* pEncodedTerminalModes;
201  ubyte4 encodedTerminalModes;
202 
203  ubyte4 breakLength;
204 
206 
207 
208 /*------------------------------------------------------------------*/
209 
210 #ifdef __ENABLE_MOCANA_SSH_FTP_CLIENT__
211 
217 typedef struct
218 {
219  intBoolean isFileHandleInUse;
220  void* pHandleName;
221  void* cookie; /* not used for directories */
222 
223  sbyte4 readLocation; /* current position / total bytes read */
224  sbyte* pReadBuffer;
225  sbyte4 readBufferSize;
226 
227  sbyte4 writeLocation; /* current position / total bytes written */
228  sbyte* pWriteBuffer;
229  sbyte4 writeBufferSize;
230 
231  sbyte4 clientWrtLoc; /* internal use */
232  ubyte4 requestID; /* current pending request id */
233  ubyte request; /* not sure if needed */
234  ubyte4 requestStatusResponse; /* the status response for the request */
235  sbyte4 response; /* response message type for our request */
236 
237  /* for realpath */
238  struct ATTRClient* pATTR; /* used by SSH_FXP_NAME */
239  void* pFilename; /* used by SSH_FXP_NAME */
240 
241  /* for file listings */
242  ubyte* pFileListingPayload; /* used by SSH_FXP_NAME */
243  ubyte4 fileListingCount;
244  ubyte4 fileListingPosition;
245  ubyte4 fileListingBufIndex;
246  ubyte4 fileListingPayloadLen;
247 
249 #endif /* __ENABLE_MOCANA_SSH_FTP_CLIENT__ */
250 
255 typedef struct
256 {
257  sbyte* pPrompt;
258  ubyte4 promptLen;
259  ubyte4 echo;
260 
261 } keyIntPrompt;
262 
267 typedef struct keyIntInfoReq
268 {
269  sbyte4 cookie; /* for flexiblity, useful for marking things as static or dynamic, etc */
270 
271  sbyte* pName;
272  ubyte4 nameLen;
273  sbyte* pInstruction;
274  ubyte4 instructionLen;
275 
276  ubyte4 numPrompts;
277  keyIntPrompt* prompts[AUTH_MAX_NUM_PROMPTS];
278 
279 } keyIntInfoReq;
280 
285 typedef struct
286 {
287  ubyte* pResponse;
288  ubyte4 responseLen;
289 
290 } keyIntResp;
291 
296 typedef struct
297 {
298  ubyte4 numResponses;
299  keyIntResp* responses[AUTH_MAX_NUM_PROMPTS]; /* contains responses to prompts */
300 
302 struct certChain;
303 typedef struct certChain* certChainPtr;
304 
305 /*------------------------------------------------------------------*/
306 
329 typedef struct
330 {
336 
344 
352 
360 
368 
376 
384 
392 
393 #if ((defined(__ENABLE_MOCANA_SSH_OCSP_SUPPORT__)) && (defined(__ENABLE_MOCANA_OCSP_CLIENT__)))
394 
401  certDescriptor ocspTrustedResponderCerts[MAX_OCSP_TRUSTED_RESPONDERS];
402 #endif
403 
409  MSTATUS (*funcPtrSessionOpen) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
410 
416  MSTATUS (*funcPtrPtyRequest) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
417 
423  MSTATUS (*funcPtrOpenShell) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
424 
430  MSTATUS (*funcPtrOpenSftp) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
431 
437  MSTATUS (*funcPtrWindowChange) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
438 
444  MSTATUS (*funcPtrReceivedData) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
445 
451  MSTATUS (*funcPtrStdErr) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
452 
458  MSTATUS (*funcPtrEof) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
459 
465  MSTATUS (*funcPtrClosed) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
466 
472  MSTATUS (*funcPtrBreakOp) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen);
473 
474  /* general purpose upcalls */
475 
502  void(*funcPtrStartTimer) (sbyte4 connectionInstance, ubyte4 msTimerExpire, sbyte4 boolUserAuthenticated);
503 
504 
540  sbyte4(*funcPtrRetrieveNakedAuthKeys)(sbyte4 connectionInstance, ubyte **ppRetKeyBlob, ubyte4 *pRetKeyBlobLength);
541 
573  sbyte4(*funcPtrReleaseNakedAuthKeys) (sbyte4 connectionInstance, ubyte **ppFreeKeyBlob);
574 
575  /* for SSH_MSG_USERAUTH_REQUEST (50). pMethod can be one of MOCANA_SSH_AUTH_PUBLIC_KEY or MOCANA_SSH_AUTH_PASSWORD. */
576 
665  sbyte4(*funcPtrServerPubKeyAuth) (sbyte4 connectionInstance, const ubyte *pPubKey, ubyte4 pubKeyLength);
666 
710  sbyte4(*funcPtrRetrieveUserAuthRequestInfo)(sbyte4 connectionInstance, ubyte *pAuthNameList, ubyte4 authNameListLen, ubyte **ppUserName, ubyte4 *pUserNameLength, ubyte4 *pMethod);
711 
712 
713 #ifdef __ENABLE_MOCANA_SSH_AUTH_KEYBOARD_INTERACTIVE__
714  sbyte4(*funcPtrKeyIntAuthResp)(sbyte4 connectionInstance, keyIntInfoReq* pRequestInfo, keyIntInfoResp* pResponseInfo);
715 
716  sbyte4(*funcPtrReleaseKeyIntAuthResp)(sbyte4 connectionInstance, keyIntInfoResp *pResponse);
717 #endif
718 
776  sbyte4(*funcPtrRetrieveUserAuthRequestInfoEx)(sbyte4 connectionInstance, ubyte messageCode, ubyte4 methodType, ubyte *pAuthNameList, ubyte4 authNameListLen, ubyte **ppUserName, ubyte4 *pUserNameLength, ubyte4 *pMethod, intBoolean *pSendSignature);
777 
812  sbyte4(*funcPtrCertStatus) (sbyte4 connectionInstance,
813  sbyte4 cert_status, ubyte *pCertificate, ubyte4 certLen,
814  certChainPtr pCertChain, const ubyte *pAnchorCert, ubyte4 anchorCertLen);
815 
850  sbyte4(*funcPtrRetrieveUserPassword) (sbyte4 connectionInstance, ubyte *pUserName, ubyte4 userNameLength, ubyte **ppUserPassword, ubyte4 *pUserPasswordLength);
851 
878  void(*funcPtrAuthOpen) (sbyte4 connectionInstance);
879 
917  sbyte4(*funcPtrSessionOpenFail) (sbyte4 connectionInstance, ubyte *pInfo, ubyte4 infoLength, ubyte *pLanguage, ubyte4 languageLength);
918 
919 #ifdef __ENABLE_MOCANA_SSH_PORT_FORWARDING__
920 
954  void(*funcPtrPortFwdSessionOpen) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen, ubyte4 channel);
955 
999  sbyte4(*funcPtrPortFwdSessionOpenFail) (sbyte4 connectionInstance, ubyte *pInfo, ubyte4 infoLength, ubyte *pLanguage, ubyte4 languageLength, sbyte4 channel);
1000 
1035  void(*funcPtrPortForwardClosed) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen, ubyte4 channel);
1036 
1071  void(*funcPtrPortForwardEof) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen, ubyte4 channel);
1072 
1107  void(*funcPtrPortFwdReceivedData) (sbyte4 connectionInstance, enum sshcSessionTypes sessionEvent, ubyte *pMesg, ubyte4 mesgLen, ubyte4 channel );
1108 
1113  sbyte4(*funcPtrPortForwardConnect) (sbyte4 connectionInstance, enum pfType, sbyte *pHostAddr, ubyte4 hostPort, ubyte *pIgnoreRequest, ubyte4 channel );
1114 
1119  void(*funcPtrRemotePortReqStatus) (sbyte4 status, ubyte4 port );
1120 
1121 #endif /* __ENABLE_MOCANA_SSH_PORT_FORWARDING__ */
1122 
1123 #ifdef __ENABLE_MOCANA_SSH_AUTH_BANNER__
1124 
1160  sbyte4(* funcPtrDisplayBanner)(sbyte4 connectionInstance, ubyte *pBanner, ubyte4 length, ubyte *pMsgLanguageTag);
1161 #endif
1162 
1189  void(* funcPtrDisconnectMsg)(sbyte4 connectionInstance, ubyte4 reasonCode, ubyte *pMsg, ubyte4 msgLength, ubyte *pMsgLanguageTag);
1190 
1216  MSTATUS (*funcPtrSessionReKey) (sbyte4 connectionInstance, intBoolean initiatedByRemote);
1217 
1219 
1220 /*
1221  * SSHC_FuncPtrProtocolTest functions should return true iff the doProtocolXXX() loop
1222  * should exit/unwind.
1223  */
1224 
1225 
1226 /*------------------------------------------------------------------*/
1227 
1228 struct certStore;
1229 
1253 MOC_EXTERN sshClientSettings *SSHC_sshClientSettings(void);
1254 
1283 MOC_EXTERN sbyte4 SSHC_init(sbyte4 numClientConnections);
1284 
1310 MOC_EXTERN sbyte4 SSHC_shutdown(void);
1311 
1345 MOC_EXTERN sbyte4 SSHC_connect(TCP_SOCKET tempSocket, sbyte4 *pConnectionInstance, sbyte *pCommonName, struct certStore *pCertStore);
1346 
1379 MOC_EXTERN sbyte4 SSHC_useThisCipher(sbyte4 connectionInstance, ubyte *pCipher);
1380 
1414 MOC_EXTERN sbyte4 SSHC_useThisHmac(sbyte4 connectionInstance, ubyte *pHmac);
1415 
1444 MOC_EXTERN sbyte4 SSHC_negotiateConnection(sbyte4 connectionInstance);
1445 
1475 MOC_EXTERN sbyte4 SSHC_negotiateSession(sbyte4 connectionInstance);
1476 
1506 MOC_EXTERN sbyte4 SSHC_negotiateCloseChannel(sbyte4 connectionInstance, sbyte4 channelNumber);
1507 
1537 MOC_EXTERN sbyte4 SSHC_negotiateSubsystemSFTPChannelRequest(sbyte4 connectionInstance);
1538 
1568 MOC_EXTERN sbyte4 SSHC_negotiateSFTPHello(sbyte4 connectionInstance);
1569 
1599 MOC_EXTERN sbyte4 SSHC_negotiatePtyTerminalChannelRequest(sbyte4 connectionInstance);
1600 
1631 MOC_EXTERN sbyte4 SSHC_negotiateShellChannelRequest(sbyte4 connectionInstance);
1632 
1668 MOC_EXTERN sbyte4 SSHC_sendMessage(sbyte4 connectionInstance, ubyte *pBuffer, ubyte4 bufferSize, ubyte4 *pBytesSent);
1669 
1708 MOC_EXTERN sbyte4 SSHC_recvMessage(sbyte4 connectionInstance, sbyte4 *pMessageType, sbyte *pRetMessage, sbyte4 *pNumBytesReceived, ubyte4 timeout);
1709 
1742 MOC_EXTERN sbyte4 SSHC_setTerminalTextWindowSize(sbyte4 connectionInstance, ubyte4 width, ubyte4 height);
1743 
1772 MOC_EXTERN void SSHC_close(sbyte4 connectionInstance);
1773 
1806 MOC_EXTERN sbyte4 SSHC_initiateReKey(sbyte4 connectionInstance, ubyte4 msAllowToComply);
1807 
1842 MOC_EXTERN sbyte4 SSHC_numBytesTransmitted(sbyte4 connectionInstance, ubyte8 *pRetNumBytes);
1843 
1878 MOC_EXTERN sbyte4 SSHC_getCookie(sbyte4 connectionInstance, void **pRetCookie);
1879 
1913 MOC_EXTERN sbyte4 SSHC_setCookie(sbyte4 connectionInstance, void* cookie);
1914 
1915 /*------------------------------------------------------------------*/
1916 
1917 #ifdef __ENABLE_MOCANA_SSH_PORT_FORWARDING__
1918 
1950 MOC_EXTERN sbyte4 SSHC_lpfRegisterConnection( sbyte4 connectionInstance, ubyte4* pChannel);
1951 
1991 MOC_EXTERN sbyte4 SSHC_lpfStartConnection( sbyte4 connectionInstance, ubyte4 channel,
1992  ubyte* pConnectHost, ubyte4 connectPort,
1993  ubyte* pSrcHost, ubyte4 srcPort);
1994 
2026 MOC_EXTERN sbyte4 SSHC_lpfStopConnection( sbyte4 connectionInstance, ubyte4 channel);
2027 
2063 MOC_EXTERN sbyte4 SSHC_lpfSendMessage(sbyte4 connectionInstance, ubyte4 channel, sbyte *pBuffer, sbyte4 bufferSize, sbyte4 *pBytesSent);
2064 
2095 MOC_EXTERN sbyte4 SSHC_doProtocolProcessPortForwardSession(sbyte4 connectionInstance, intBoolean useTimeout, ubyte4 timeout);
2096 extern MSTATUS
2097 SSHC_startRemotePortForwarding(sbyte4 connectionInstance, sbyte *pBindAddr, ubyte4 bindPort, sbyte *pHostAddr, ubyte4 hostPort);
2098 extern MSTATUS
2099 SSHC_cancelRemotePortForwarding(sbyte4 connectionInstance, sbyte *pHostAddr, ubyte4 hostPort);
2100 #endif /*__ENABLE_MOCANA_SSH_PORT_FORWARDING__*/
2101 /*------------------------------------------------------------------*/
2102 
2103 #ifdef __ENABLE_MOCANA_SSH_FTP_CLIENT__
2104 
2143 MOC_EXTERN sbyte4 SSHC_openFile(sbyte4 connectionInstance, ubyte* pFName, ubyte4 pFNameLen, sbyte4 readOrWrite, sftpcFileHandleDescr **pp_retSftpFileHandleDescr);
2144 
2181 MOC_EXTERN sbyte4 SSHC_readFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr);
2182 
2218 MOC_EXTERN sbyte4 SSHC_writeFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr);
2219 
2253 MOC_EXTERN sbyte4 SSHC_closeFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr);
2254 
2290 MOC_EXTERN sbyte4 SSHC_openDirectory(sbyte4 connectionInstance, ubyte *pPath, ubyte4 pathLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr);
2291 
2331 MOC_EXTERN sbyte4 SSHC_readDirectory(sbyte4 connectionInstance, sftpcFileHandleDescr* p_sftpFileHandleDescr, ubyte **ppRetFilename, ubyte4 *pRetFilenameLen);
2332 
2365 MOC_EXTERN sbyte4 SSHC_closeDirectory(sbyte4 connectionInstance, sftpcFileHandleDescr* p_sftpFileHandleDescr);
2366 
2410 MOC_EXTERN void SSHC_sftpGetDirEntryFileSize(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileSize, intBoolean *pRetIsPresent);
2411 
2460 MOC_EXTERN void SSHC_sftpGetDirEntryFileType(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileType, intBoolean *pRetIsPresent);
2461 
2505 MOC_EXTERN void SSHC_sftpGetDirEntryFilePermission(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFilePermission, intBoolean *pRetIsPresent);
2506 
2538 MOC_EXTERN void SSHC_sftpSetCookie(sftpcFileHandleDescr *p_sftpFileHandleDescr, void* sftpCookie);
2539 
2570 MOC_EXTERN void* SSHC_sftpGetCookie(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2571 
2598 MOC_EXTERN sbyte4 SSHC_sftpRequestStatusCode(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2599 
2631 MOC_EXTERN sbyte4 SSHC_freeHandle(sbyte4 connectionInstance, sftpcFileHandleDescr** pp_sftpFileHandleDescr);
2632 
2664 MOC_EXTERN sbyte4 SSHC_freeFilename(sbyte4 connectionInstance, ubyte **ppFreeFilename);
2665 
2693 MOC_EXTERN sbyte4 SSHC_sftpReadLocation(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2694 
2723 MOC_EXTERN sbyte* SSHC_sftpReadBuffer(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2724 
2753 MOC_EXTERN sbyte4 SSHC_sftpReadBufferSize(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2754 
2786 MOC_EXTERN sbyte4 SSHC_sftpNumBytesRead(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2787 
2815 MOC_EXTERN sbyte4 SSHC_sftpWriteLocation(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2816 
2845 MOC_EXTERN sbyte* SSHC_sftpWriteBuffer(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2846 
2875 MOC_EXTERN sbyte4 SSHC_sftpWriteBufferSize(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2876 
2908 MOC_EXTERN sbyte4 SSHC_sftpNumBytesWritten(sftpcFileHandleDescr *p_sftpFileHandleDescr);
2909 
2947 MOC_EXTERN sbyte4 SSHC_getFileStat(sbyte4 connectionInstance, ubyte *pGetStatFile, ubyte4 getStatFileLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr);
2948 
2996 MOC_EXTERN sbyte4 SSHC_realpath(sbyte4 connectionInstance, ubyte *pRealpath, ubyte4 realpathLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr, ubyte **ppRetRealpath, ubyte4 *pRetRealpathLen);
2997 
3035 MOC_EXTERN sbyte4 SSHC_removeFile(sbyte4 connectionInstance, ubyte *pRemoveFileName, ubyte4 removeFileNameLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr);
3036 
3076 MOC_EXTERN sbyte4 SSHC_mkdir(sbyte4 connectionInstance, ubyte *pNewDirName, ubyte4 newDirNameLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr, void *pFuture);
3077 
3115 MOC_EXTERN sbyte4 SSHC_rmdir(sbyte4 connectionInstance, ubyte *pRemoveDirName, ubyte4 removeDirNameLen, sftpcFileHandleDescr** pp_sftpFileHandleDescr);
3116 
3155 MOC_EXTERN MSTATUS SSHC_generateServerAuthKeyFile(ubyte *pKeyBlob, ubyte4 keyBlobLen, ubyte **ppRetEncodedAuthKey, ubyte4 *pRetEncodedAuthKeyLen);
3156 
3190 MOC_EXTERN MSTATUS SSHC_parseServerAuthKeyFile(ubyte* pKeyFile, ubyte4 keyFileLen,
3191  AsymmetricKey *pAsymKey);
3192 
3227 MOC_EXTERN MSTATUS SSHC_parsePublicKeyBuffer(ubyte* pKeyFile, ubyte4 keyFileLen,
3228  AsymmetricKey *pAsymKey);
3229 
3259 MOC_EXTERN MSTATUS SSHC_freeGenerateServerAuthKeyFile(ubyte **ppFreeEncodedAuthKey);
3260 
3261 #endif
3262 
3263 #ifdef __cplusplus
3264 }
3265 #endif
3266 
3267 #endif /* __SSHC_HEADER__ */
MOC_EXTERN sbyte4 SSHC_removeFile(sbyte4 connectionInstance, ubyte *pRemoveFileName, ubyte4 removeFileNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
Delete a file from an SFTP server.
MOC_EXTERN sbyte4 SSHC_doProtocolProcessPortForwardSession(sbyte4 connectionInstance, intBoolean useTimeout, ubyte4 timeout)
MOC_EXTERN sbyte4 SSHC_lpfSendMessage(sbyte4 connectionInstance, ubyte4 channel, sbyte *pBuffer, sbyte4 bufferSize, sbyte4 *pBytesSent)
Send local port forwarding connection data from SSH client to SSH server.
MOC_EXTERN sbyte4 SSHC_setTerminalTextWindowSize(sbyte4 connectionInstance, ubyte4 width, ubyte4 height)
Set a terminal window's dimensions.
ubyte4 sshTimeOutServiceRequest
Number of milliseconds the client waits for a service request response before timing out...
Definition: sshc.h:375
MOC_EXTERN sbyte4 SSHC_sftpWriteLocation(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a file's current write location.
MOC_EXTERN sbyte * SSHC_sftpWriteBuffer(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a pointer to a file's write data buffer.
MOC_EXTERN sbyte4 SSHC_recvMessage(sbyte4 connectionInstance, sbyte4 *pMessageType, sbyte *pRetMessage, sbyte4 *pNumBytesReceived, ubyte4 timeout)
Get data from a connected server/client.
MOC_EXTERN sbyte4 SSHC_sftpNumBytesRead(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get the number of bytes read from an open file.
MOC_EXTERN sbyte4 SSHC_rmdir(sbyte4 connectionInstance, ubyte *pRemoveDirName, ubyte4 removeDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
Delete a directory from an SFTP server.
MOC_EXTERN sbyte4 SSHC_lpfStopConnection(sbyte4 connectionInstance, ubyte4 channel)
Stop port forwarding through the specified SSH connection.
MOC_EXTERN sbyte4 SSHC_mkdir(sbyte4 connectionInstance, ubyte *pNewDirName, ubyte4 newDirNameLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, void *pFuture)
Create a directory on an SFTP server.
MOC_EXTERN sbyte4 SSHC_readDirectory(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte **ppRetFilename, ubyte4 *pRetFilenameLen)
Get a directory's list of files (using a read directory request).
MOC_EXTERN sbyte4 SSHC_negotiateCloseChannel(sbyte4 connectionInstance, sbyte4 channelNumber)
Negotiate closing of a channel.
MOC_EXTERN sbyte4 SSHC_negotiateSubsystemSFTPChannelRequest(sbyte4 connectionInstance)
Send an SSH exec sftp command on the specified connection.
MOC_EXTERN void SSHC_sftpGetDirEntryFileType(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileType, intBoolean *pRetIsPresent)
Get a directory's type.
MOC_EXTERN sbyte4 SSHC_getFileStat(sbyte4 connectionInstance, ubyte *pGetStatFile, ubyte4 getStatFileLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
Get a file's statistics from an SFTP server.
MOC_EXTERN void SSHC_close(sbyte4 connectionInstance)
Close an SSH session and releases all its resources.
MOC_EXTERN sbyte4 SSHC_closeDirectory(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr)
Close a directory on an SFTP server.
MOC_EXTERN sbyte4 SSHC_initiateReKey(sbyte4 connectionInstance, ubyte4 msAllowToComply)
Initiate an SSH re-key operation.
MOC_EXTERN sbyte4 SSHC_sftpReadLocation(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a file's current read location.
sbyte4 sshMaxConnections
Maximum number of connections to this client.
Definition: sshc.h:335
MOC_EXTERN sbyte4 SSHC_useThisHmac(sbyte4 connectionInstance, ubyte *pHmac)
Set an SSH connection's HMAC.
MOC_EXTERN sbyte4 SSHC_readFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr)
Read a file on an SFTP server.
MOC_EXTERN sbyte4 SSHC_realpath(sbyte4 connectionInstance, ubyte *pRealpath, ubyte4 realpathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr, ubyte **ppRetRealpath, ubyte4 *pRetRealpathLen)
Get the fully-qualified directory path of an an SSH Client's virtual directory.
MOC_EXTERN sbyte4 SSHC_lpfRegisterConnection(sbyte4 connectionInstance, ubyte4 *pChannel)
Register the port number on which to listen for port forwarding messages from the SSH server...
MOC_EXTERN sbyte4 SSHC_openFile(sbyte4 connectionInstance, ubyte *pFName, ubyte4 pFNameLen, sbyte4 readOrWrite, sftpcFileHandleDescr **pp_retSftpFileHandleDescr)
Open a file on an SFTP server.
MOC_EXTERN MSTATUS SSHC_parsePublicKeyBuffer(ubyte *pKeyFile, ubyte4 keyFileLen, AsymmetricKey *pAsymKey)
Parses an public key and generates an AsymmetricKey object.
Definition: ssh.h:263
MOC_EXTERN MSTATUS SSHC_freeGenerateServerAuthKeyFile(ubyte **ppFreeEncodedAuthKey)
Release an authentication key's memory.
ubyte4 sshMaxAuthAttempts
Number of authentication tries allowed before the connection is said to have failed.
Definition: sshc.h:343
MOC_EXTERN sbyte4 SSHC_setCookie(sbyte4 connectionInstance, void *cookie)
Save a cookie containing custom information.
NanoSSH Client SFTP file handle descriptor.
Definition: sshc.h:217
MOC_EXTERN sbyte4 SSHC_useThisCipher(sbyte4 connectionInstance, ubyte *pCipher)
Set an SSH connection's cipher.
MOC_EXTERN sbyte4 SSHC_freeFilename(sbyte4 connectionInstance, ubyte **ppFreeFilename)
Release memory used to store a filename.
ubyte4 sshTimeOutDefaultOpenState
Number of milliseconds before timing out for the client to make a request (such as open a shell) afte...
Definition: sshc.h:391
MOC_EXTERN sbyte4 SSHC_sftpRequestStatusCode(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a file's SFTP operation status.
MOC_EXTERN sbyte4 SSHC_lpfStartConnection(sbyte4 connectionInstance, ubyte4 channel, ubyte *pConnectHost, ubyte4 connectPort, ubyte *pSrcHost, ubyte4 srcPort)
Start a port forwarding session.
MOC_EXTERN void SSHC_sftpSetCookie(sftpcFileHandleDescr *p_sftpFileHandleDescr, void *sftpCookie)
Set a file's cookie value (custom information).
MOC_EXTERN sbyte4 SSHC_numBytesTransmitted(sbyte4 connectionInstance, ubyte8 *pRetNumBytes)
Get the number of bytes sent and received through a given connectionInstance.
MOC_EXTERN sbyte4 SSHC_negotiateConnection(sbyte4 connectionInstance)
Authenticate a server (which establishes a secure connection).
MOC_EXTERN sbyte4 SSHC_closeFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr)
Close a file on an SFTP server.
MOC_EXTERN MSTATUS SSHC_generateServerAuthKeyFile(ubyte *pKeyBlob, ubyte4 keyBlobLen, ubyte **ppRetEncodedAuthKey, ubyte4 *pRetEncodedAuthKeyLen)
Generate an exportable public key for an internal public key BLOB.
MOC_EXTERN sbyte4 SSHC_sftpReadBufferSize(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get the number of bytes in a file's read buffer.
MOC_EXTERN void SSHC_sftpGetDirEntryFilePermission(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFilePermission, intBoolean *pRetIsPresent)
Determine whether a directory's file permission flag is set.
ubyte4 trustedResponderCount
(field added after 5.3.1...)
Definition: sshc.h:397
MOC_EXTERN sbyte4 SSHC_shutdown(void)
Release memory initialized by SSHC_init().
MOC_EXTERN sbyte * SSHC_sftpReadBuffer(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a pointer to a file's read data buffer.
Definition: ssh.h:245
MOC_EXTERN sbyte4 SSHC_sendMessage(sbyte4 connectionInstance, ubyte *pBuffer, ubyte4 bufferSize, ubyte4 *pBytesSent)
Send data to a server.
MOC_EXTERN sbyte4 SSHC_getCookie(sbyte4 connectionInstance, void **pRetCookie)
Get a connection's cookie containing custom (application-specific) information.
ubyte4 sshTimeOutNewKeys
Number of milliseconds the client waits for new keys before timing out.
Definition: sshc.h:367
MOC_EXTERN MSTATUS SSHC_parseServerAuthKeyFile(ubyte *pKeyFile, ubyte4 keyFileLen, AsymmetricKey *pAsymKey)
Parses an exportable public key and generates an AsymmetricKey object.
MOC_EXTERN sbyte4 SSHC_negotiateSFTPHello(sbyte4 connectionInstance)
Start a NanoSSH client SFTP session.
ubyte4 sshTimeOutKeyExchange
Number of milliseconds the client waits for a key exchange before timing out.
Definition: sshc.h:359
MOC_EXTERN sbyte4 SSHC_sftpNumBytesWritten(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get the number of bytes written to an open file.
MOC_EXTERN sbyte4 SSHC_sftpWriteBufferSize(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get the number of bytes in a file's write buffer.
MOC_EXTERN sshClientSettings * SSHC_sshClientSettings(void)
Get a pointer to the session's NanoSSH Client settings.
MOC_EXTERN sbyte4 SSHC_negotiatePtyTerminalChannelRequest(sbyte4 connectionInstance)
Send an SSH PTY command on the specified connection.
Definition: sshc.h:190
MOC_EXTERN sbyte4 SSHC_init(sbyte4 numClientConnections)
Initialize NanoSSH client internal structures.
MOC_EXTERN sbyte4 SSHC_negotiateShellChannelRequest(sbyte4 connectionInstance)
Send an SSH shell command on the specified connection.
Definition: ssh.h:274
MOC_EXTERN void SSHC_sftpGetDirEntryFileSize(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr, ubyte4 *pRetFileSize, intBoolean *pRetIsPresent)
Get a directory's size (number of bytes).
MOC_EXTERN void * SSHC_sftpGetCookie(sftpcFileHandleDescr *p_sftpFileHandleDescr)
Get a file's cookie value.
Definition: ssh.h:233
ubyte4 sshTimeOutOpen
Number of milliseconds the client waits for an open session response before timing out...
Definition: sshc.h:351
MOC_EXTERN sbyte4 SSHC_negotiateSession(sbyte4 connectionInstance)
Negotiate a connection (the client is authenticated by the server).
ubyte4 sshTimeOutAuthentication
Number of milliseconds the client waits for an authentication response before timing out...
Definition: sshc.h:383
MOC_EXTERN sbyte4 SSHC_openDirectory(sbyte4 connectionInstance, ubyte *pPath, ubyte4 pathLen, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
MOC_EXTERN sbyte4 SSHC_writeFile(sbyte4 connectionInstance, sftpcFileHandleDescr *p_sftpFileHandleDescr)
Write a file to an SFTP server.
Configuration settings and callback function pointers for SSH clients.
Definition: sshc.h:329
MOC_EXTERN sbyte4 SSHC_connect(TCP_SOCKET tempSocket, sbyte4 *pConnectionInstance, sbyte *pCommonName, struct certStore *pCertStore)
Create a secure SSH connection with a remote server.
MOC_EXTERN sbyte4 SSHC_freeHandle(sbyte4 connectionInstance, sftpcFileHandleDescr **pp_sftpFileHandleDescr)
Release (free) memory used to store a file/directory descriptor handle.