summaryrefslogtreecommitdiffstats
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-14 13:29:46 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-15 16:26:58 +0200
commit190ae27463fd20c6089e79ffc7cece07a83d66ba (patch)
treef9300027aeb8c9f47b6d44565cdea80b14d78479 /src/pki.c
parent481522cf630833733d96fe19ef2876a467c113a6 (diff)
downloadlibssh-190ae27463fd20c6089e79ffc7cece07a83d66ba.tar.gz
libssh-190ae27463fd20c6089e79ffc7cece07a83d66ba.tar.xz
libssh-190ae27463fd20c6089e79ffc7cece07a83d66ba.zip
pki: Added ssh_key_dup().
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/pki.c b/src/pki.c
index 21a22484..aa32fc4a 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -69,6 +69,15 @@ ssh_key ssh_key_new (void) {
return ptr;
}
+ssh_key ssh_key_dup(const ssh_key key)
+{
+ if (key == NULL) {
+ return NULL;
+ }
+
+ return pki_key_dup(key, 0);
+}
+
/**
* @brief clean up the key and deallocate all existing keys
* @param[in] key ssh_key to clean
@@ -591,7 +600,12 @@ fail:
* @return A public key, NULL on error.
*/
ssh_key ssh_pki_publickey_from_privatekey(const ssh_key privkey) {
- return pki_publickey_from_privatekey(privkey);
+
+ if (privkey == NULL || !ssh_key_is_private(privkey)) {
+ return NULL;
+ }
+
+ return pki_key_dup(privkey, 1);
}
/*