aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2017-06-11 00:28:52 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2017-06-11 00:28:52 +0200
commit6f8ec3062c8b7f21a6995d498c3aae8f106bda8f (patch)
treeb7a7501a2c96a7b122718f83c5571c7d5fd83be8
parenta726497a953a263c6115706e449a5b78c86647ac (diff)
downloadlibssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.tar.gz
libssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.tar.xz
libssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.zip
dh: move cleanup into dh.c
-rw-r--r--include/libssh/dh.h2
-rw-r--r--src/dh.c7
-rw-r--r--src/wrapper.c6
3 files changed, 5 insertions, 10 deletions
diff --git a/include/libssh/dh.h b/include/libssh/dh.h
index effa0183..b270abf5 100644
--- a/include/libssh/dh.h
+++ b/include/libssh/dh.h
@@ -36,7 +36,7 @@ void ssh_server_dh_init(ssh_session session);
#endif /* WITH_SERVER */
int ssh_dh_init_common(ssh_session session);
-void ssh_dh_cleanup(ssh_session session);
+void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
int ssh_dh_generate_secret(ssh_session session, bignum dest);
#endif /* DH_H_ */
diff --git a/src/dh.c b/src/dh.c
index 727adcc2..6845b396 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -159,8 +159,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);
@@ -302,7 +301,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;
}
@@ -342,7 +341,7 @@ SSH_PACKET_CALLBACK(ssh_packet_client_dh_reply){
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;
}
diff --git a/src/wrapper.c b/src/wrapper.c
index 951016ee..13215bd5 100644
--- a/src/wrapper.c
+++ b/src/wrapper.c
@@ -160,11 +160,7 @@ void crypto_free(struct ssh_crypto_struct *crypto){
cipher_free(crypto->in_cipher);
cipher_free(crypto->out_cipher);
-
- bignum_safe_free(crypto->e);
- bignum_safe_free(crypto->f);
- bignum_safe_free(crypto->x);
- bignum_safe_free(crypto->y);
+ ssh_dh_cleanup(crypto);
bignum_safe_free(crypto->k);
#ifdef HAVE_ECDH
SAFE_FREE(crypto->ecdh_client_pubkey);