aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-08-06 13:40:32 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-31 14:18:34 +0200
commit82da0c3361b18f804f1e2b0d99fae862bb5dcb6e (patch)
tree66a53795e13c21827e93987dd1aa09c6855312de /src/pki.c
parent1f08aabe430676653c584eb29a28e56555ea5314 (diff)
downloadlibssh-82da0c3361b18f804f1e2b0d99fae862bb5dcb6e.tar.gz
libssh-82da0c3361b18f804f1e2b0d99fae862bb5dcb6e.tar.xz
libssh-82da0c3361b18f804f1e2b0d99fae862bb5dcb6e.zip
auth: Support SHA2 extension for pubkey authentication (RFC 8332)
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/pki.c b/src/pki.c
index 5106aec5..d894762c 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -282,8 +282,8 @@ static enum ssh_digest_e ssh_key_hash_from_name(const char *name)
*
* @return A hash type to be used.
*/
-static enum ssh_keytypes_e ssh_key_type_to_hash(ssh_session session,
- enum ssh_keytypes_e type)
+static enum ssh_digest_e ssh_key_type_to_hash(ssh_session session,
+ enum ssh_keytypes_e type)
{
/* TODO this should also reflect supported key types specified in
* configuration (ssh_config PubkeyAcceptedKeyTypes) */
@@ -310,6 +310,26 @@ static enum ssh_keytypes_e ssh_key_type_to_hash(ssh_session session,
}
/**
+ * @brief Gets signature algorithm name to be used with the given
+ * key type.
+ *
+ * @param[in] session SSH session.
+ * @param[in] type The algorithm type to convert.
+ *
+ * @return A string for the keytype or NULL if unknown.
+ */
+const char *
+ssh_key_get_signature_algorithm(ssh_session session,
+ enum ssh_keytypes_e type)
+{
+ enum ssh_digest_e hash_type;
+
+ hash_type = ssh_key_type_to_hash(session, type);
+
+ return ssh_key_signature_to_char(type, hash_type);
+}
+
+/**
* @brief Convert a ssh key algorithm name to a ssh key algorithm type.
*
* @param[in] name The name to convert.