From 9bed334da3b0f18eee326300b5a8a8b4ff5d5875 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 7 Aug 2011 17:49:02 +0200 Subject: pki: Add ssh_pki_convert_key_to_privatekey(). --- src/pki.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/pki.c b/src/pki.c index 57b3ad2..593cc41 100644 --- a/src/pki.c +++ b/src/pki.c @@ -293,6 +293,22 @@ ssh_public_key ssh_pki_convert_key_to_publickey(ssh_key key) { return pub; } +ssh_private_key ssh_pki_convert_key_to_privatekey(ssh_key key) { + ssh_private_key privkey; + + 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; +} + /** @brief import a base64 formated key from a memory c-string * * @param key The key to fill, created with ssh_key_new() -- cgit