summaryrefslogtreecommitdiffstats
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-06-15 18:27:23 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-06-15 18:27:23 +0200
commitf684e76ab224869b1a4db07cd1256876f4a71bae (patch)
tree22c3f1ff5b0d8d078553cf6bd7f5d75026a6a479 /src/pki.c
parent3ba44badb00f7315dbe30aee7f5b75568fd1b0b7 (diff)
parentc75581fb939e5be9ea51c1741e57b75626da03a3 (diff)
downloadlibssh-f684e76ab224869b1a4db07cd1256876f4a71bae.tar.gz
libssh-f684e76ab224869b1a4db07cd1256876f4a71bae.tar.xz
libssh-f684e76ab224869b1a4db07cd1256876f4a71bae.zip
Merge branch 'pki'
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pki.c b/src/pki.c
index fe3b13b..fd30ee4 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -151,6 +151,36 @@ enum ssh_keytypes_e ssh_key_type_from_name(const char *name) {
}
/**
+ * @brief Check if the key has/is a public key.
+ *
+ * @param[in] k The key to check.
+ *
+ * @return 1 if it is a public key, 0 if not.
+ */
+int ssh_key_is_public(ssh_key k) {
+ if (k == NULL) {
+ return 0;
+ }
+
+ return (k->flags & SSH_KEY_FLAG_PUBLIC);
+}
+
+/**
+ * @brief Check if the key is a private key.
+ *
+ * @param[in] k The key to check.
+ *
+ * @return 1 if it is a private key, 0 if not.
+ */
+int ssh_key_is_private(ssh_key k) {
+ if (k == NULL) {
+ return 0;
+ }
+
+ return (k->flags & SSH_KEY_FLAG_PRIVATE);
+}
+
+/**
* @brief import a key from a file
* @param[out] key the ssh_key to update
* @param[in] session The SSH Session to use. If a key decryption callback is set, it will