diff --git a/burn_stack.c b/burn_stack.c index 5d276a4..9cc9826 100644 --- a/burn_stack.c +++ b/burn_stack.c @@ -1,6 +1,14 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis */ -/* SPDX-License-Identifier: Unlicense */ -#include "tomcrypt_private.h" +/* 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" /** @file burn_stack.c @@ -13,11 +21,12 @@ */ void burn_stack(unsigned long len) { - unsigned char buf[32]; + unsigned char buf[len]; zeromem(buf, sizeof(buf)); - if (len > (unsigned long)sizeof(buf)) { - burn_stack(len - sizeof(buf)); - } } + +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */ diff --git a/zeromem.c b/zeromem.c index 7d14994..b2ae036 100644 --- a/zeromem.c +++ b/zeromem.c @@ -1,6 +1,7 @@ /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ /* SPDX-License-Identifier: Unlicense */ #include "tomcrypt_private.h" +#include /** @file zeromem.c @@ -14,9 +15,10 @@ */ void zeromem(volatile void *out, size_t outlen) { - volatile char *mem = out; LTC_ARGCHKVD(out != NULL); - while (outlen-- > 0) { - *mem++ = '\0'; - } + memset((void *)out, 0, outlen); } + +/* $Source$ */ +/* $Revision$ */ +/* $Date$ */