ssh_algorithms.h
Go to the documentation of this file.
1 /**
2  * @file ssh_algorithms.h
3  * @brief SSH algorithm negotiation
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSH Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _SSH_ALGORITHMS_H
32 #define _SSH_ALGORITHMS_H
33 
34 //Dependencies
35 #include "ssh/ssh.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 //SSH related functions
43 error_t sshFormatKexAlgoList(SshConnection *connection, uint8_t *p,
44  size_t *written);
45 
46 error_t sshFormatHostKeyAlgoList(SshContext *context, uint8_t *p,
47  size_t *written);
48 
49 error_t sshFormatEncAlgoList(SshContext *context, uint8_t *p, size_t *written);
50 error_t sshFormatMacAlgoList(SshContext *context, uint8_t *p, size_t *written);
51 
53  size_t *written);
54 
56  size_t *written);
57 
58 const char_t *sshSelectAlgo(SshContext *context, const SshNameList *peerAlgoList,
59  const char_t *const *supportedAlgoList, uint_t supportedAlgoListLen);
60 
61 const char_t *sshSelectKexAlgo(SshConnection *connection,
62  const SshNameList *peerAlgoList);
63 
64 const char_t *sshSelectHostKeyAlgo(SshContext *context,
65  const SshNameList *peerAlgoList);
66 
67 const char_t *sshSelectEncAlgo(SshContext *context,
68  const SshNameList *peerAlgoList);
69 
70 const char_t *sshSelectMacAlgo(SshContext *context, const char_t *encAlgo,
71  const SshNameList *peerAlgoList);
72 
74  const SshNameList *peerAlgoList);
75 
77  const char_t *keyFormatId, const SshNameList *peerAlgoList);
78 
79 const char_t *sshGetKeyFormatId(const SshString *publicKeyAlgo);
80 const char_t *sshGetSignFormatId(const SshString *publicKeyAlgo);
81 
82 bool_t sshIsGuessCorrect(SshContext *context, const SshNameList *kexAlgoList,
83  const SshNameList *hostKeyAlgoList);
84 
85 bool_t sshIsRsaKexAlgo(const char_t *kexAlgo);
86 bool_t sshIsDhKexAlgo(const char_t *kexAlgo);
87 bool_t sshIsDhGexKexAlgo(const char_t *kexAlgo);
88 bool_t sshIsEcdhKexAlgo(const char_t *kexAlgo);
89 bool_t sshIsHybridKexAlgo(const char_t *kexAlgo);
90 
91 bool_t sshIsCertPublicKeyAlgo(const SshString *publicKeyAlgo);
92 bool_t sshIsX509CertPublicKeyAlgo(const SshString *publicKeyAlgo);
93 
94 //C++ guard
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
uint8_t p
Definition: ndp.h:300
Secure Shell (SSH)
#define SshConnection
Definition: ssh.h:883
#define SshContext
Definition: ssh.h:879
bool_t sshIsDhKexAlgo(const char_t *kexAlgo)
Test if the specified algorithm is a Diffie-Hellman key exchange algorithm.
const char_t * sshSelectEncAlgo(SshContext *context, const SshNameList *peerAlgoList)
Encryption algorithm negotiation.
const char_t * sshSelectKexAlgo(SshConnection *connection, const SshNameList *peerAlgoList)
Key exchange algorithm negotiation.
bool_t sshIsDhGexKexAlgo(const char_t *kexAlgo)
Test if the specified algorithm is a DH GEX key exchange algorithm.
bool_t sshIsHybridKexAlgo(const char_t *kexAlgo)
Test if the specified algorithm is a PQ-hybrid key exchange algorithm.
const char_t * sshGetKeyFormatId(const SshString *publicKeyAlgo)
Get the key format identifier used by a given public key algorithm.
error_t sshFormatCompressionAlgoList(SshContext *context, uint8_t *p, size_t *written)
Format the list of compression algorithms.
const char_t * sshGetSignFormatId(const SshString *publicKeyAlgo)
Get the signature format identifier used by a given public key algorithm.
error_t sshFormatEncAlgoList(SshContext *context, uint8_t *p, size_t *written)
Format the list of encryption algorithms.
const char_t * sshSelectAlgo(SshContext *context, const SshNameList *peerAlgoList, const char_t *const *supportedAlgoList, uint_t supportedAlgoListLen)
Generic algorithm negotiation.
bool_t sshIsX509CertPublicKeyAlgo(const SshString *publicKeyAlgo)
Test if the specified public key algorithm is using X.509 certificates.
const char_t * sshSelectPublicKeyAlgo(SshContext *context, const char_t *keyFormatId, const SshNameList *peerAlgoList)
Public key algorithm selection.
bool_t sshIsGuessCorrect(SshContext *context, const SshNameList *kexAlgoList, const SshNameList *hostKeyAlgoList)
Check whether the other party's guess is correct.
const char_t * sshSelectMacAlgo(SshContext *context, const char_t *encAlgo, const SshNameList *peerAlgoList)
Integrity algorithm negotiation.
bool_t sshIsRsaKexAlgo(const char_t *kexAlgo)
Test if the specified algorithm is an RSA key exchange algorithm.
error_t sshFormatPublicKeyAlgoList(SshContext *context, uint8_t *p, size_t *written)
Format the list of public key algorithms.
const char_t * sshSelectCompressionAlgo(SshContext *context, const SshNameList *peerAlgoList)
Compression algorithm negotiation.
bool_t sshIsCertPublicKeyAlgo(const SshString *publicKeyAlgo)
Test if the specified public key algorithm is using certificates.
const char_t * sshSelectHostKeyAlgo(SshContext *context, const SshNameList *peerAlgoList)
Host key algorithm negotiation.
error_t sshFormatMacAlgoList(SshContext *context, uint8_t *p, size_t *written)
Format the list of integrity algorithms.
bool_t sshIsEcdhKexAlgo(const char_t *kexAlgo)
Test if the specified algorithm is an ECDH key exchange algorithm.
error_t sshFormatHostKeyAlgoList(SshContext *context, uint8_t *p, size_t *written)
Format the list of host key algorithms.
error_t sshFormatKexAlgoList(SshConnection *connection, uint8_t *p, size_t *written)
Format the list of key exchange algorithms.
String containing a comma-separated list of names.
Definition: ssh_types.h:78
String.
Definition: ssh_types.h:56