ssh_server.h File Reference

SSH server. More...

#include "ssh/ssh.h"

Go to the source code of this file.

Data Structures

struct  SshServerSettings
 SSH server settings. More...
 
struct  SshServerContext
 SSH server context. More...
 

Macros

#define SSH_SERVER_STACK_SIZE   750
 
#define SSH_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL
 
#define SSH_SERVER_TIMEOUT   60000
 
#define SSH_SERVER_TICK_INTERVAL   1000
 

Functions

void sshServerGetDefaultSettings (SshServerSettings *settings)
 Initialize settings with default values. More...
 
error_t sshServerInit (SshServerContext *context, const SshServerSettings *settings)
 Initialize SSH server context. More...
 
error_t sshServerRegisterGlobalRequestCallback (SshServerContext *context, SshGlobalReqCallback callback, void *param)
 Register global request callback function. More...
 
error_t sshServerUnregisterGlobalRequestCallback (SshServerContext *context, SshGlobalReqCallback callback)
 Unregister global request callback function. More...
 
error_t sshServerRegisterChannelRequestCallback (SshServerContext *context, SshChannelReqCallback callback, void *param)
 Register channel request callback function. More...
 
error_t sshServerUnregisterChannelRequestCallback (SshServerContext *context, SshChannelReqCallback callback)
 Unregister channel request callback function. More...
 
error_t sshServerRegisterChannelOpenCallback (SshServerContext *context, SshChannelOpenCallback callback, void *param)
 Register channel open callback function. More...
 
error_t sshServerUnregisterChannelOpenCallback (SshServerContext *context, SshChannelOpenCallback callback)
 Unregister channel open callback function. More...
 
error_t sshServerRegisterConnectionOpenCallback (SshServerContext *context, SshConnectionOpenCallback callback, void *param)
 Register connection open callback function. More...
 
error_t sshServerUnregisterConnectionOpenCallback (SshServerContext *context, SshConnectionOpenCallback callback)
 Unregister connection open callback function. More...
 
error_t sshServerRegisterConnectionCloseCallback (SshServerContext *context, SshConnectionCloseCallback callback, void *param)
 Register connection close callback function. More...
 
error_t sshServerUnregisterConnectionCloseCallback (SshServerContext *context, SshConnectionCloseCallback callback)
 Unregister connection close callback function. More...
 
