tor  master
Functions
crypto_util.h File Reference

Common functions for cryptographic routines. More...

#include "torint.h"
Include dependency graph for crypto_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void memwipe (void *mem, uint8_t byte, size_t sz)
 

Detailed Description

Common functions for cryptographic routines.

Function Documentation

◆ memwipe()

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().

Here is the caller graph for this function: