From: Guus Sliepen Date: Sun, 10 Jul 2011 19:02:34 +0000 (+0200) Subject: Free ECDSA and RSA structures when freeing a connection_t. X-Git-Tag: release-1.1pre2~20 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=027228debee2ea6f31cd176e456c13d626380066;p=tinc Free ECDSA and RSA structures when freeing a connection_t. --- diff --git a/src/connection.c b/src/connection.c index 62bfccb6..956607ca 100644 --- a/src/connection.c +++ b/src/connection.c @@ -69,6 +69,9 @@ void free_connection(connection_t *c) { cipher_close(&c->outcipher); digest_close(&c->outdigest); + ecdsa_free(&c->ecdsa); + rsa_free(&c->rsa); + if(c->hischallenge) free(c->hischallenge); diff --git a/src/openssl/ecdsa.c b/src/openssl/ecdsa.c index c3b96833..a4f0f30d 100644 --- a/src/openssl/ecdsa.c +++ b/src/openssl/ecdsa.c @@ -105,3 +105,14 @@ bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t len, const void *sig) { return true; } + +bool ecdsa_active(ecdsa_t *ecdsa) { + return *ecdsa; +} + +void ecdsa_free(ecdsa_t *ecdsa) { + if(*ecdsa) { + EC_KEY_free(*ecdsa); + *ecdsa = NULL; + } +} diff --git a/src/openssl/ecdsa.h b/src/openssl/ecdsa.h index fcdc3b37..cc0e7b02 100644 --- a/src/openssl/ecdsa.h +++ b/src/openssl/ecdsa.h @@ -30,5 +30,7 @@ extern bool ecdsa_read_pem_private_key(ecdsa_t *ecdsa, FILE *fp); extern size_t ecdsa_size(ecdsa_t *ecdsa); extern bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t inlen, void *out); extern bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t inlen, const void *out); +extern bool ecdsa_active(ecdsa_t *ecdsa); +extern void ecdsa_free(ecdsa_t *ecdsa); #endif diff --git a/src/openssl/rsa.c b/src/openssl/rsa.c index d39a1cba..c3ea692d 100644 --- a/src/openssl/rsa.c +++ b/src/openssl/rsa.c @@ -88,3 +88,14 @@ bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) { logger(LOG_ERR, "Unable to perform RSA decryption: %s", ERR_error_string(ERR_get_error(), NULL)); return false; } + +bool rsa_active(rsa_t *rsa) { + return *rsa; +} + +void rsa_free(rsa_t *rsa) { + if(*rsa) { + RSA_free(*rsa); + *rsa = NULL; + } +} diff --git a/src/openssl/rsa.h b/src/openssl/rsa.h index 62836a8e..10fe3462 100644 --- a/src/openssl/rsa.h +++ b/src/openssl/rsa.h @@ -31,5 +31,8 @@ extern bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp); extern size_t rsa_size(rsa_t *rsa); extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t inlen, void *out); extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t inlen, void *out); +extern bool rsa_active(rsa_t *rsa); +extern void rsa_free(rsa_t *rsa); + #endif