summaryrefslogtreecommitdiffstats
path: root/src/legacy.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-07 15:00:35 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-08 15:28:31 +0200
commitf55cd7de431018bc1799aa9616006569d90f0fcc (patch)
tree9b5ba494a2c88090306067ebf58c0c25b196eae2 /src/legacy.c
parent9569d053d8f419ebd7fcdecd2c6e18ff86e34c86 (diff)
downloadlibssh-f55cd7de431018bc1799aa9616006569d90f0fcc.tar.gz
libssh-f55cd7de431018bc1799aa9616006569d90f0fcc.tar.xz
libssh-f55cd7de431018bc1799aa9616006569d90f0fcc.zip
pki: Improve ssh_key_import_private().
Diffstat (limited to 'src/legacy.c')
-rw-r--r--src/legacy.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/legacy.c b/src/legacy.c
index 678b065..8655f31 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -263,6 +263,34 @@ ssh_private_key privatekey_from_base64(ssh_session session,
return privkey;
}
+ssh_private_key privatekey_from_file(ssh_session session,
+ const char *filename,
+ int type,
+ const char *passphrase) {
+ ssh_key key;
+ ssh_private_key privkey;
+ int rc;
+
+ (void) type; /* unused */
+
+ rc = ssh_key_import_private(session, filename, passphrase, &key);
+ if (rc == SSH_ERROR) {
+ return NULL;
+ }
+
+ privkey = malloc(sizeof(struct ssh_private_key_struct));
+ if (privkey == NULL) {
+ ssh_key_free(key);
+ return NULL;
+ }
+
+ privkey->type = key->type;
+ privkey->dsa_priv = key->dsa;
+ privkey->rsa_priv = key->rsa;
+
+ return privkey;
+}
+
/****************************************************************************
* SERVER SUPPORT
****************************************************************************/