aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlan Dunn <amdunn@gmail.com>2014-03-07 08:13:24 -0600
committerAndreas Schneider <asn@cryptomilk.org>2014-03-27 10:06:36 +0100
commit5c0c95bd348078fb94b00a4525a2df0c447c530f (patch)
tree07b2e9149024ddeaaa0b1e27b053f960c68efda2 /examples
parentc82dd2eb81ebdd1456faa0de45eb285d669755fb (diff)
downloadlibssh-5c0c95bd348078fb94b00a4525a2df0c447c530f.tar.gz
libssh-5c0c95bd348078fb94b00a4525a2df0c447c530f.tar.xz
libssh-5c0c95bd348078fb94b00a4525a2df0c447c530f.zip
examples: Add ECDSA key option to ssh_server_fork
Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/ssh_server_fork.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/examples/ssh_server_fork.c b/examples/ssh_server_fork.c
index 1582b38a..21177f3a 100644
--- a/examples/ssh_server_fork.c
+++ b/examples/ssh_server_fork.c
@@ -55,7 +55,8 @@ The goal is to show the API in action.
static void set_default_keys(ssh_bind sshbind,
int rsa_already_set,
- int dsa_already_set) {
+ int dsa_already_set,
+ int ecdsa_already_set) {
if (!rsa_already_set) {
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY,
KEYS_FOLDER "ssh_host_rsa_key");
@@ -64,6 +65,10 @@ static void set_default_keys(ssh_bind sshbind,
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY,
KEYS_FOLDER "ssh_host_dsa_key");
}
+ if (!ecdsa_already_set) {
+ ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY,
+ KEYS_FOLDER "ssh_host_ecdsa_key");
+ }
}
#ifdef HAVE_ARGP_H
@@ -112,6 +117,14 @@ static struct argp_option options[] = {
.group = 0
},
{
+ .name = "ecdsakey",
+ .key = 'e',
+ .arg = "FILE",
+ .flags = 0,
+ .doc = "Set the ecdsa key.",
+ .group = 0
+ },
+ {
.name = "no-default-keys",
.key = 'n',
.arg = NULL,
@@ -136,7 +149,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
* know is a pointer to our arguments structure. */
ssh_bind sshbind = state->input;
static int no_default_keys = 0;
- static int rsa_already_set = 0, dsa_already_set = 0;
+ static int rsa_already_set = 0, dsa_already_set = 0, ecdsa_already_set = 0;
switch (key) {
case 'n':
@@ -159,6 +172,10 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
rsa_already_set = 1;
break;
+ case 'e':
+ ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY, arg);
+ ecdsa_already_set = 1;
+ break;
case 'v':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR,
"3");
@@ -179,7 +196,8 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
if (!no_default_keys) {
set_default_keys(sshbind,
rsa_already_set,
- dsa_already_set);
+ dsa_already_set,
+ ecdsa_already_set);
}
break;
@@ -620,7 +638,7 @@ int main(int argc, char **argv) {
(void) argc;
(void) argv;
- set_default_keys(sshbind, 0, 0);
+ set_default_keys(sshbind, 0, 0, 0);
#endif /* HAVE_ARGP_H */
if(ssh_bind_listen(sshbind) < 0) {