summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2014-04-17 17:08:16 +0200
committerAndreas Schneider <asn@cryptomilk.org>2014-08-06 09:46:14 +0200
commit9457685320fe418263952469737c3ffd00f9dbcc (patch)
tree4f7bd98cd0d39c071bcc226e0c6b19673711b948 /src
parente9fd14c7f0313192753d674300704de47f0c41eb (diff)
downloadlibssh-9457685320fe418263952469737c3ffd00f9dbcc.tar.gz
libssh-9457685320fe418263952469737c3ffd00f9dbcc.tar.xz
libssh-9457685320fe418263952469737c3ffd00f9dbcc.zip
buffers: adapt ecdh.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/ecdh.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/ecdh.c b/src/ecdh.c
index ba8da591..0e48c374 100644
--- a/src/ecdh.c
+++ b/src/ecdh.c
@@ -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;
}