chore(cherry-pick): Cherry-picking commit 5d5c005: Fix burn_stack performance issue
performance(sqlcipher): Fix burn_stack performance issue
This commit is contained in:
parent
25f68adb9f
commit
f0c26bafb5
23
burn_stack.c
23
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$ */
|
||||
|
|
10
zeromem.c
10
zeromem.c
|
@ -1,6 +1,7 @@
|
|||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
|
||||
/* SPDX-License-Identifier: Unlicense */
|
||||
#include "tomcrypt_private.h"
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
@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$ */
|
||||
|
|
Loading…
Reference in New Issue