From 19a3f5a61d96f4dbbb60b3a3fc19e50dde6870c0 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 16 Aug 2011 00:46:34 +0200 Subject: pki: Make publickey_from_file() a legacy function. --- src/legacy.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/legacy.c') diff --git a/src/legacy.c b/src/legacy.c index a17cb82..ed75490 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -194,8 +194,6 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename, void publickey_free(ssh_public_key key); int ssh_publickey_to_file(ssh_session session, const char *file, ssh_string pubkey, int type); -ssh_string publickey_from_file(ssh_session session, const char *filename, - int *type); ssh_public_key publickey_from_privatekey(ssh_private_key prv); ssh_string publickey_to_string(ssh_public_key key); * @@ -319,6 +317,28 @@ void privatekey_free(ssh_private_key prv) { SAFE_FREE(prv); } +ssh_string publickey_from_file(ssh_session session, const char *filename, + int *type) { + ssh_key key; + ssh_string key_str; + int rc; + + rc = ssh_pki_import_pubkey_file(session, filename, &key); + if (rc < 0) { + return NULL; + } + + key_str = ssh_pki_publickey_to_blob(key); + if (key_str == NULL) { + return NULL; + } + + *type = key->type; + ssh_key_free(key); + + return key_str; +} + /**************************************************************************** * SERVER SUPPORT ****************************************************************************/ -- cgit