summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/include
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-02-03 21:50:54 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-03 21:51:18 +0100
commit8cff496b89f63475e9af07bc19364e4232cd4347 (patch)
treec512eb098203d0db14a8723c63c3a3e417434f07 /src/crypto/include
parenta3008c17fc41e1d6c1b95d518ff9c770be89c333 (diff)
noise: store clamped key instead of raw key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/include')
-rw-r--r--src/crypto/include/zinc/curve25519.h6
1 files changed, 6 insertions, 0 deletions
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 */