Choose a faster memwipe implementation
Our current memwipe implementation (see #7352 (moved)) was chosen for being very-likely-to-be-safe, not for its speed. We could get much faster, probably: All we really need is a memwipe, plus some way to tell the compiler that the memwipe shouldn't be eliminated.
One GCC-only option is
void memwipe(void *p, uint8_t b, size_t sz) __attribtue__((noinline));
void memwipe(void *p, uint8_t b, size_t sz)
{
memset(p, b, sz);
}
Another, crazier GCC-only option is
inline void
memwipe(void *p, uint8_t b, size_t sz)
{
memset(p, b, sz);
asm("" ::: "memory");
}
And on windows, one could probably say
void
memwipe(void *p, uint8_t b, size_t sz)
{
SecureZeroMemory(p, sz);
}
if b == 0.
Probably, we shouldn't bother to do any of these unless it turns out that OPENSSL_cleanse() is showing up in our profiles.