2018-09-24 18:07:34 +00:00
|
|
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
|
|
|
*
|
|
|
|
* LibTomCrypt is a library that provides various cryptographic
|
|
|
|
* algorithms in a highly modular and flexible manner.
|
|
|
|
*
|
|
|
|
* The library is free for all purposes without any express
|
|
|
|
* guarantee it works.
|
|
|
|
*
|
|
|
|
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
|
|
|
*/
|
|
|
|
#include "tomcrypt.h"
|
2023-05-08 11:34:36 +00:00
|
|
|
#include <string.h>
|
2018-09-24 18:07:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@file zeromem.c
|
|
|
|
Zero a block of memory, Tom St Denis
|
|
|
|
*/
|
|
|
|
|
2023-05-08 11:34:36 +00:00
|
|
|
/*
|
|
|
|
* Pointer to memset is volatile so that compiler must de-reference
|
|
|
|
* the pointer and can't assume that it points to any function in
|
|
|
|
* particular (such as memset, which it then might further "optimize")
|
|
|
|
*/
|
|
|
|
typedef void *(*memset_t)(void *, int, size_t);
|
|
|
|
|
|
|
|
static volatile memset_t memset_func = memset;
|
|
|
|
|
2018-09-24 18:07:34 +00:00
|
|
|
/**
|
|
|
|
Zero a block of memory
|
|
|
|
@param out The destination of the area to zero
|
|
|
|
@param outlen The length of the area to zero (octets)
|
|
|
|
*/
|
|
|
|
void zeromem(void *out, size_t outlen)
|
|
|
|
{
|
|
|
|
LTC_ARGCHKVD(out != NULL);
|
2023-05-08 11:34:36 +00:00
|
|
|
memset_func((void *)out, 0, outlen);
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* $Source$ */
|
|
|
|
/* $Revision$ */
|
|
|
|
/* $Date$ */
|