aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-30 10:16:53 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-30 10:16:53 +0200
commit60b92e458e1cf16f0029d9251e0f117ff27a02d0 (patch)
tree1f099e92f170a4aa3d921efc7adbd5a22f75627a /src/pki.c
parente2365775030fa3c696e1f75997d5bc856a19e3ed (diff)
downloadlibssh-60b92e458e1cf16f0029d9251e0f117ff27a02d0.tar.gz
libssh-60b92e458e1cf16f0029d9251e0f117ff27a02d0.tar.xz
libssh-60b92e458e1cf16f0029d9251e0f117ff27a02d0.zip
pki: Use consistent API for ssh_pki_export_pubkey_blob().
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/pki.c b/src/pki.c
index 7e86d307..7628bb4e 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -800,23 +800,39 @@ ssh_key ssh_pki_publickey_from_privatekey(const ssh_key privkey) {
}
/**
+ * @internal
+ *
* @brief Create a key_blob from a public key.
*
* The "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
* Algorithms" for any of the supported protocol 2 key types.
*
- * @param[in] key A public or private key to create the public ssh_string
+ * @param[in] key A public or private key to create the public ssh_string
* from.
*
- * @return The key_blob or NULL on error.
+ * @param[out] pblob A pointer to store the newly allocated key blob. You
+ * NEED to free it.
+ *
+ * @return SSH_OK on success, SSH_ERROR otherwise.
+ *
+ * @see ssh_string_free()
*/
-ssh_string ssh_pki_export_pubkey_blob(const ssh_key key)
+int ssh_pki_export_pubkey_blob(const ssh_key key,
+ ssh_string *pblob)
{
+ ssh_string blob;
+
if (key == NULL) {
- return NULL;
+ return SSH_OK;
}
- return pki_publickey_to_blob(key);
+ blob = pki_publickey_to_blob(key);
+ if (blob == NULL) {
+ return SSH_ERROR;
+ }
+
+ *pblob = blob;
+ return SSH_OK;
}
/**