aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_abe.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2017-10-10 16:01:14 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2017-10-10 16:01:14 +0200
commit1cfa320f0cb213aed0a3a04577d065a65f847d49 (patch)
treecaf0db997af48e9599c964cfccc9953ed0baca24 /src/util/crypto_abe.c
parentdf344790f7f2e7c39cfd951ce373c4ec52b6cda7 (diff)
downloadgnunet-1cfa320f0cb213aed0a3a04577d065a65f847d49.tar.gz
gnunet-1cfa320f0cb213aed0a3a04577d065a65f847d49.zip
-bugfixes, fix memleaks
Diffstat (limited to 'src/util/crypto_abe.c')
-rw-r--r--src/util/crypto_abe.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/util/crypto_abe.c b/src/util/crypto_abe.c
index f52cd5213..fcaa826ed 100644
--- a/src/util/crypto_abe.c
+++ b/src/util/crypto_abe.c
@@ -159,7 +159,10 @@ GNUNET_CRYPTO_cpabe_create_master_key (void)
159void 159void
160GNUNET_CRYPTO_cpabe_delete_master_key (struct GNUNET_CRYPTO_AbeMasterKey *key) 160GNUNET_CRYPTO_cpabe_delete_master_key (struct GNUNET_CRYPTO_AbeMasterKey *key)
161{ 161{
162 gabe_msk_free (key->msk); //For some reason free of pub implicit? 162 gabe_msk_free (key->msk);
163 gabe_pub_free (key->pub);
164 //GNUNET_free (key->msk);
165 //gabe_msk_free (key->msk); //For some reason free of pub implicit?
163 GNUNET_free (key); 166 GNUNET_free (key);
164} 167}
165 168
@@ -175,15 +178,19 @@ GNUNET_CRYPTO_cpabe_create_key (struct GNUNET_CRYPTO_AbeMasterKey *key,
175 prv_key->prv = gabe_keygen(key->pub, key->msk, attrs); 178 prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
176 size = gabe_pub_serialize(key->pub, &tmp); 179 size = gabe_pub_serialize(key->pub, &tmp);
177 prv_key->pub = gabe_pub_unserialize(tmp, size); 180 prv_key->pub = gabe_pub_unserialize(tmp, size);
181 GNUNET_free (tmp);
178 GNUNET_assert (NULL != prv_key->prv); 182 GNUNET_assert (NULL != prv_key->prv);
179 return prv_key; 183 return prv_key;
180} 184}
181 185
182void 186void
183GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key) 187GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key,
188 int delete_pub)
184{ 189{
185 //Memory management in gabe is buggy 190 //Memory management in gabe is buggy
186 //gabe_prv_free (prv); 191 gabe_prv_free (key->prv);
192 if (GNUNET_YES == delete_pub)
193 gabe_pub_free (key->pub);
187 GNUNET_free (key); 194 GNUNET_free (key);
188} 195}
189 196
@@ -266,6 +273,7 @@ GNUNET_CRYPTO_cpabe_encrypt (const void *block,
266 cph_buf_len = gabe_cph_serialize(cph, 273 cph_buf_len = gabe_cph_serialize(cph,
267 &cph_buf); 274 &cph_buf);
268 gabe_cph_free(cph); 275 gabe_cph_free(cph);
276 GNUNET_free (cph);
269 plt = GNUNET_memdup (block, size); 277 plt = GNUNET_memdup (block, size);
270 aes_buf_len = aes_128_cbc_encrypt(plt, size, m, &aes_buf); 278 aes_buf_len = aes_128_cbc_encrypt(plt, size, m, &aes_buf);
271 GNUNET_free (plt); 279 GNUNET_free (plt);
@@ -293,14 +301,21 @@ GNUNET_CRYPTO_cpabe_decrypt (const void *block,
293 read_cpabe(block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size); 301 read_cpabe(block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size);
294 cph = gabe_cph_unserialize(key->pub, cph_buf, cph_buf_size); 302 cph = gabe_cph_unserialize(key->pub, cph_buf, cph_buf_size);
295 if( !gabe_dec(key->pub, key->prv, cph, m) ) { 303 if( !gabe_dec(key->pub, key->prv, cph, m) ) {
296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
297 "%s\n", gabe_error()); 305 "%s\n", gabe_error());
306 GNUNET_free (aes_buf);
307 GNUNET_free (cph_buf);
298 gabe_cph_free(cph); 308 gabe_cph_free(cph);
309 GNUNET_free (cph);
310 element_clear (m);
299 return GNUNET_SYSERR; 311 return GNUNET_SYSERR;
300 } 312 }
301 gabe_cph_free(cph); 313 gabe_cph_free(cph);
314 GNUNET_free (cph);
302 plt_len = aes_128_cbc_decrypt(aes_buf, aes_buf_size, m, (char**)result); 315 plt_len = aes_128_cbc_decrypt(aes_buf, aes_buf_size, m, (char**)result);
316 GNUNET_free (cph_buf);
303 GNUNET_free (aes_buf); 317 GNUNET_free (aes_buf);
318 element_clear (m);
304 //freeing is buggy in gabe 319 //freeing is buggy in gabe
305 //gabe_prv_free (prv); 320 //gabe_prv_free (prv);
306 //gabe_pub_free (pub); 321 //gabe_pub_free (pub);