Secure Shell (SSH) More...
#include "ssh/ssh.h"
#include "ssh/ssh_algorithms.h"
#include "ssh/ssh_channel.h"
#include "ssh/ssh_key_import.h"
#include "ssh/ssh_cert_import.h"
#include "ssh/ssh_misc.h"
#include "pkix/pem_import.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SSH_TRACE_LEVEL |
Functions | |
error_t | sshInit (SshContext *context, SshConnection *connections, uint_t numConnections, SshChannel *channels, uint_t numChannels) |
SSH context initialization. More... | |
error_t | sshSetOperationMode (SshContext *context, SshOperationMode mode) |
Set operation mode (client or server) More... | |
error_t | sshSetPrng (SshContext *context, const PrngAlgo *prngAlgo, void *prngContext) |
Set the pseudo-random number generator to be used. More... | |
error_t | sshSetUsername (SshContext *context, const char_t *username) |
Set the user name to be used for authentication. More... | |
error_t | sshSetPassword (SshContext *context, const char_t *password) |
Set the password to be used for authentication. More... | |
error_t | sshRegisterHostKeyVerifyCallback (SshContext *context, SshHostKeyVerifyCallback callback) |
Register host key verification callback function. More... | |
error_t | sshRegisterCertVerifyCallback (SshContext *context, SshCertVerifyCallback callback) |
Register certificate verification callback function. More... | |
error_t | sshRegisterCaPublicKeyVerifyCallback (SshContext *context, SshCaPublicKeyVerifyCallback callback) |
Register CA public key verification callback function. More... | |
error_t | sshRegisterPublicKeyAuthCallback (SshContext *context, SshPublicKeyAuthCallback callback) |
Register public key authentication callback function. More... | |
error_t | sshRegisterCertAuthCallback (SshContext *context, SshCertAuthCallback callback) |
Register certificate authentication callback function. More... | |
error_t | sshRegisterPasswordAuthCallback (SshContext *context, SshPasswordAuthCallback callback) |
Register password authentication callback function. More... | |
error_t | sshRegisterPasswordChangeCallback (SshContext *context, SshPasswordChangeCallback callback) |
Register password change callback function. More... | |
error_t | sshRegisterSignGenCallback (SshContext *context, SshSignGenCallback callback) |
Register signature generation callback function. More... | |
error_t | sshRegisterSignVerifyCallback (SshContext *context, SshSignVerifyCallback callback) |
Register signature verification callback function. More... | |
error_t | sshRegisterEcdhKeyPairGenCallback (SshContext *context, SshEcdhKeyPairGenCallback callback) |
Register ECDH key pair generation callback function. More... | |
error_t | sshRegisterEcdhSharedSecretCalcCallback (SshContext *context, SshEcdhSharedSecretCalcCallback callback) |
Register ECDH shared secret calculation callback function. More... | |
error_t | sshRegisterGlobalRequestCallback (SshContext *context, SshGlobalReqCallback callback, void *param) |
Register global request callback function. More... | |
error_t | sshUnregisterGlobalRequestCallback (SshContext *context, SshGlobalReqCallback callback) |
Unregister global request callback function. More... | |
error_t | sshRegisterChannelRequestCallback (SshContext *context, SshChannelReqCallback callback, void *param) |
Register channel request callback function. More... | |
error_t | sshUnregisterChannelRequestCallback (SshContext *context, SshChannelReqCallback callback) |
Unregister channel request callback function. More... | |
error_t | sshRegisterChannelOpenCallback (SshContext *context, SshChannelOpenCallback callback, void *param) |
Register channel open callback function. More... | |
error_t | sshUnregisterChannelOpenCallback (SshContext *context, SshChannelOpenCallback callback) |
Unregister channel open callback function. More... | |
error_t | sshRegisterConnectionOpenCallback (SshContext *context, SshConnectionOpenCallback callback, void *param) |
Register connection open callback function. More... | |
error_t | sshUnregisterConnectionOpenCallback (SshContext *context, SshConnectionOpenCallback callback) |
Unregister connection open callback function. More... | |
error_t | sshRegisterConnectionCloseCallback (SshContext *context, SshConnectionCloseCallback callback, void *param) |
Register connection close callback function. More... | |
error_t | sshUnregisterConnectionCloseCallback (SshContext *context, SshConnectionCloseCallback callback) |
Unregister connection close callback function. More... | |
error_t | sshRegisterKeyLogCallback (SshContext *context, SshKeyLogCallback callback) |
Register key logging callback function (for debugging purpose only) More... | |
error_t | sshLoadRsaKey (SshContext *context, uint_t index, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password) |
Load transient RSA key (for RSA key exchange) More... | |
error_t | sshUnloadRsaKey (SshContext *context, uint_t index) |
Unload transient RSA key (for RSA key exchange) More... | |
error_t | sshLoadDhGexGroup (SshContext *context, uint_t index, const char_t *dhParams, size_t dhParamsLen) |
Load Diffie-Hellman group. More... | |
error_t | sshUnloadDhGexGroup (SshContext *context, uint_t index) |
Unload Diffie-Hellman group. More... | |
error_t | sshLoadHostKey (SshContext *context, uint_t index, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password) |
Load entity's host key. More... | |
error_t | sshUnloadHostKey (SshContext *context, uint_t index) |
Unload entity's host key. More... | |
error_t | sshLoadCertificate (SshContext *context, uint_t index, const char_t *cert, size_t certLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password) |
Load entity's certificate. More... | |
error_t | sshUnloadCertificate (SshContext *context, uint_t index) |
Unload entity's certificate. More... | |
error_t | sshSetPasswordChangePrompt (SshConnection *connection, const char_t *prompt) |
Set password change prompt message. More... | |
SshChannel * | sshCreateChannel (SshConnection *connection) |
Create a new SSH channel. More... | |
error_t | sshSetChannelTimeout (SshChannel *channel, systime_t timeout) |
Set timeout for read/write operations. More... | |
error_t | sshWriteChannel (SshChannel *channel, const void *data, size_t length, size_t *written, uint_t flags) |
Write data to the specified channel. More... | |
error_t | sshReadChannel (SshChannel *channel, void *data, size_t size, size_t *received, uint_t flags) |
Receive data from the specified channel. More... | |
error_t | sshPollChannels (SshChannelEventDesc *eventDesc, uint_t size, OsEvent *extEvent, systime_t timeout) |
Wait for one of a set of channels to become ready to perform I/O. More... | |
error_t | sshCloseChannel (SshChannel *channel) |
Close channel. More... | |
void | sshDeleteChannel (SshChannel *channel) |
Release channel. More... | |
void | sshDeinit (SshContext *context) |
Release SSH context. More... | |
Detailed Description
Secure Shell (SSH)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneSSH Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file ssh.c.
Macro Definition Documentation
◆ TRACE_LEVEL
Function Documentation
◆ sshCloseChannel()
error_t sshCloseChannel | ( | SshChannel * | channel | ) |
◆ sshCreateChannel()
SshChannel* sshCreateChannel | ( | SshConnection * | connection | ) |
◆ sshDeinit()
void sshDeinit | ( | SshContext * | context | ) |
◆ sshDeleteChannel()
void sshDeleteChannel | ( | SshChannel * | channel | ) |
◆ sshInit()
error_t sshInit | ( | SshContext * | context, |
SshConnection * | connections, | ||
uint_t | numConnections, | ||
SshChannel * | channels, | ||
uint_t | numChannels | ||
) |
◆ sshLoadCertificate()
error_t sshLoadCertificate | ( | SshContext * | context, |
uint_t | index, | ||
const char_t * | cert, | ||
size_t | certLen, | ||
const char_t * | privateKey, | ||
size_t | privateKeyLen, | ||
const char_t * | password | ||
) |
Load entity's certificate.
- Parameters
-
[in] context Pointer to the SSH context [in] index Zero-based index identifying a slot [in] cert Certificate (OpenSSH format). This parameter is taken as reference [in] certLen Length of the certificate [in] privateKey Private key (PEM or OpenSSH format). This parameter is taken as reference [in] privateKeyLen Length of the private key [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted
- Returns
- Error code
◆ sshLoadDhGexGroup()
error_t sshLoadDhGexGroup | ( | SshContext * | context, |
uint_t | index, | ||
const char_t * | dhParams, | ||
size_t | dhParamsLen | ||
) |
Load Diffie-Hellman group.
- Parameters
-
[in] context Pointer to the SSH context [in] index Zero-based index identifying a slot [in] dhParams Diffie-Hellman parameters (PEM format). This parameter is taken as reference [in] dhParamsLen Length of the Diffie-Hellman parameters
- Returns
- Error code
◆ sshLoadHostKey()
error_t sshLoadHostKey | ( | SshContext * | context, |
uint_t | index, | ||
const char_t * | publicKey, | ||
size_t | publicKeyLen, | ||
const char_t * | privateKey, | ||
size_t | privateKeyLen, | ||
const char_t * | password | ||
) |
Load entity's host key.
- Parameters
-
[in] context Pointer to the SSH context [in] index Zero-based index identifying a slot [in] publicKey Public key (PEM, SSH2 or OpenSSH format). This parameter is taken as reference [in] publicKeyLen Length of the public key [in] privateKey Private key (PEM or OpenSSH format). This parameter is taken as reference [in] privateKeyLen Length of the private key [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted
- Returns
- Error code
◆ sshLoadRsaKey()
error_t sshLoadRsaKey | ( | SshContext * | context, |
uint_t | index, | ||
const char_t * | publicKey, | ||
size_t | publicKeyLen, | ||
const char_t * | privateKey, | ||
size_t | privateKeyLen, | ||
const char_t * | password | ||
) |
Load transient RSA key (for RSA key exchange)
- Parameters
-
[in] context Pointer to the SSH context [in] index Zero-based index identifying a slot [in] publicKey RSA public key (PEM, SSH2 or OpenSSH format). This parameter is taken as reference [in] publicKeyLen Length of the RSA public key [in] privateKey RSA private key (PEM or OpenSSH format). This parameter is taken as reference [in] password NULL-terminated string containing the password. This parameter is required if the private key is encrypted [in] privateKeyLen Length of the RSA private key
- Returns
- Error code
◆ sshPollChannels()
error_t sshPollChannels | ( | SshChannelEventDesc * | eventDesc, |
uint_t | size, | ||
OsEvent * | extEvent, | ||
systime_t | timeout | ||
) |
Wait for one of a set of channels to become ready to perform I/O.
This function determines the status of one or more channels, waiting if necessary, to perform synchronous I/O
- Parameters
-
[in,out] eventDesc Set of entries specifying the events the user is interested in [in] size Number of entries in the descriptor set [in] extEvent External event that can abort the wait if necessary (optional) [in] timeout Maximum time to wait before returning
- Returns
- Error code
◆ sshReadChannel()
error_t sshReadChannel | ( | SshChannel * | channel, |
void * | data, | ||
size_t | size, | ||
size_t * | received, | ||
uint_t | flags | ||
) |
Receive data from the specified channel.
- Parameters
-
[in] channel SSH channel handle [out] data Buffer where to store the incoming data [in] size Maximum number of bytes that can be received [out] received Number of bytes that have been received [in] flags Set of flags that influences the behavior of this function
- Returns
- Error code
◆ sshRegisterCaPublicKeyVerifyCallback()
error_t sshRegisterCaPublicKeyVerifyCallback | ( | SshContext * | context, |
SshCaPublicKeyVerifyCallback | callback | ||
) |
◆ sshRegisterCertAuthCallback()
error_t sshRegisterCertAuthCallback | ( | SshContext * | context, |
SshCertAuthCallback | callback | ||
) |
◆ sshRegisterCertVerifyCallback()
error_t sshRegisterCertVerifyCallback | ( | SshContext * | context, |
SshCertVerifyCallback | callback | ||
) |
◆ sshRegisterChannelOpenCallback()
error_t sshRegisterChannelOpenCallback | ( | SshContext * | context, |
SshChannelOpenCallback | callback, | ||
void * | param | ||
) |
◆ sshRegisterChannelRequestCallback()
error_t sshRegisterChannelRequestCallback | ( | SshContext * | context, |
SshChannelReqCallback | callback, | ||
void * | param | ||
) |
◆ sshRegisterConnectionCloseCallback()
error_t sshRegisterConnectionCloseCallback | ( | SshContext * | context, |
SshConnectionCloseCallback | callback, | ||
void * | param | ||
) |
◆ sshRegisterConnectionOpenCallback()
error_t sshRegisterConnectionOpenCallback | ( | SshContext * | context, |
SshConnectionOpenCallback | callback, | ||
void * | param | ||
) |
◆ sshRegisterEcdhKeyPairGenCallback()
error_t sshRegisterEcdhKeyPairGenCallback | ( | SshContext * | context, |
SshEcdhKeyPairGenCallback | callback | ||
) |
◆ sshRegisterEcdhSharedSecretCalcCallback()
error_t sshRegisterEcdhSharedSecretCalcCallback | ( | SshContext * | context, |
SshEcdhSharedSecretCalcCallback | callback | ||
) |
◆ sshRegisterGlobalRequestCallback()
error_t sshRegisterGlobalRequestCallback | ( | SshContext * | context, |
SshGlobalReqCallback | callback, | ||
void * | param | ||
) |
◆ sshRegisterHostKeyVerifyCallback()
error_t sshRegisterHostKeyVerifyCallback | ( | SshContext * | context, |
SshHostKeyVerifyCallback | callback | ||
) |
◆ sshRegisterKeyLogCallback()
error_t sshRegisterKeyLogCallback | ( | SshContext * | context, |
SshKeyLogCallback | callback | ||
) |
◆ sshRegisterPasswordAuthCallback()
error_t sshRegisterPasswordAuthCallback | ( | SshContext * | context, |
SshPasswordAuthCallback | callback | ||
) |
◆ sshRegisterPasswordChangeCallback()
error_t sshRegisterPasswordChangeCallback | ( | SshContext * | context, |
SshPasswordChangeCallback | callback | ||
) |
◆ sshRegisterPublicKeyAuthCallback()
error_t sshRegisterPublicKeyAuthCallback | ( | SshContext * | context, |
SshPublicKeyAuthCallback | callback | ||
) |
◆ sshRegisterSignGenCallback()
error_t sshRegisterSignGenCallback | ( | SshContext * | context, |
SshSignGenCallback | callback | ||
) |
◆ sshRegisterSignVerifyCallback()
error_t sshRegisterSignVerifyCallback | ( | SshContext * | context, |
SshSignVerifyCallback | callback | ||
) |
◆ sshSetChannelTimeout()
error_t sshSetChannelTimeout | ( | SshChannel * | channel, |
systime_t | timeout | ||
) |
◆ sshSetOperationMode()
error_t sshSetOperationMode | ( | SshContext * | context, |
SshOperationMode | mode | ||
) |
◆ sshSetPassword()
error_t sshSetPassword | ( | SshContext * | context, |
const char_t * | password | ||
) |
◆ sshSetPasswordChangePrompt()
error_t sshSetPasswordChangePrompt | ( | SshConnection * | connection, |
const char_t * | prompt | ||
) |
◆ sshSetPrng()
error_t sshSetPrng | ( | SshContext * | context, |
const PrngAlgo * | prngAlgo, | ||
void * | prngContext | ||
) |
◆ sshSetUsername()
error_t sshSetUsername | ( | SshContext * | context, |
const char_t * | username | ||
) |
◆ sshUnloadCertificate()
error_t sshUnloadCertificate | ( | SshContext * | context, |
uint_t | index | ||
) |
◆ sshUnloadDhGexGroup()
error_t sshUnloadDhGexGroup | ( | SshContext * | context, |
uint_t | index | ||
) |
◆ sshUnloadHostKey()
error_t sshUnloadHostKey | ( | SshContext * | context, |
uint_t | index | ||
) |
◆ sshUnloadRsaKey()
error_t sshUnloadRsaKey | ( | SshContext * | context, |
uint_t | index | ||
) |
◆ sshUnregisterChannelOpenCallback()
error_t sshUnregisterChannelOpenCallback | ( | SshContext * | context, |
SshChannelOpenCallback | callback | ||
) |
◆ sshUnregisterChannelRequestCallback()
error_t sshUnregisterChannelRequestCallback | ( | SshContext * | context, |
SshChannelReqCallback | callback | ||
) |
◆ sshUnregisterConnectionCloseCallback()
error_t sshUnregisterConnectionCloseCallback | ( | SshContext * | context, |
SshConnectionCloseCallback | callback | ||
) |
◆ sshUnregisterConnectionOpenCallback()
error_t sshUnregisterConnectionOpenCallback | ( | SshContext * | context, |
SshConnectionOpenCallback | callback | ||
) |
◆ sshUnregisterGlobalRequestCallback()
error_t sshUnregisterGlobalRequestCallback | ( | SshContext * | context, |
SshGlobalReqCallback | callback | ||
) |
◆ sshWriteChannel()
error_t sshWriteChannel | ( | SshChannel * | channel, |
const void * | data, | ||
size_t | length, | ||
size_t * | written, | ||
uint_t | flags | ||
) |
Write data to the specified channel.
- Parameters
-
[in] channel SSH channel handle [in] data Pointer to the buffer containing the data to be transmitted [in] length Number of data bytes to send [out] written Actual number of bytes written (optional parameter) [in] flags Set of flags that influences the behavior of this function
- Returns
- Error code