diff options
author | Alan Dunn <amdunn@gmail.com> | 2014-03-07 08:13:21 -0600 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2014-03-27 10:05:23 +0100 |
commit | 2a1089d6079c14da8d24c996402e24a689a9f5d3 (patch) | |
tree | ef271d402874cd5966677f20ae620805c09b62a6 /src/options.c | |
parent | fbf73ede1eb4226ebe54698fefffb38ecd8f090b (diff) | |
download | libssh-2a1089d6079c14da8d24c996402e24a689a9f5d3.tar.gz libssh-2a1089d6079c14da8d24c996402e24a689a9f5d3.tar.xz libssh-2a1089d6079c14da8d24c996402e24a689a9f5d3.zip |
options: Allow use of host ECDSA key
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/options.c b/src/options.c index cdcbe7c0..846ce368 100644 --- a/src/options.c +++ b/src/options.c @@ -1303,6 +1303,22 @@ static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo, 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. * @@ -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, const void *value) { char *p, *q; - int i; + int i, rc; if (sshbind == NULL) { return -1; @@ -1445,31 +1461,23 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, } break; case SSH_BIND_OPTIONS_DSAKEY: - if (value == NULL) { - ssh_set_error_invalid(sshbind); - return -1; - } else { - SAFE_FREE(sshbind->dsakey); - sshbind->dsakey = strdup(value); - if (sshbind->dsakey == NULL) { - ssh_set_error_oom(sshbind); - return -1; + rc = ssh_bind_set_key(sshbind, &sshbind->dsakey, value); + if (rc < 0) { + return -1; } - } - break; + break; case SSH_BIND_OPTIONS_RSAKEY: - if (value == NULL) { - ssh_set_error_invalid(sshbind); - return -1; - } else { - SAFE_FREE(sshbind->rsakey); - sshbind->rsakey = strdup(value); - if (sshbind->rsakey == NULL) { - ssh_set_error_oom(sshbind); - return -1; + rc = ssh_bind_set_key(sshbind, &sshbind->rsakey, value); + if (rc < 0) { + 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: if (value == NULL) { ssh_set_error_invalid(sshbind); |