ssh_kex_ecdh.c File Reference

ECDH key exchange. More...

#include "ssh/ssh.h"
#include "ssh/ssh_algorithms.h"
#include "ssh/ssh_transport.h"
#include "ssh/ssh_kex.h"
#include "ssh/ssh_kex_ecdh.h"
#include "ssh/ssh_packet.h"
#include "ssh/ssh_key_material.h"
#include "ssh/ssh_exchange_hash.h"
#include "ssh/ssh_key_verify.h"
#include "ssh/ssh_cert_verify.h"
#include "ssh/ssh_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   SSH_TRACE_LEVEL
 

Functions

error_t sshSendKexEcdhInit (SshConnection *connection)
 Send SSH_MSG_KEX_ECDH_INIT message. More...
 
error_t sshSendKexEcdhReply (SshConnection *connection)
 Send SSH_MSG_KEX_ECDH_REPLY message. More...
 
error_t sshFormatKexEcdhInit (SshConnection *connection, uint8_t *p, size_t *length)
 Format SSH_MSG_KEX_ECDH_INIT message. More...
 
error_t sshFormatKexEcdhReply (SshConnection *connection, uint8_t *p, size_t *length)
 Format SSH_MSG_KEX_ECDH_REPLY message. More...
 
error_t sshParseKexEcdhInit (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_KEX_ECDH_INIT message. More...
 
error_t sshParseKexEcdhReply (SshConnection *connection, const uint8_t *message, size_t length)
 Parse SSH_MSG_KEX_ECDH_REPLY message. More...
 
error_t sshParseKexEcdhMessage (SshConnection *connection, uint8_t type, const uint8_t *message, size_t length)
 Parse ECDH specific messages. More...
 
error_t sshLoadKexEcdhParams (EcDomainParameters *params, const char_t *kexAlgo)
 Load the EC parameters that match specified key exchange algorithm. More...
 
error_t sshGenerateEcdhKeyPair (SshConnection *connection)
 ECDH key pair generation. More...
 
error_t sshComputeEcdhSharedSecret (SshConnection *connection)
 ECDH shared secret calculation. More...
 
error_t sshDigestClientEcdhPublicKey (SshConnection *connection)
 Update exchange hash with client's ephemeral public key. More...
 

Detailed Description

ECDH key exchange.

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.4

Definition in file ssh_kex_ecdh.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   SSH_TRACE_LEVEL

Definition at line 32 of file ssh_kex_ecdh.c.

Function Documentation

◆ sshComputeEcdhSharedSecret()

error_t sshComputeEcdhSharedSecret ( SshConnection connection)

ECDH shared secret calculation.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 751 of file ssh_kex_ecdh.c.

◆ sshDigestClientEcdhPublicKey()

error_t sshDigestClientEcdhPublicKey ( SshConnection connection)

Update exchange hash with client's ephemeral public key.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 801 of file ssh_kex_ecdh.c.

◆ sshFormatKexEcdhInit()

error_t sshFormatKexEcdhInit ( SshConnection connection,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_KEX_ECDH_INIT message.

Parameters
[in]connectionPointer to the SSH connection
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 174 of file ssh_kex_ecdh.c.

◆ sshFormatKexEcdhReply()

error_t sshFormatKexEcdhReply ( SshConnection connection,
uint8_t *  p,
size_t *  length 
)

Format SSH_MSG_KEX_ECDH_REPLY message.

Parameters
[in]connectionPointer to the SSH connection
[out]pBuffer where to format the message
[out]lengthLength of the resulting message, in bytes
Returns
Error code

Definition at line 221 of file ssh_kex_ecdh.c.

◆ sshGenerateEcdhKeyPair()

error_t sshGenerateEcdhKeyPair ( SshConnection connection)

ECDH key pair generation.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 709 of file ssh_kex_ecdh.c.

◆ sshLoadKexEcdhParams()

error_t sshLoadKexEcdhParams ( EcDomainParameters params,
const char_t kexAlgo 
)

Load the EC parameters that match specified key exchange algorithm.

Parameters
[in,out]paramsElliptic curve domain parameters
[in]kexAlgoKey exchange algorithm name
Returns
Error code

Definition at line 635 of file ssh_kex_ecdh.c.

◆ sshParseKexEcdhInit()

error_t sshParseKexEcdhInit ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_KEX_ECDH_INIT message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 319 of file ssh_kex_ecdh.c.

◆ sshParseKexEcdhMessage()

error_t sshParseKexEcdhMessage ( SshConnection connection,
uint8_t  type,
const uint8_t *  message,
size_t  length 
)

Parse ECDH specific messages.

Parameters
[in]connectionPointer to the SSH connection
[in]typeSSH message type
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 576 of file ssh_kex_ecdh.c.

◆ sshParseKexEcdhReply()

error_t sshParseKexEcdhReply ( SshConnection connection,
const uint8_t *  message,
size_t  length 
)

Parse SSH_MSG_KEX_ECDH_REPLY message.

Parameters
[in]connectionPointer to the SSH connection
[in]messagePointer to message
[in]lengthLength of the message, in bytes
Returns
Error code

Definition at line 406 of file ssh_kex_ecdh.c.

◆ sshSendKexEcdhInit()

error_t sshSendKexEcdhInit ( SshConnection connection)

Send SSH_MSG_KEX_ECDH_INIT message.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 58 of file ssh_kex_ecdh.c.

◆ sshSendKexEcdhReply()

error_t sshSendKexEcdhReply ( SshConnection connection)

Send SSH_MSG_KEX_ECDH_REPLY message.

Parameters
[in]connectionPointer to the SSH connection
Returns
Error code

Definition at line 119 of file ssh_kex_ecdh.c.