mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
Improve server_set_kex().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@654 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -273,19 +273,24 @@ static int server_set_kex(SSH_SESSION * session) {
|
|||||||
SSH_OPTIONS *options = session->options;
|
SSH_OPTIONS *options = session->options;
|
||||||
int i, j;
|
int i, j;
|
||||||
char *wanted;
|
char *wanted;
|
||||||
memset(server,0,sizeof(KEX));
|
|
||||||
// the program might ask for a specific cookie to be sent. useful for server
|
ZERO_STRUCTP(server);
|
||||||
// debugging
|
/*
|
||||||
if (options->wanted_cookie)
|
* The program might ask for a specific cookie to be sent. Useful for server
|
||||||
|
* debugging
|
||||||
|
*/
|
||||||
|
if (options->wanted_cookie) {
|
||||||
memcpy(server->cookie, options->wanted_cookie, 16);
|
memcpy(server->cookie, options->wanted_cookie, 16);
|
||||||
else
|
} else {
|
||||||
ssh_get_random(server->cookie, 16,0);
|
ssh_get_random(server->cookie, 16, 0);
|
||||||
if (session->dsa_key && session->rsa_key) {
|
}
|
||||||
if (ssh_options_set_wanted_algos(options, SSH_HOSTKEYS, "ssh-dss,ssh-rsa") < 0) {
|
|
||||||
|
if (session->dsa_key != NULL && session->rsa_key != NULL) {
|
||||||
|
if (ssh_options_set_wanted_algos(options, SSH_HOSTKEYS,
|
||||||
|
"ssh-dss,ssh-rsa") < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (session->dsa_key != NULL) {
|
||||||
if (session->dsa_key) {
|
|
||||||
if (ssh_options_set_wanted_algos(options, SSH_HOSTKEYS, "ssh-dss") < 0) {
|
if (ssh_options_set_wanted_algos(options, SSH_HOSTKEYS, "ssh-dss") < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -294,14 +299,16 @@ static int server_set_kex(SSH_SESSION * session) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
server->methods = malloc(10 * sizeof(char **));
|
server->methods = malloc(10 * sizeof(char **));
|
||||||
if (server->methods == NULL) {
|
if (server->methods == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
if (!(wanted = options->wanted_methods[i]))
|
if ((wanted = options->wanted_methods[i]) == NULL) {
|
||||||
wanted = supported_methods[i];
|
wanted = supported_methods[i];
|
||||||
|
}
|
||||||
server->methods[i] = strdup(wanted);
|
server->methods[i] = strdup(wanted);
|
||||||
if (server->methods[i] == NULL) {
|
if (server->methods[i] == NULL) {
|
||||||
for (j = i - 1; j <= 0; j--) {
|
for (j = i - 1; j <= 0; j--) {
|
||||||
@@ -311,6 +318,7 @@ static int server_set_kex(SSH_SESSION * session) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user