Free ECDSA and RSA structures when freeing a connection_t.

This commit is contained in:
Guus Sliepen 2011-07-10 21:02:34 +02:00
parent 73863fab8a
commit 027228debe
5 changed files with 30 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

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