return false;
}
+ free(cipher);
+
regenerate_key();
/* Check if we want to use message authentication codes... */
return false;
}
+ free(digest);
+
/* Compression */
if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) {
if(outgoing->ai)
freeaddrinfo(outgoing->ai);
+ if(outgoing->config_tree)
+ exit_configuration(&outgoing->config_tree);
+
if(outgoing->name)
free(outgoing->name);
void cipher_close(cipher_t *cipher) {
EVP_CIPHER_CTX_cleanup(&cipher->ctx);
- if(cipher->counter) {
- free(cipher->counter);
- cipher->counter = 0;
- }
+ free(cipher->counter);
+ cipher->counter = NULL;
}
size_t cipher_keylength(const cipher_t *cipher) {
}
void digest_close(digest_t *digest) {
- if(digest->key)
- free(digest->key);
+ free(digest->key);
digest->key = NULL;
}
size_t keylen = cipher_keylength(&myself->incipher);
char key[keylen * 2 + 1];
+ cipher_close(&to->incipher);
+ digest_close(&to->indigest);
+
cipher_open_by_nid(&to->incipher, cipher_get_nid(&myself->incipher));
digest_open_by_nid(&to->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest));
to->incompression = myself->incompression;
}
/* Don't use key material until every check has passed. */
+ cipher_close(&from->outcipher);
+ digest_close(&from->outdigest);
from->status.validkey = false;
if(compression < 0 || compression > 11) {
// Stop a SPTPS session.
bool sptps_stop(sptps_t *s) {
// Clean up any resources.
+ cipher_close(&s->incipher);
+ cipher_close(&s->outcipher);
+ digest_close(&s->indigest);
+ digest_close(&s->outdigest);
ecdh_free(&s->ecdh);
free(s->inbuf);
- s->inbuf = NULL;
free(s->mykex);
- s->mykex = NULL;
free(s->hiskex);
- s->hiskex = NULL;
free(s->key);
- s->key = NULL;
free(s->label);
- s->label = NULL;
free(s->late);
- s->late = NULL;
+ memset(s, 0, sizeof *s);
return true;
}