diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2018-03-27 14:55:01 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2018-03-27 14:55:01 +0000 |
commit | 2cb2ba6df8e31d389fd4bbfa73f0e6227dccb056 (patch) | |
tree | c548bb63a6a611d450f97880d0ed985cfc7d0121 | |
parent | ac663598dfc3812ab247d9637047885e906ec1be (diff) | |
download | src-2cb2ba6df8e31d389fd4bbfa73f0e6227dccb056.tar.gz src-2cb2ba6df8e31d389fd4bbfa73f0e6227dccb056.zip |
MFV: libb2: use native calls for secure memory clearance
Drop our local patch and restore full vanilla upstream code in
contrib/libb2.
No functional change intended. explicit_bzero() should continue to be used.
Obtained from: libb2 b4b241a34824b51956a7866606329a065d397525
Sponsored by: Dell EMC Isilon
Notes
Notes:
svn path=/head/; revision=331620
-rw-r--r-- | sys/contrib/libb2/blake2-impl.h | 15 | ||||
-rw-r--r-- | sys/crypto/blake2/config.h | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sys/contrib/libb2/blake2-impl.h b/sys/contrib/libb2/blake2-impl.h index dd8b9b763723..222b61279c18 100644 --- a/sys/contrib/libb2/blake2-impl.h +++ b/sys/contrib/libb2/blake2-impl.h @@ -131,11 +131,20 @@ static inline uint64_t rotr64( const uint64_t w, const unsigned c ) /* prevents compiler optimizing out memset() */ static inline void secure_zero_memory(void *v, size_t n) { -#ifdef __FreeBSD__ +#if defined(_WIN32) || defined(WIN32) + SecureZeroMemory(v, n); +#else +// prioritize first the general C11 call +#if defined(HAVE_MEMSET_S) + memset_s(v, n, 0, n); +#elif defined(HAVE_EXPLICIT_BZERO) explicit_bzero(v, n); +#elif defined(HAVE_EXPLICIT_MEMSET) + explicit_memset(v, 0, n); #else - static void *(*const volatile memset_v)(void *, int, size_t) = &memset; - memset_v(v, 0, n); + memset(v, 0, n); + __asm__ __volatile__("" :: "r"(v) : "memory"); +#endif #endif } diff --git a/sys/crypto/blake2/config.h b/sys/crypto/blake2/config.h index 9ceba827f3d1..0471a1fedc20 100644 --- a/sys/crypto/blake2/config.h +++ b/sys/crypto/blake2/config.h @@ -17,3 +17,5 @@ #else #define HAVE_ALIGNED_ACCESS_REQUIRED 1 #endif + +#define HAVE_EXPLICIT_BZERO 1 |