aboutsummaryrefslogtreecommitdiff
path: root/src/ecdh_gcrypt.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/ecdh_gcrypt.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/ecdh_gcrypt.c')
-rw-r--r--src/ecdh_gcrypt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ecdh_gcrypt.c b/src/ecdh_gcrypt.c
index 3c3fe8f0..7bbad14e 100644
--- a/src/ecdh_gcrypt.c
+++ b/src/ecdh_gcrypt.c
@@ -273,6 +273,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
gcry_sexp_t key = NULL;
/* SSH host keys (rsa,dsa,ecdsa) */
ssh_key privkey;
+ enum ssh_digest_e digest = SSH_DIGEST_AUTO;
ssh_string sig_blob = NULL;
ssh_string pubkey_blob = NULL;
int rc = SSH_ERROR;
@@ -325,7 +326,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
}
/* privkey is not allocated */
- rc = ssh_get_key_params(session, &privkey);
+ rc = ssh_get_key_params(session, &privkey, &digest);
if (rc != SSH_OK) {
goto out;
}
@@ -336,7 +337,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
goto out;
}
- sig_blob = ssh_srv_pki_do_sign_sessionid(session, privkey);
+ sig_blob = ssh_srv_pki_do_sign_sessionid(session, privkey, digest);
if (sig_blob == NULL) {
ssh_set_error(session, SSH_FATAL, "Could not sign the session id");
rc = SSH_ERROR;