aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-10-31 13:03:21 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-11-07 15:55:32 +0100
commit1ebf506913495a736322fc5a97ba336adff6e464 (patch)
treec5df3a393c157286e41c43219b7f7e8c08d9a37c /src/pki.c
parentfbc2912ddeb22dfc901508467a23d6e9d41cd6a2 (diff)
downloadlibssh-1ebf506913495a736322fc5a97ba336adff6e464.tar.gz
libssh-1ebf506913495a736322fc5a97ba336adff6e464.tar.xz
libssh-1ebf506913495a736322fc5a97ba336adff6e464.zip
server: Use really the negotiated signature type
Generally, when the extension negotiation is enabled and client supports SHA2 algorithms for RSA, they are supposed to be prioritized against the old SHA1. If it is not (ssh-rsa is listed in front of rsa-sha2-* hostkey algorithms during negotiation), the server wrongly tries to provide the new typo of signature, ignoring the negotiated algirithm This commit propagates the digest algorithm from negotiation to the actual signature functions, which were previously responsible for decision about the hash algorithm based just on the negotiated extensions. Fixes T191 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.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/pki.c b/src/pki.c
index 488500cc..3bd7f272 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -305,7 +305,7 @@ const char *ssh_key_type_to_char(enum ssh_keytypes_e type) {
return NULL;
}
-static enum ssh_digest_e ssh_key_hash_from_name(const char *name)
+enum ssh_digest_e ssh_key_hash_from_name(const char *name)
{
if (name == NULL) {
/* TODO we should rather fail */
@@ -2423,7 +2423,8 @@ ssh_string ssh_pki_do_sign_agent(ssh_session session,
#ifdef WITH_SERVER
ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
- const ssh_key privkey)
+ const ssh_key privkey,
+ const enum ssh_digest_e digest)
{
struct ssh_crypto_struct *crypto = NULL;
@@ -2432,8 +2433,6 @@ ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
ssh_buffer sign_input = NULL;
- enum ssh_digest_e hash_type;
-
int rc;
if (session == NULL || privkey == NULL || !ssh_key_is_private(privkey)) {
@@ -2448,9 +2447,6 @@ ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
return NULL;
}
- /* Get the hash type from the key type */
- hash_type = ssh_key_type_to_hash(session, privkey->type);
-
/* Fill the input */
sign_input = ssh_buffer_new();
if (sign_input == NULL) {
@@ -2470,7 +2466,7 @@ ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
sig = pki_do_sign(privkey,
ssh_buffer_get(sign_input),
ssh_buffer_get_len(sign_input),
- hash_type);
+ digest);
if (sig == NULL) {
goto end;
}