aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2018-05-25 03:00:33 -0700
committerAndreas Schneider <asn@cryptomilk.org>2018-06-27 21:25:24 +0200
commit0b90ab102e5831a1d262c8ffb0aa769ffafac301 (patch)
tree40a02e4cc760e459328ab5d3456efc846838a6fe
parentcd3170fcb174954eb28629cad8667f8de45963a3 (diff)
downloadlibssh-0b90ab102e5831a1d262c8ffb0aa769ffafac301.tar.gz
libssh-0b90ab102e5831a1d262c8ffb0aa769ffafac301.tar.xz
libssh-0b90ab102e5831a1d262c8ffb0aa769ffafac301.zip
ecdh: fix SSH_MSG_KEXDH_REPLY for libcrypto
Ensure to provide the `ssh_string` pubkey blob to the buffer packing routine when computing the SSH_MSG_KEXDH_REPLY message, rather than the new `ssh_key` type. Introduced with 16217454d576511f37f39c3169963629f9d5082f. Testing done: with this change, `pkd_hello` test is passing on an OpenSSL 1.1.0 build for me. Previously it would segfault during pubkey exchange with "ecdh-sha2-nistp256". Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/ecdh_crypto.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ecdh_crypto.c b/src/ecdh_crypto.c
index 041e6c0e..24f21c03 100644
--- a/src/ecdh_crypto.c
+++ b/src/ecdh_crypto.c
@@ -206,6 +206,7 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
/* SSH host keys (rsa,dsa,ecdsa) */
ssh_key privkey;
ssh_string sig_blob = NULL;
+ ssh_string pubkey_blob = NULL;
int curve;
int len;
int rc;
@@ -289,14 +290,22 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
return SSH_ERROR;
}
+ rc = ssh_dh_get_next_server_publickey_blob(session, &pubkey_blob);
+ if (rc != SSH_OK) {
+ ssh_set_error(session, SSH_FATAL, "Could not export server public key");
+ ssh_string_free(sig_blob);
+ return SSH_ERROR;
+ }
+
rc = ssh_buffer_pack(session->out_buffer,
"bSSS",
SSH2_MSG_KEXDH_REPLY,
- session->next_crypto->server_pubkey, /* host's pubkey */
+ pubkey_blob, /* host's pubkey */
q_s_string, /* ecdh public key */
sig_blob); /* signature blob */
ssh_string_free(sig_blob);
+ ssh_string_free(pubkey_blob);
if (rc != SSH_OK) {
ssh_set_error_oom(session);