DH GEX (Diffie-Hellman Group Exchange) 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_dh_gex.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 "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 | sshSendKexDhGexRequest (SshConnection *connection) | 
| Send SSH_MSG_KEX_DH_GEX_REQUEST message.  More... | |
| error_t | sshSendKexDhGexGroup (SshConnection *connection) | 
| Send SSH_MSG_KEX_DH_GEX_GROUP message.  More... | |
| error_t | sshSendKexDhGexInit (SshConnection *connection) | 
| Send SSH_MSG_KEX_DH_GEX_INIT message.  More... | |
| error_t | sshSendKexDhGexReply (SshConnection *connection) | 
| Send SSH_MSG_KEX_DH_GEX_REPLY message.  More... | |
| error_t | sshFormatKexDhGexRequest (SshConnection *connection, uint8_t *p, size_t *length) | 
| Format SSH_MSG_KEX_DH_GEX_REQUEST message.  More... | |
| error_t | sshFormatKexDhGexGroup (SshConnection *connection, uint8_t *p, size_t *length) | 
| Format SSH_MSG_KEX_DH_GEX_GROUP message.  More... | |
| error_t | sshFormatKexDhGexInit (SshConnection *connection, uint8_t *p, size_t *length) | 
| Format SSH_MSG_KEX_DH_GEX_INIT message.  More... | |
| error_t | sshFormatKexDhGexReply (SshConnection *connection, uint8_t *p, size_t *length) | 
| Format SSH_MSG_KEX_DH_GEX_REPLY message.  More... | |
| error_t | sshParseKexDhGexRequest (SshConnection *connection, const uint8_t *message, size_t length) | 
| Parse SSH_MSG_KEX_DH_GEX_REQUEST message.  More... | |
| error_t | sshParseKexDhGexRequestOld (SshConnection *connection, const uint8_t *message, size_t length) | 
| Parse SSH_MSG_KEX_DH_GEX_REQUEST_OLD message.  More... | |
| error_t | sshParseKexDhGexGroup (SshConnection *connection, const uint8_t *message, size_t length) | 
| Parse SSH_MSG_KEX_DH_GEX_GROUP message.  More... | |
| error_t | sshParseKexDhGexInit (SshConnection *connection, const uint8_t *message, size_t length) | 
| Parse SSH_MSG_KEX_DH_GEX_INIT message.  More... | |
| error_t | sshParseKexDhGexReply (SshConnection *connection, const uint8_t *message, size_t length) | 
| Parse SSH_MSG_KEX_DH_GEX_REPLY message.  More... | |
| error_t | sshParseKexDhGexMessage (SshConnection *connection, uint8_t type, const uint8_t *message, size_t length) | 
| Parse Diffie-Hellman Group Exchange specific messages.  More... | |
| int_t | sshSelectDhGexGroup (SshContext *context, uint32_t minDhModulusSize, uint32_t preferredDhModulusSize, uint32_t maxDhModulusSize) | 
| Select a Diffie-Hellman group that best matches client's request.  More... | |
| error_t | sshComputeDhGexSharedSecret (SshConnection *connection) | 
| Diffie-Hellman shared secret calculation.  More... | |
| error_t | sshDigestDhGexParams (SshConnection *connection) | 
| Update exchange hash with min, n, max, p, g and e.  More... | |
Detailed Description
DH GEX (Diffie-Hellman Group Exchange) key exchange.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2019-2025 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.5.4
Definition in file ssh_kex_dh_gex.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL SSH_TRACE_LEVEL | 
Definition at line 32 of file ssh_kex_dh_gex.c.
Function Documentation
◆ sshComputeDhGexSharedSecret()
| error_t sshComputeDhGexSharedSecret | ( | SshConnection * | connection | ) | 
Diffie-Hellman shared secret calculation.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 1170 of file ssh_kex_dh_gex.c.
◆ sshDigestDhGexParams()
| error_t sshDigestDhGexParams | ( | SshConnection * | connection | ) | 
Update exchange hash with min, n, max, p, g and e.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 1200 of file ssh_kex_dh_gex.c.
◆ sshFormatKexDhGexGroup()
| error_t sshFormatKexDhGexGroup | ( | SshConnection * | connection, | 
| uint8_t * | p, | ||
| size_t * | length | ||
| ) | 
Format SSH_MSG_KEX_DH_GEX_GROUP message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [out] p Buffer where to format the message [out] length Length of the resulting message, in bytes 
- Returns
- Error code
Definition at line 335 of file ssh_kex_dh_gex.c.
◆ sshFormatKexDhGexInit()
| error_t sshFormatKexDhGexInit | ( | SshConnection * | connection, | 
| uint8_t * | p, | ||
| size_t * | length | ||
| ) | 
Format SSH_MSG_KEX_DH_GEX_INIT message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [out] p Buffer where to format the message [out] length Length of the resulting message, in bytes 
- Returns
- Error code
Definition at line 400 of file ssh_kex_dh_gex.c.
◆ sshFormatKexDhGexReply()
| error_t sshFormatKexDhGexReply | ( | SshConnection * | connection, | 
| uint8_t * | p, | ||
| size_t * | length | ||
| ) | 
Format SSH_MSG_KEX_DH_GEX_REPLY message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [out] p Buffer where to format the message [out] length Length of the resulting message, in bytes 
- Returns
- Error code
Definition at line 443 of file ssh_kex_dh_gex.c.
◆ sshFormatKexDhGexRequest()
| error_t sshFormatKexDhGexRequest | ( | SshConnection * | connection, | 
| uint8_t * | p, | ||
| size_t * | length | ||
| ) | 
Format SSH_MSG_KEX_DH_GEX_REQUEST message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [out] p Buffer where to format the message [out] length Length of the resulting message, in bytes 
- Returns
- Error code
Definition at line 294 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexGroup()
| error_t sshParseKexDhGexGroup | ( | SshConnection * | connection, | 
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse SSH_MSG_KEX_DH_GEX_GROUP message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 690 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexInit()
| error_t sshParseKexDhGexInit | ( | SshConnection * | connection, | 
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse SSH_MSG_KEX_DH_GEX_INIT message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 783 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexMessage()
| error_t sshParseKexDhGexMessage | ( | SshConnection * | connection, | 
| uint8_t | type, | ||
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse Diffie-Hellman Group Exchange specific messages.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] type SSH message type [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 1013 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexReply()
| error_t sshParseKexDhGexReply | ( | SshConnection * | connection, | 
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse SSH_MSG_KEX_DH_GEX_REPLY message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 857 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexRequest()
| error_t sshParseKexDhGexRequest | ( | SshConnection * | connection, | 
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse SSH_MSG_KEX_DH_GEX_REQUEST message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 537 of file ssh_kex_dh_gex.c.
◆ sshParseKexDhGexRequestOld()
| error_t sshParseKexDhGexRequestOld | ( | SshConnection * | connection, | 
| const uint8_t * | message, | ||
| size_t | length | ||
| ) | 
Parse SSH_MSG_KEX_DH_GEX_REQUEST_OLD message.
- Parameters
- 
  [in] connection Pointer to the SSH connection [in] message Pointer to message [in] length Length of the message, in bytes 
- Returns
- Error code
Definition at line 616 of file ssh_kex_dh_gex.c.
◆ sshSelectDhGexGroup()
| int_t sshSelectDhGexGroup | ( | SshContext * | context, | 
| uint32_t | minDhModulusSize, | ||
| uint32_t | preferredDhModulusSize, | ||
| uint32_t | maxDhModulusSize | ||
| ) | 
Select a Diffie-Hellman group that best matches client's request.
- Parameters
- 
  [in] context Pointer to the SSH context [in] minDhModulusSize Minimum acceptable size for Diffie-Hellman prime modulus [in] preferredDhModulusSize Preferred size for Diffie-Hellman prime modulus [in] maxDhModulusSize Maximum acceptable size for Diffie-Hellman prime modulus 
- Returns
- Index of the selected Diffie-Hellman group, if any
Definition at line 1089 of file ssh_kex_dh_gex.c.
◆ sshSendKexDhGexGroup()
| error_t sshSendKexDhGexGroup | ( | SshConnection * | connection | ) | 
Send SSH_MSG_KEX_DH_GEX_GROUP message.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 105 of file ssh_kex_dh_gex.c.
◆ sshSendKexDhGexInit()
| error_t sshSendKexDhGexInit | ( | SshConnection * | connection | ) | 
Send SSH_MSG_KEX_DH_GEX_INIT message.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 176 of file ssh_kex_dh_gex.c.
◆ sshSendKexDhGexReply()
| error_t sshSendKexDhGexReply | ( | SshConnection * | connection | ) | 
Send SSH_MSG_KEX_DH_GEX_REPLY message.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 234 of file ssh_kex_dh_gex.c.
◆ sshSendKexDhGexRequest()
| error_t sshSendKexDhGexRequest | ( | SshConnection * | connection | ) | 
Send SSH_MSG_KEX_DH_GEX_REQUEST message.
- Parameters
- 
  [in] connection Pointer to the SSH connection 
- Returns
- Error code
Definition at line 59 of file ssh_kex_dh_gex.c.
