summaryrefslogtreecommitdiffstats
path: root/src/legacy.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-07 14:00:42 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-08 15:28:31 +0200
commit9569d053d8f419ebd7fcdecd2c6e18ff86e34c86 (patch)
tree672c98de97f7f1ba2b17a69982a02266b9787da0 /src/legacy.c
parent028888719a54794f998cc3572419361a73674929 (diff)
downloadlibssh-9569d053d8f419ebd7fcdecd2c6e18ff86e34c86.tar.gz
libssh-9569d053d8f419ebd7fcdecd2c6e18ff86e34c86.tar.xz
libssh-9569d053d8f419ebd7fcdecd2c6e18ff86e34c86.zip
pki: Improve ssh_pki_import_privkey_base64().
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 76bcf50..678b065 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
****************************************************************************/