diff --git a/libretroshare/src/gxs/gxssecurity.cc b/libretroshare/src/gxs/gxssecurity.cc index c321969d2..7d200ab86 100644 --- a/libretroshare/src/gxs/gxssecurity.cc +++ b/libretroshare/src/gxs/gxssecurity.cc @@ -582,6 +582,8 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u // intialize context and send store encrypted cipher in ek if(!EVP_SealInit(ctx, EVP_aes_128_cbc(), &ek, &eklen, iv, &public_key, 1)) return false; + EVP_PKEY_free(public_key) ; + // now assign memory to out accounting for data, and cipher block size, key length, and key length val out = (uint8_t*)rs_malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH) ; @@ -859,6 +861,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in, std::cerr << "(EE) Cannot decrypt data. Most likely reason: private GXS key is missing." << std::endl; return false; } + EVP_PKEY_free(privateKey) ; if(inlen < (uint32_t)in_offset) {