chore(cherry-pick): Cherry-picking commit 5d5c005: Fix burn_stack performance issue

performance(sqlcipher): Fix burn_stack performance issue
This commit is contained in:
Alex Jbanca 2023-05-10 12:22:14 +03:00 committed by Alex Jbanca
parent 25f68adb9f
commit f0c26bafb5
No known key found for this signature in database
GPG Key ID: 6004079575C21C5D
2 changed files with 22 additions and 11 deletions

View File

@ -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$ */

View File

@ -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$ */