1
1

options: Allow use of host ECDSA key

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Alan Dunn 2014-03-07 08:13:21 -06:00 коммит произвёл Andreas Schneider
родитель fbf73ede1e
Коммит 2a1089d607
2 изменённых файлов: 33 добавлений и 24 удалений

Просмотреть файл

@ -44,7 +44,8 @@ enum ssh_bind_options_e {
SSH_BIND_OPTIONS_RSAKEY, SSH_BIND_OPTIONS_RSAKEY,
SSH_BIND_OPTIONS_BANNER, SSH_BIND_OPTIONS_BANNER,
SSH_BIND_OPTIONS_LOG_VERBOSITY, SSH_BIND_OPTIONS_LOG_VERBOSITY,
SSH_BIND_OPTIONS_LOG_VERBOSITY_STR SSH_BIND_OPTIONS_LOG_VERBOSITY_STR,
SSH_BIND_OPTIONS_ECDSAKEY
}; };
typedef struct ssh_bind_struct* ssh_bind; typedef struct ssh_bind_struct* ssh_bind;

Просмотреть файл

@ -1303,6 +1303,22 @@ static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo,
return 0; return 0;
} }
static int ssh_bind_set_key(ssh_bind sshbind, char **key_loc,
const void *value) {
if (value == NULL) {
ssh_set_error_invalid(sshbind);
return -1;
} else {
SAFE_FREE(*key_loc);
*key_loc = strdup(value);
if (*key_loc == NULL) {
ssh_set_error_oom(sshbind);
return -1;
}
}
return 0;
}
/** /**
* @brief This function can set all possible ssh bind options. * @brief This function can set all possible ssh bind options.
* *
@ -1361,7 +1377,7 @@ static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo,
int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
const void *value) { const void *value) {
char *p, *q; char *p, *q;
int i; int i, rc;
if (sshbind == NULL) { if (sshbind == NULL) {
return -1; return -1;
@ -1445,31 +1461,23 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
} }
break; break;
case SSH_BIND_OPTIONS_DSAKEY: case SSH_BIND_OPTIONS_DSAKEY:
if (value == NULL) { rc = ssh_bind_set_key(sshbind, &sshbind->dsakey, value);
ssh_set_error_invalid(sshbind); if (rc < 0) {
return -1; return -1;
} else {
SAFE_FREE(sshbind->dsakey);
sshbind->dsakey = strdup(value);
if (sshbind->dsakey == NULL) {
ssh_set_error_oom(sshbind);
return -1;
} }
} break;
break;
case SSH_BIND_OPTIONS_RSAKEY: case SSH_BIND_OPTIONS_RSAKEY:
if (value == NULL) { rc = ssh_bind_set_key(sshbind, &sshbind->rsakey, value);
ssh_set_error_invalid(sshbind); if (rc < 0) {
return -1; return -1;
} else {
SAFE_FREE(sshbind->rsakey);
sshbind->rsakey = strdup(value);
if (sshbind->rsakey == NULL) {
ssh_set_error_oom(sshbind);
return -1;
} }
} break;
break; case SSH_BIND_OPTIONS_ECDSAKEY:
rc = ssh_bind_set_key(sshbind, &sshbind->ecdsakey, value);
if (rc < 0) {
return -1;
}
break;
case SSH_BIND_OPTIONS_BANNER: case SSH_BIND_OPTIONS_BANNER:
if (value == NULL) { if (value == NULL) {
ssh_set_error_invalid(sshbind); ssh_set_error_invalid(sshbind);