TrustCore SDK NanoSSH API reference  version 7.0
ssh_known_hosts.h
1 /*
2  * ssh_known_hosts.h
3  *
4  * Mocana Initialization Header
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
10 
11 
12 /*------------------------------------------------------------------*/
13 
14 #ifndef __SSH_KNOWN_HOST_HEADER__
15 #define __SSH_KNOWN_HOST_HEADER__
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 
22 #ifdef __ENABLE_MOCANA_SSH_KNOWN_HOSTS__
23 
84 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_addKnownHostsEntry(ubyte** ppBuffer, ubyte4* bufferLen, ubyte * hostName, ubyte * pKey, sbyte4 pKeyLen, ubyte4 * pRetVal);
85 
124 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_checkHostEntryExists(ubyte* pBuffer, ubyte4 bufferLen, ubyte * hostName, ubyte4* pIndex, ubyte4 * pRetVal);
125 
166 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_getEntries(sbyte4 *pEntries);
167 
168 /*
169 @brief Read a known-hosts file and store it in a given known-hosts buffer.
170 
171 @details This function reads a known-hosts file and stores its contents in
172  a given known-hosts buffer. There is no validity checking on the
173  file's contents; they are simply stored in the buffer.
174 
175 @note To avoid memory leaks, be sure to make a subsequent call to
176  MOCANA_freeReadFile().
177 
178 @ingroup func_ssh_server_known_hosts
179 
180 @since 5.4
181 @version 5.4 and later
182 
183 @flags
184 To enable this function, the following flags must be defined in moptions.h:
185 + \c \__ENABLE_SSH_KNOWN_HOSTS__
186 + \c \__ENABLE_MOCANA_IPV6__
187 
188 @inc_file ssh_known_hosts.h
189 
190 @param filename Name of file to read.
191 @param ppBuffer Pointer to a buffer in which to store the file's contents.
192 @param pBufferLen On return, number of bytes stored in the buffer, \p ppBuffer.
193 
194 @return \c OK (0) if successful; otherwise a negative number error code
195  definition from merrors.h. To retrieve a string containing an
196  English text error identifier corresponding to the function's
197  returned error status, use the \c DISPLAY_ERROR macro.
198 
199 @remark This is a convenience function provided for your application's use;
200  it is not used by Mocana SoT Platform code.
201 
202 @funcdoc ssh_known_hosts.c
203 */
204 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_readFile(sbyte* filename, ubyte** ppBuffer, ubyte4* pBufferLen);
205 
252 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_removeKnownHostsEntry(ubyte** ppBuffer, ubyte4* pBufferLen, ubyte * hostName, ubyte4 *passed_index, ubyte4* pRetVal);
253 
289 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_retrieveKeyForKnownHostsEntry(ubyte* pBuffer, ubyte4 bufferLen, ubyte * hostName, ubyte ** ppKey, ubyte4 * pKeyLen, ubyte4 * pRetVal);
290 
327 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_updateEntries(ubyte * pBuffer, ubyte4 bufferLen);
328 
370 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_updateKnownHostsEntry(ubyte** ppBuffer, ubyte4* pBufferLen, ubyte * hostName, ubyte * pKey, sbyte4 pKeyLen, ubyte4 * pRetVal);
371 
408 MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_verifyKnownHostKeyEntry(ubyte* pBuffer, ubyte4 bufferLen, ubyte* hostName, ubyte * pKey, sbyte4 pKeyLen, ubyte4 * pRetVal);
409 #endif
410 
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 
416 #endif /* __SSH_KNOWN_HOST_HEADER__ */
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_checkHostEntryExists(ubyte *pBuffer, ubyte4 bufferLen, ubyte *hostName, ubyte4 *pIndex, ubyte4 *pRetVal)
Determine whether a host entry already exists in a given known-host buffer.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_verifyKnownHostKeyEntry(ubyte *pBuffer, ubyte4 bufferLen, ubyte *hostName, ubyte *pKey, sbyte4 pKeyLen, ubyte4 *pRetVal)
Verify that a given key matches a given host's key in the given known-hosts buffer.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_addKnownHostsEntry(ubyte **ppBuffer, ubyte4 *bufferLen, ubyte *hostName, ubyte *pKey, sbyte4 pKeyLen, ubyte4 *pRetVal)
Add a host entry to a NanoSSH known-host list.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_retrieveKeyForKnownHostsEntry(ubyte *pBuffer, ubyte4 bufferLen, ubyte *hostName, ubyte **ppKey, ubyte4 *pKeyLen, ubyte4 *pRetVal)
Get the key that corresponds to a given host name.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_removeKnownHostsEntry(ubyte **ppBuffer, ubyte4 *pBufferLen, ubyte *hostName, ubyte4 *passed_index, ubyte4 *pRetVal)
Remove a host entry from a given known-hosts buffer, if found.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_getEntries(sbyte4 *pEntries)
Get the number of entries in the NanoSSH known-hosts list.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_updateKnownHostsEntry(ubyte **ppBuffer, ubyte4 *pBufferLen, ubyte *hostName, ubyte *pKey, sbyte4 pKeyLen, ubyte4 *pRetVal)
Update or add a host entry to a NanoSSH known-host list.
MOC_EXTERN MSTATUS SSH_KNOWN_HOSTS_updateEntries(ubyte *pBuffer, ubyte4 bufferLen)
Update the global known-hosts entries count, based on a given known-hosts buffer. ...