1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

wrapper: Reformat crypto_free()

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2018-09-03 17:39:56 +02:00
parent 7867126aa6
commit 9c5d2d4543

View File

@@ -146,7 +146,8 @@ struct ssh_crypto_struct *crypto_new(void) {
return crypto; return crypto;
} }
void crypto_free(struct ssh_crypto_struct *crypto){ void crypto_free(struct ssh_crypto_struct *crypto)
{
int i; int i;
if (crypto == NULL) { if (crypto == NULL) {
return; return;
@@ -174,11 +175,11 @@ void crypto_free(struct ssh_crypto_struct *crypto){
crypto->ecdh_privkey = NULL; crypto->ecdh_privkey = NULL;
} }
#endif #endif
if(crypto->session_id != NULL){ if (crypto->session_id != NULL) {
memset(crypto->session_id, '\0', crypto->digest_len); memset(crypto->session_id, '\0', crypto->digest_len);
SAFE_FREE(crypto->session_id); SAFE_FREE(crypto->session_id);
} }
if(crypto->secret_hash != NULL){ if (crypto->secret_hash != NULL) {
memset(crypto->secret_hash, '\0', crypto->digest_len); memset(crypto->secret_hash, '\0', crypto->digest_len);
SAFE_FREE(crypto->secret_hash); SAFE_FREE(crypto->secret_hash);
} }
@@ -195,19 +196,15 @@ void crypto_free(struct ssh_crypto_struct *crypto){
} }
SAFE_FREE(crypto->compress_in_ctx); SAFE_FREE(crypto->compress_in_ctx);
#endif /* WITH_ZLIB */ #endif /* WITH_ZLIB */
if(crypto->encryptIV)
SAFE_FREE(crypto->encryptIV); SAFE_FREE(crypto->encryptIV);
if(crypto->decryptIV)
SAFE_FREE(crypto->decryptIV); SAFE_FREE(crypto->decryptIV);
if(crypto->encryptMAC)
SAFE_FREE(crypto->encryptMAC); SAFE_FREE(crypto->encryptMAC);
if(crypto->decryptMAC)
SAFE_FREE(crypto->decryptMAC); SAFE_FREE(crypto->decryptMAC);
if(crypto->encryptkey){ if (crypto->encryptkey != NULL) {
memset(crypto->encryptkey, 0, crypto->digest_len); memset(crypto->encryptkey, 0, crypto->digest_len);
SAFE_FREE(crypto->encryptkey); SAFE_FREE(crypto->encryptkey);
} }
if(crypto->decryptkey){ if (crypto->decryptkey != NULL) {
memset(crypto->decryptkey, 0, crypto->digest_len); memset(crypto->decryptkey, 0, crypto->digest_len);
SAFE_FREE(crypto->decryptkey); SAFE_FREE(crypto->decryptkey);
} }