diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2017-06-11 00:28:52 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2017-06-11 00:28:52 +0200 |
commit | 6f8ec3062c8b7f21a6995d498c3aae8f106bda8f (patch) | |
tree | b7a7501a2c96a7b122718f83c5571c7d5fd83be8 | |
parent | a726497a953a263c6115706e449a5b78c86647ac (diff) | |
download | libssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.tar.gz libssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.tar.xz libssh-6f8ec3062c8b7f21a6995d498c3aae8f106bda8f.zip |
dh: move cleanup into dh.c
-rw-r--r-- | include/libssh/dh.h | 2 | ||||
-rw-r--r-- | src/dh.c | 7 | ||||
-rw-r--r-- | src/wrapper.c | 6 |
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_ */ @@ -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); |