<div dir="ltr">Can anyone point me at some best practices for implementing buffer types for storing secrets?<div><br></div><div>There are the general coding rules at <a href="http://cryptocoding.net">cryptocoding.net</a> for example, that say you should use unsigned bytes and zero memory when you're done, but I'm more curious about specific strategies, like:</div>

<div><br></div><div>- malloc/free + separate process for crypto</div><div>- malloc/free + mlock/munlock + "secure zeroing"</div><div>- mmap/munmap (+ mlock/munlock)</div><div><br></div><div>Should finalizers be explicit or implicit? (or should an implicit finalizer try to make sure buffers are finalized if you don't do it yourself?)</div>

<div><div><br></div><div>Are paranoid buffers worth the effort? Are the threats they'd potentially mitigate realistic? Are there too many other things that can go wrong (e.g. rewindable VMs) for this to matter?</div>
<div>
<br></div>--<br>Tony Arcieri<br>
</div></div>