summaryrefslogtreecommitdiffstats
path: root/src/legacy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/legacy.c')
-rw-r--r--src/legacy.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/legacy.c b/src/legacy.c
index 76bcf503..678b0658 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -29,6 +29,8 @@
#include <libssh/priv.h>
#include <libssh/server.h>
#include <libssh/buffer.h>
+#include <libssh/pki.h>
+#include <libssh/keys.h>
void buffer_free(ssh_buffer buffer){
ssh_buffer_free(buffer);
@@ -234,6 +236,33 @@ char *string_to_char(ssh_string str){
return ssh_string_to_char(str);
}
+ssh_private_key privatekey_from_base64(ssh_session session,
+ const char *b64_pkey,
+ int type,
+ const char *passphrase) {
+ ssh_private_key privkey;
+ ssh_key key;
+
+ (void) type; /* unused */
+
+ key = pki_private_key_from_base64(session, b64_pkey, passphrase);
+ if (key == NULL) {
+ 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
****************************************************************************/