wg: dedup secret normalization

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-01-31 15:58:17 +01:00
parent 1e5d6b9a66
commit bc3f283148

View file

@ -35,6 +35,7 @@ typedef u32 __le32;
#ifndef __force #ifndef __force
#define __force #define __force
#endif #endif
#define normalize_secret(a) curve25519_normalize_secret(a)
static noinline void memzero_explicit(void *s, size_t count) static noinline void memzero_explicit(void *s, size_t count)
{ {
@ -42,13 +43,6 @@ static noinline void memzero_explicit(void *s, size_t count)
__asm__ __volatile__("": :"r"(s) :"memory"); __asm__ __volatile__("": :"r"(s) :"memory");
} }
static __always_inline void normalize_secret(u8 secret[CURVE25519_POINT_SIZE])
{
secret[0] &= 248;
secret[31] &= 127;
secret[31] |= 64;
}
#ifdef __SIZEOF_INT128__ #ifdef __SIZEOF_INT128__
#include "../crypto/curve25519-hacl64.h" #include "../crypto/curve25519-hacl64.h"
#else #else