mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
Improve crypto free functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@387 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -466,21 +466,23 @@ static void cipher_free(struct crypto_struct *cipher){
|
|||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cipher == NULL) {
|
if (cipher == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cipher->key) {
|
if(cipher->key) {
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
for (i=0;i<cipher->keylen/sizeof (gcry_cipher_hd_t);i++)
|
for (i = 0; i < (cipher->keylen / sizeof(gcry_cipher_hd_t)); i++) {
|
||||||
gcry_cipher_close(cipher->key[i]);
|
gcry_cipher_close(cipher->key[i]);
|
||||||
|
}
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
/* destroy the key */
|
/* destroy the key */
|
||||||
memset(cipher->key, 0, cipher->keylen);
|
memset(cipher->key, 0, cipher->keylen);
|
||||||
#endif
|
#endif
|
||||||
free(cipher->key);
|
SAFE_FREE(cipher->key);
|
||||||
}
|
}
|
||||||
free(cipher);
|
SAFE_FREE(cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRYPTO *crypto_new(void) {
|
CRYPTO *crypto_new(void) {
|
||||||
@@ -500,26 +502,22 @@ void crypto_free(CRYPTO *crypto){
|
|||||||
if (crypto == NULL) {
|
if (crypto == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(crypto->server_pubkey)
|
|
||||||
free(crypto->server_pubkey);
|
SAFE_FREE(crypto->server_pubkey);
|
||||||
if(crypto->in_cipher)
|
|
||||||
cipher_free(crypto->in_cipher);
|
cipher_free(crypto->in_cipher);
|
||||||
if(crypto->out_cipher)
|
|
||||||
cipher_free(crypto->out_cipher);
|
cipher_free(crypto->out_cipher);
|
||||||
if(crypto->e)
|
|
||||||
bignum_free(crypto->e);
|
bignum_free(crypto->e);
|
||||||
if(crypto->f)
|
|
||||||
bignum_free(crypto->f);
|
bignum_free(crypto->f);
|
||||||
if(crypto->x)
|
|
||||||
bignum_free(crypto->x);
|
bignum_free(crypto->x);
|
||||||
if(crypto->y)
|
|
||||||
bignum_free(crypto->y);
|
bignum_free(crypto->y);
|
||||||
if(crypto->k)
|
|
||||||
bignum_free(crypto->k);
|
bignum_free(crypto->k);
|
||||||
/* lot of other things */
|
/* lot of other things */
|
||||||
/* i'm lost in my own code. good work */
|
/* i'm lost in my own code. good work */
|
||||||
memset(crypto,0,sizeof(*crypto));
|
memset(crypto,0,sizeof(*crypto));
|
||||||
free(crypto);
|
|
||||||
|
SAFE_FREE(crypto);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int crypt_set_algorithms2(SSH_SESSION *session){
|
static int crypt_set_algorithms2(SSH_SESSION *session){
|
||||||
|
|||||||
Reference in New Issue
Block a user