Add missing sodium_free() calls in the kdf test

This commit is contained in:
Frank Denis 2017-12-16 14:31:01 +01:00
parent 765710c1f4
commit afbef83c6b

View File

@ -13,8 +13,9 @@ tv_kdf(void)
int ret; int ret;
context = (char *) sodium_malloc(crypto_kdf_CONTEXTBYTES); context = (char *) sodium_malloc(crypto_kdf_CONTEXTBYTES);
memcpy(context, "KDF test", strlen("KDF test"));
master_key = (unsigned char *) sodium_malloc(crypto_kdf_KEYBYTES); master_key = (unsigned char *) sodium_malloc(crypto_kdf_KEYBYTES);
memcpy(context, "KDF test", strlen("KDF test"));
for (i = 0; i < crypto_kdf_KEYBYTES; i++) { for (i = 0; i < crypto_kdf_KEYBYTES; i++) {
master_key[i] = i; master_key[i] = i;
} }
@ -41,6 +42,9 @@ tv_kdf(void)
sodium_free(subkey); sodium_free(subkey);
} }
sodium_free(master_key);
sodium_free(context);
assert(strcmp(crypto_kdf_primitive(), crypto_kdf_PRIMITIVE) == 0); assert(strcmp(crypto_kdf_primitive(), crypto_kdf_PRIMITIVE) == 0);
assert(crypto_kdf_BYTES_MAX > 0); assert(crypto_kdf_BYTES_MAX > 0);
assert(crypto_kdf_BYTES_MIN <= crypto_kdf_BYTES_MAX); assert(crypto_kdf_BYTES_MIN <= crypto_kdf_BYTES_MAX);