mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-14 04:18:54 +03:00
server: expose 'ssh_server_init_kex' API
Expose an API 'ssh_server_init_kex' which allows one to change the set of key exchange, hostkey, ciphers, MACs, and compression algorithms currently configured for the ssh_session at hand, after having started the 'ssh_handle_key_exchange' process. One can use this API from the already-existing 'connect_status_function' callback to dynamically modify the set of algorithms used after having received the client banner, but before sending out the initial KEXINIT message. For example, one might want to prevent advertising the curve25519 key exchange algorithm for older OpenSSH clients due to interop bugs. Fixes T25 Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
f0ddde4826
commit
538f1bc00e
27
src/server.c
27
src/server.c
@@ -75,12 +75,12 @@ static int dh_handshake_server(ssh_session session);
|
||||
*/
|
||||
|
||||
/** @internal
|
||||
* This functions sets the Key Exchange protocols to be accepted
|
||||
* by the server. They depend on
|
||||
* -What the user asked (via options)
|
||||
* -What is available (keys)
|
||||
* It should then accept the intersection of what the user asked
|
||||
* and what is available, and return an error if nothing matches
|
||||
*
|
||||
* @brief initialize the set of key exchange, hostkey, ciphers, MACs, and
|
||||
* compression algorithms for the given ssh_session
|
||||
*
|
||||
* The selection of algorithms and keys used are determined by the
|
||||
* options that are currently set in the given ssh_session structure.
|
||||
*/
|
||||
|
||||
static int server_set_kex(ssh_session session) {
|
||||
@@ -149,6 +149,21 @@ static int server_set_kex(ssh_session session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ssh_server_init_kex(ssh_session session) {
|
||||
int i;
|
||||
|
||||
if (session->session_state > SSH_SESSION_STATE_BANNER_RECEIVED) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
/* free any currently-set methods: server_set_kex will allocate new ones */
|
||||
for (i = 0; i < 10 /* SSH_KEX_METHODS */; i++) {
|
||||
SAFE_FREE(session->next_crypto->server_kex.methods[i]);
|
||||
}
|
||||
|
||||
return server_set_kex(session);
|
||||
}
|
||||
|
||||
/** @internal
|
||||
* @brief parse an incoming SSH_MSG_KEXDH_INIT packet and complete
|
||||
* key exchange
|
||||
|
||||
Reference in New Issue
Block a user