Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2015-12-12 23:45:01 +0300
committerSamuel Neves <sneves@dei.uc.pt>2015-12-12 23:45:01 +0300
commitcfc536848ab8aca62961c7ee446006d53814132f (patch)
tree486296a86692a17d91d5191a65a932cfedce42c6
parent1c2b66c26d6d4914bf66a9c9ed7bbc2f98b9eec1 (diff)
replace secure_zero_memory
-rw-r--r--ref/blake2-impl.h7
-rw-r--r--sse/blake2-impl.h7
2 files changed, 8 insertions, 6 deletions
diff --git a/ref/blake2-impl.h b/ref/blake2-impl.h
index 5ac7a43..ae582a5 100644
--- a/ref/blake2-impl.h
+++ b/ref/blake2-impl.h
@@ -15,6 +15,7 @@
#define __BLAKE2_IMPL_H__
#include <stdint.h>
+#include <string.h>
static inline uint32_t load32( const void *src )
{
@@ -126,10 +127,10 @@ 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 )
+static inline void secure_zero_memory(void *v, size_t n)
{
- volatile uint8_t *p = ( volatile uint8_t * )v;
- while( n-- ) *p++ = 0;
+ static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
+ memset_v(v, 0, n);
}
#endif
diff --git a/sse/blake2-impl.h b/sse/blake2-impl.h
index 16219db..72c7e8a 100644
--- a/sse/blake2-impl.h
+++ b/sse/blake2-impl.h
@@ -15,6 +15,7 @@
#define __BLAKE2_IMPL_H__
#include <stdint.h>
+#include <string.h>
static inline uint32_t load32( const void *src )
{
@@ -126,10 +127,10 @@ 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 )
+static inline void secure_zero_memory(void *v, size_t n)
{
- volatile uint8_t *p = ( volatile uint8_t * )v;
- while( n-- ) *p++ = 0;
+ static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
+ memset_v(v, 0, n);
}
#endif