1
1

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>
Этот коммит содержится в:
Aris Adamantiadis 2018-11-06 22:22:59 +01:00 коммит произвёл Andreas Schneider
родитель 9407065879
Коммит 40faa98c5e
4 изменённых файлов: 9 добавлений и 14 удалений

Просмотреть файл

@ -45,7 +45,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_ */

Просмотреть файл

@ -85,7 +85,7 @@ int ssh_client_dhgex_init(ssh_session session)
}
return rc;
error:
ssh_dh_cleanup(session);
ssh_dh_cleanup(session->next_crypto);
return SSH_ERROR;
}
@ -201,7 +201,7 @@ error:
if(!bignum_ctx_invalid(ctx)) {
bignum_ctx_free(ctx);
}
ssh_dh_cleanup(session);
ssh_dh_cleanup(session->next_crypto);
session->session_state = SSH_SESSION_STATE_ERROR;
return SSH_PACKET_USED;
@ -252,7 +252,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_client_dhgex_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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -165,10 +165,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);