summaryrefslogtreecommitdiffstats
path: root/src/legacy.c
diff options
context:
space:
mode:
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
****************************************************************************/