summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/known_hosts.c6
-rw-r--r--src/pki.c30
2 files changed, 36 insertions, 0 deletions
diff --git a/src/known_hosts.c b/src/known_hosts.c
index 7c935a8..7ec73de 100644
--- a/src/known_hosts.c
+++ b/src/known_hosts.c
@@ -474,6 +474,12 @@ int ssh_is_server_known(ssh_session session) {
if (match) {
/* We got a match. Now check the key type */
if (strcmp(session->current_crypto->server_pubkey_type, type) != 0) {
+ ssh_log(session,
+ SSH_LOG_PACKET,
+ "ssh_is_server_known: server type [%s] doesn't match the "
+ "type [%s] in known_hosts file",
+ session->current_crypto->server_pubkey_type,
+ type);
/* Different type. We don't override the known_changed error which is
* more important */
if (ret != SSH_SERVER_KNOWN_CHANGED)
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