Is zeroing user or lib responsibility

I’m making a core password manager/vault library, and I’m wondering whether I should zero the memory or the user should do this.

One way they could do this is through a ZeroingAllocator, which std.crypto.secureZero’s all memory that is freed. This also makes it easier for me because I have a StringHashMap where the keys need to be freed, and the allocators already @constCast.

Two problems with this:

  1. User doesn’t know about having to do this.
  2. User would prefer not to worry about it and have the library do it for them.

I could maybe provide a ZeroingAllocator with the library in the second problem, but I would like to know what other people think!

As far as I can tell, a most misuse resistant way is to do it yourself, either with a custom allocator that wraps the one the user provides or manually. Do see Frank Denis’ series on zeroization:

Thank you, I didn’t think of wrapping the user provided Allocator with ZeroingAllocator! I’ll make sure to read the series.