unsigned char *key, unsigned char *iv, int enc)
{
if(enc && (enc != -1)) enc = 1;
- if (cipher) {
+ if (cipher)
+ {
+ if(ctx->cipher_data)
+ OPENSSL_free(ctx->cipher_data);
ctx->cipher=cipher;
+ ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
ctx->key_len = cipher->key_len;
ctx->flags = 0;
if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT) {
{
if(!c->cipher->cleanup(c)) return 0;
}
+ OPENSSL_free(c->cipher_data);
memset(c,0,sizeof(EVP_CIPHER_CTX));
return 1;
}