aboutsummaryrefslogtreecommitdiff
path: root/src/dh.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2018-11-06 22:22:59 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-24 12:56:14 +0100
commit40faa98c5ee0c834879c1ea7a7b3e347893e8fed (patch)
tree696786bb92639b192e15907e5856f46bc2096a2c /src/dh.c
parent94070658792df7d50fe8320caecfcf17534fe455 (diff)
downloadlibssh-40faa98c5ee0c834879c1ea7a7b3e347893e8fed.tar.gz
libssh-40faa98c5ee0c834879c1ea7a7b3e347893e8fed.tar.xz
libssh-40faa98c5ee0c834879c1ea7a7b3e347893e8fed.zip
wrapper: Move dh cleanup into dh.c
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/dh.c')
-rw-r--r--src/dh.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/dh.c b/src/dh.c
index f6a9a039..8301a8dc 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -357,8 +357,7 @@ int ssh_dh_init_common(ssh_session session){
}
}
-void ssh_dh_cleanup(ssh_session session){
- struct ssh_crypto_struct *crypto=session->next_crypto;
+void ssh_dh_cleanup(struct ssh_crypto_struct *crypto){
bignum_safe_free(crypto->x);
bignum_safe_free(crypto->y);
bignum_safe_free(crypto->e);
@@ -521,7 +520,7 @@ int ssh_client_dh_init(ssh_session session){
rc = ssh_packet_send(session);
return rc;
error:
- ssh_dh_cleanup(session);
+ ssh_dh_cleanup(session->next_crypto);
return SSH_ERROR;
}
@@ -566,7 +565,7 @@ SSH_PACKET_CALLBACK(ssh_packet_client_dh_reply){
session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
return SSH_PACKET_USED;
error:
- ssh_dh_cleanup(session);
+ ssh_dh_cleanup(session->next_crypto);
session->session_state=SSH_SESSION_STATE_ERROR;
return SSH_PACKET_USED;
}
@@ -689,15 +688,14 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dh_init)
}
SSH_LOG(SSH_LOG_PACKET, "SSH_MSG_NEWKEYS sent");
session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
- ssh_dh_cleanup(session);
return SSH_PACKET_USED;
error:
- ssh_dh_cleanup(session);
if (!bignum_ctx_invalid(ctx)) {
bignum_ctx_free(ctx);
}
session->session_state = SSH_SESSION_STATE_ERROR;
+ ssh_dh_cleanup(session->next_crypto);
return SSH_PACKET_USED;
}