error_t sshServerLoadRsaKey (SshServerContext *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 sshServerUnloadRsaKey (SshServerContext *context, uint_t index)
 Unload transient RSA key (for RSA key exchange) More...
 
error_t sshServerLoadDhGexGroup (SshServerContext *context, uint_t index, const char_t *dhParams, size_t dhParamsLen)
 Load Diffie-Hellman group. More...
 
error_t sshServerUnloadDhGexGroup (SshServerContext *context, uint_t index)
 Unload Diffie-Hellman group. More...
 
error_t sshServerLoadHostKey (SshServerContext *context, uint_t index, const char_t *publicKey, size_t publicKeyLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password)
 Load server's host key. More...
 
error_t sshServerUnloadHostKey (SshServerContext *context, uint_t index)
 Unload server's host key. More...
 
error_t sshServerLoadCertificate (SshServerContext *context, uint_t index, const char_t *cert, size_t certLen, const char_t *privateKey, size_t privateKeyLen, const char_t *password)
 Load server's certificate. More...
 
error_t sshServerUnloadCertificate (SshServerContext *context, uint_t index)
 Unload server's certificate. More...
 
error_t sshServerStart (SshServerContext *context)
 Start SSH server. More...
 
error_t sshServerStop (SshServerContext *context)
 Stop SSH server. More...
 
void sshServerTask (SshServerContext *context)
 SSH server task. More...
 
void sshServerDeinit (SshServerContext *context)
 Release SSH server context. More...
 

Detailed Description

SSH server.

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file ssh_server.h.

Macro Definition Documentation

◆ SSH_SERVER_PRIORITY

#define SSH_SERVER_PRIORITY   OS_TASK_PRIORITY_NORMAL

Definition at line 46 of file ssh_server.h.

◆ SSH_SERVER_STACK_SIZE

#define SSH_SERVER_STACK_SIZE   750

Definition at line 39 of file ssh_server.h.

◆ SSH_SERVER_TICK_INTERVAL

#define SSH_SERVER_TICK_INTERVAL   1000

Definition at line 58 of file ssh_server.h.

◆ SSH_SERVER_TIMEOUT

#define SSH_SERVER_TIMEOUT   60000

Definition at line 51 of file ssh_server.h.

Function Documentation

◆ sshServerDeinit()

void sshServerDeinit ( SshServerContext context)

Release SSH server context.

Parameters
[in]contextPointer to the SSH server context

Definition at line 898 of file ssh_server.c.

◆ sshServerGetDefaultSettings()

void sshServerGetDefaultSettings ( SshServerSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains SSH server settings

Definition at line 50 of file ssh_server.c.

◆ sshServerInit()

error_t sshServerInit ( SshServerContext context,
const SshServerSettings settings 
)

Initialize SSH server context.

Parameters
[in]contextPointer to the SSH server context
[in]settingsSSH server specific settings
Returns
Error code

Definition at line 124 of file ssh_server.c.

◆ sshServerLoadCertificate()

error_t sshServerLoadCertificate ( SshServerContext context,
uint_t  index,
const char_t cert,
size_t  certLen,
const char_t privateKey,
size_t  privateKeyLen,
const char_t password 
)

Load server's certificate.

Parameters
[in]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
[in]certCertificate (OpenSSH format). This parameter is taken as reference
[in]certLenLength of the certificate
[in]privateKeyPrivate key (PEM or OpenSSH format). This parameter is taken as reference
[in]privateKeyLenLength of the private key
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
Returns
Error code

Definition at line 606 of file ssh_server.c.

◆ sshServerLoadDhGexGroup()

error_t sshServerLoadDhGexGroup ( SshServerContext context,
uint_t  index,
const char_t dhParams,
size_t  dhParamsLen 
)

Load Diffie-Hellman group.

Parameters
[in]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
[in]dhParamsDiffie-Hellman parameters (PEM format). This parameter is taken as reference
[in]dhParamsLenLength of the Diffie-Hellman parameters
Returns
Error code

Definition at line 529 of file ssh_server.c.

◆ sshServerLoadHostKey()

error_t sshServerLoadHostKey ( SshServerContext context,
uint_t  index,
const char_t publicKey,
size_t  publicKeyLen,
const char_t privateKey,
size_t  privateKeyLen,
const char_t password 
)

Load server's host key.

Parameters
[in]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
[in]publicKeyPublic key (PEM, SSH2 or OpenSSH format). This parameter is taken as reference
[in]publicKeyLenLength of the public key
[in]privateKeyPrivate key (PEM or OpenSSH format). This parameter is taken as reference
[in]privateKeyLenLength of the private key
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
Returns
Error code

Definition at line 567 of file ssh_server.c.

◆ sshServerLoadRsaKey()

error_t sshServerLoadRsaKey ( SshServerContext 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]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
[in]publicKeyRSA public key (PEM, SSH2 or OpenSSH format). This parameter is taken as reference
[in]publicKeyLenLength of the RSA public key
[in]privateKeyRSA private key (PEM or OpenSSH format). This parameter is taken as reference
[in]passwordNULL-terminated string containing the password. This parameter is required if the private key is encrypted
[in]privateKeyLenLength of the RSA private key
Returns
Error code

Definition at line 495 of file ssh_server.c.

◆ sshServerRegisterChannelOpenCallback()

error_t sshServerRegisterChannelOpenCallback ( SshServerContext context,
SshChannelOpenCallback  callback,
void *  param 
)

Register channel open callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackChannel open callback function
[in]paramAn opaque pointer passed to the callback function
Returns
Error code

Definition at line 392 of file ssh_server.c.

◆ sshServerRegisterChannelRequestCallback()

error_t sshServerRegisterChannelRequestCallback ( SshServerContext context,
SshChannelReqCallback  callback,
void *  param 
)

Register channel request callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackChannel request callback function
[in]paramAn opaque pointer passed to the callback function
Returns
Error code

Definition at line 360 of file ssh_server.c.

◆ sshServerRegisterConnectionCloseCallback()

error_t sshServerRegisterConnectionCloseCallback ( SshServerContext context,
SshConnectionCloseCallback  callback,
void *  param 
)

Register connection close callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackConnection close callback function
[in]paramAn opaque pointer passed to the callback function
Returns
Error code

Definition at line 456 of file ssh_server.c.

◆ sshServerRegisterConnectionOpenCallback()

error_t sshServerRegisterConnectionOpenCallback ( SshServerContext context,
SshConnectionOpenCallback  callback,
void *  param 
)

Register connection open callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackConnection open callback function
[in]paramAn opaque pointer passed to the callback function
Returns
Error code

Definition at line 424 of file ssh_server.c.

◆ sshServerRegisterGlobalRequestCallback()

error_t sshServerRegisterGlobalRequestCallback ( SshServerContext context,
SshGlobalReqCallback  callback,
void *  param 
)

Register global request callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackGlobal request callback function
[in]paramAn opaque pointer passed to the callback function
Returns
Error code

Definition at line 328 of file ssh_server.c.

◆ sshServerStart()

error_t sshServerStart ( SshServerContext context)

Start SSH server.

Parameters
[in]contextPointer to the SSH server context
Returns
Error code

Definition at line 646 of file ssh_server.c.

◆ sshServerStop()

error_t sshServerStop ( SshServerContext context)

Stop SSH server.

Parameters
[in]contextPointer to the SSH server context
Returns
Error code

Definition at line 741 of file ssh_server.c.

◆ sshServerTask()

void sshServerTask ( SshServerContext context)

SSH server task.

Parameters
[in]contextPointer to the SSH server context

Definition at line 792 of file ssh_server.c.

◆ sshServerUnloadCertificate()

error_t sshServerUnloadCertificate ( SshServerContext context,
uint_t  index 
)

Unload server's certificate.

Parameters
[in]indexZero-based index identifying a slot
[in]contextPointer to the SSH server context
Returns
Error code

Definition at line 628 of file ssh_server.c.

◆ sshServerUnloadDhGexGroup()

error_t sshServerUnloadDhGexGroup ( SshServerContext context,
uint_t  index 
)

Unload Diffie-Hellman group.

Parameters
[in]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
Returns
Error code

Definition at line 545 of file ssh_server.c.

◆ sshServerUnloadHostKey()

error_t sshServerUnloadHostKey ( SshServerContext context,
uint_t  index 
)

Unload server's host key.

Parameters
[in]indexZero-based index identifying a slot
[in]contextPointer to the SSH server context
Returns
Error code

Definition at line 584 of file ssh_server.c.

◆ sshServerUnloadRsaKey()

error_t sshServerUnloadRsaKey ( SshServerContext context,
uint_t  index 
)

Unload transient RSA key (for RSA key exchange)

Parameters
[in]contextPointer to the SSH server context
[in]indexZero-based index identifying a slot
Returns
Error code

Definition at line 512 of file ssh_server.c.

◆ sshServerUnregisterChannelOpenCallback()

error_t sshServerUnregisterChannelOpenCallback ( SshServerContext context,
SshChannelOpenCallback  callback 
)

Unregister channel open callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackPreviously registered callback function
Returns
Error code

Definition at line 408 of file ssh_server.c.

◆ sshServerUnregisterChannelRequestCallback()

error_t sshServerUnregisterChannelRequestCallback ( SshServerContext context,
SshChannelReqCallback  callback 
)

Unregister channel request callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackPreviously registered callback function
Returns
Error code

Definition at line 376 of file ssh_server.c.

◆ sshServerUnregisterConnectionCloseCallback()

error_t sshServerUnregisterConnectionCloseCallback ( SshServerContext context,
SshConnectionCloseCallback  callback 
)

Unregister connection close callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackPreviously registered callback function
Returns
Error code

Definition at line 472 of file ssh_server.c.

◆ sshServerUnregisterConnectionOpenCallback()

error_t sshServerUnregisterConnectionOpenCallback ( SshServerContext context,
SshConnectionOpenCallback  callback 
)

Unregister connection open callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackPreviously registered callback function
Returns
Error code

Definition at line 440 of file ssh_server.c.

◆ sshServerUnregisterGlobalRequestCallback()

error_t sshServerUnregisterGlobalRequestCallback ( SshServerContext context,
SshGlobalReqCallback  callback 
)

Unregister global request callback function.

Parameters
[in]contextPointer to the SSH server context
[in]callbackPreviously registered callback function
Returns
Error code

Definition at line 344 of file ssh_server.c.