diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/known_hosts.c | 6 | ||||
-rw-r--r-- | src/pki.c | 30 |
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) @@ -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 |