Merge branch 'master' of github.com:jedisct1/libsodium
* 'master' of github.com:jedisct1/libsodium: Register sodium_stackzero() Add sodium_stackzero() Check for alloca()
This commit is contained in:
commit
82efb10fc1
@ -744,6 +744,7 @@ __sync_lock_release(&_sodium_lock);
|
||||
|
||||
dnl Checks for functions and headers
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AS_IF([test "x$EMSCRIPTEN" = "x"],[
|
||||
AC_CHECK_FUNCS([arc4random arc4random_buf])
|
||||
AC_CHECK_FUNCS([mmap mlock madvise mprotect memset_s explicit_bzero nanosleep])
|
||||
|
@ -558,5 +558,6 @@ _sodium_runtime_has_sse3 0 0
|
||||
_sodium_runtime_has_sse41 0 0
|
||||
_sodium_runtime_has_ssse3 0 0
|
||||
_sodium_set_misuse_handler 0 0
|
||||
_sodium_stackzero 0 0
|
||||
_sodium_unpad 1 1
|
||||
_sodium_version_string 1 1
|
||||
|
@ -21,6 +21,9 @@ extern "C" {
|
||||
SODIUM_EXPORT
|
||||
void sodium_memzero(void * const pnt, const size_t len);
|
||||
|
||||
SODIUM_EXPORT
|
||||
void sodium_stackzero(const size_t len);
|
||||
|
||||
/*
|
||||
* WARNING: sodium_memcmp() must be used to verify if two secret keys
|
||||
* are equal, in constant time.
|
||||
|
@ -21,6 +21,23 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
#elif defined __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
#elif defined _AIX
|
||||
# define alloca __alloca
|
||||
#elif defined _MSC_VER
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
#else
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
void *alloca (size_t);
|
||||
#endif
|
||||
|
||||
#include "core.h"
|
||||
#include "randombytes.h"
|
||||
#include "utils.h"
|
||||
@ -106,6 +123,17 @@ sodium_memzero(void *const pnt, const size_t len)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
sodium_stackzero(const size_t len)
|
||||
{
|
||||
#ifdef HAVE_ALLOCA
|
||||
sodium_memzero(alloca(len), len);
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
unsigned char fodder[len];
|
||||
sodium_memzero(fodder, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_WEAK_SYMBOLS
|
||||
__attribute__((weak)) void
|
||||
_sodium_dummy_symbol_to_prevent_memcmp_lto(const unsigned char *b1,
|
||||
|
Loading…
Reference in New Issue
Block a user