1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

pki: Improve ssh_pki_import_privkey_base64().

This commit is contained in:
Andreas Schneider
2011-08-07 14:00:42 +02:00
parent 028888719a
commit 9569d053d8
7 changed files with 255 additions and 239 deletions

View File

@@ -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
****************************************************************************/