From 897548e927fc90d13a19e1b1f29a549e7f885621 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 3 Feb 2019 21:50:54 +0100 Subject: noise: store clamped key instead of raw key --- src/crypto/include/zinc/curve25519.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/crypto/include') diff --git a/src/crypto/include/zinc/curve25519.h b/src/crypto/include/zinc/curve25519.h index 0b46552..127d8a3 100644 --- a/src/crypto/include/zinc/curve25519.h +++ b/src/crypto/include/zinc/curve25519.h @@ -19,4 +19,10 @@ void curve25519_generate_secret(u8 secret[CURVE25519_KEY_SIZE]); bool __must_check curve25519_generate_public( u8 pub[CURVE25519_KEY_SIZE], const u8 secret[CURVE25519_KEY_SIZE]); +static inline void curve25519_clamp_secret(u8 secret[CURVE25519_KEY_SIZE]) +{ + secret[0] &= 248; + secret[31] = (secret[31] & 127) | 64; +} + #endif /* _ZINC_CURVE25519_H */ -- cgit v1.2.3-59-g8ed1b