diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-08-16 17:47:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-08-16 17:47:29 +0200 |
commit | a40f1d85972986c8baa2e32fe666c7bf19423045 (patch) | |
tree | 3ab53e1142f4d6656e2bfb378f2b1f93c3360def /src/legacy.c | |
parent | c940918821db41909ac99b16483a7c853c1bafcd (diff) | |
download | libssh-a40f1d85972986c8baa2e32fe666c7bf19423045.tar.gz libssh-a40f1d85972986c8baa2e32fe666c7bf19423045.tar.xz libssh-a40f1d85972986c8baa2e32fe666c7bf19423045.zip |
pki: Make publickey_from_string a legacy function.
Diffstat (limited to 'src/legacy.c')
-rw-r--r-- | src/legacy.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/legacy.c b/src/legacy.c index bdb9834..c021a4b 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -352,6 +352,35 @@ int ssh_type_from_name(const char *name) { return ssh_key_type_from_name(name); } +ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s) { + struct ssh_public_key_struct *pubkey; + ssh_key key; + int rc; + + rc = ssh_pki_import_pubkey_blob(session, pubkey_s, &key); + if (rc < 0) { + return NULL; + } + + pubkey = malloc(sizeof(struct ssh_public_key_struct)); + if (pubkey == NULL) { + ssh_key_free(key); + return NULL; + } + + pubkey->type = key->type; + pubkey->type_c = key->type_c; + + pubkey->dsa_pub = key->dsa; + key->dsa = NULL; + pubkey->rsa_pub = key->rsa; + key->rsa = NULL; + + ssh_key_free(key); + + return pubkey; +} + /**************************************************************************** * SERVER SUPPORT ****************************************************************************/ |