Hi, it sounds like you are looking for a way to clear allocated buffer with zero's on the free? If you are overriding the allocators for wolfSSL then you could do something like this:
void* my_Malloc(size_t size)
{
void* ptr;
ptr = malloc(size + sizeof(size_t));
if (ptr) {
*(size_t*)ptr = size;
ptr += sizeof(size_t);
memset(ptr, 0, size);
}
return ptr;
}
void my_Free(void *ptr)
{
if (ptr) {
size_t size = 0;
ptr -= sizeof(size_t);
size = *(size_t*)ptr;
memset(ptr, 0, size);
free(ptr);
}
}
wolfSSL_SetAllocators(my_Malloc, my_Free, NULL);
This allocates some extra space at the front and stores the length in it. Let me know if that makes sense or not.
Thanks,
David Garske, wolfSSL