tor
master
|
Common functions for cryptographic routines. More...
#include "torint.h"
Go to the source code of this file.
Functions | |
void | memwipe (void *mem, uint8_t byte, size_t sz) |
Common functions for cryptographic routines.
void memwipe | ( | void * | mem, |
uint8_t | byte, | ||
size_t | sz | ||
) |
OpenSSL-based utility functions.
Destroy the sz bytes of data stored at mem, setting them to the value byte. If mem is NULL or sz is zero, nothing happens.
This function is preferable to memset, since many compilers will happily optimize out memset() when they can convince themselves that the data being cleared will never be read.
Right now, our convention is to use this function when we are wiping data that's about to become inaccessible, such as stack buffers that are about to go out of scope or structures that are about to get freed. (In practice, it appears that the compilers we're currently using will optimize out the memset()s for stack-allocated buffers, but not those for about-to-be-freed structures. That could change, though, so we're being wary.) If there are live reads for the data, then you can just use memset().