diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ecdh.c | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -285,12 +285,6 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){ session->next_crypto->ecdh_privkey = ecdh_key; session->next_crypto->ecdh_server_pubkey = q_s_string; - rc = buffer_add_u8(session->out_buffer, SSH2_MSG_KEXDH_REPLY); - if (rc < 0) { - ssh_set_error_oom(session); - return SSH_ERROR; - } - /* build k and session_id */ rc = ecdh_build_k(session); if (rc < 0) { @@ -310,30 +304,22 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){ return SSH_ERROR; } - /* add host's public key */ - rc = buffer_add_ssh_string(session->out_buffer, - session->next_crypto->server_pubkey); - if (rc < 0) { - ssh_set_error_oom(session); - return SSH_ERROR; - } - - /* add ecdh public key */ - rc = buffer_add_ssh_string(session->out_buffer, q_s_string); - if (rc < 0) { - ssh_set_error_oom(session); - return SSH_ERROR; - } - /* add signature blob */ sig_blob = ssh_srv_pki_do_sign_sessionid(session, privkey); if (sig_blob == NULL) { ssh_set_error(session, SSH_FATAL, "Could not sign the session id"); return SSH_ERROR; } - rc = buffer_add_ssh_string(session->out_buffer, sig_blob); + rc = ssh_buffer_pack(session->out_buffer, + "bSSS", + SSH2_MSG_KEXDH_REPLY, + session->next_crypto->server_pubkey, /* host's pubkey */ + q_s_string, /* ecdh public key */ + sig_blob); /* signature blob */ + ssh_string_free(sig_blob); - if (rc < 0) { + + if (rc != SSH_OK) { ssh_set_error_oom(session); return SSH_ERROR; } |