aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/curve25519/curve25519.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-24 22:02:13 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-25 03:01:21 +0200
commit28d8b7eafe49450ef1bd20939334baebbea0a367 (patch)
tree5404d3b10c4141d31f23bb2e21ef0c73814308d0 /src/crypto/zinc/curve25519/curve25519.c
parenthchacha20: keep in native endian in words (diff)
downloadwireguard-monolithic-historical-28d8b7eafe49450ef1bd20939334baebbea0a367.tar.xz
wireguard-monolithic-historical-28d8b7eafe49450ef1bd20939334baebbea0a367.zip
crypto: make constant naming scheme consistent
Diffstat (limited to 'src/crypto/zinc/curve25519/curve25519.c')
-rw-r--r--src/crypto/zinc/curve25519/curve25519.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/crypto/zinc/curve25519/curve25519.c b/src/crypto/zinc/curve25519/curve25519.c
index fd46b36..a1f35aa 100644
--- a/src/crypto/zinc/curve25519/curve25519.c
+++ b/src/crypto/zinc/curve25519/curve25519.c
@@ -27,20 +27,20 @@
void __init curve25519_fpu_init(void)
{
}
-static inline bool curve25519_arch(u8 mypublic[CURVE25519_POINT_SIZE],
- const u8 secret[CURVE25519_POINT_SIZE],
- const u8 basepoint[CURVE25519_POINT_SIZE])
+static inline bool curve25519_arch(u8 mypublic[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE],
+ const u8 basepoint[CURVE25519_KEY_SIZE])
{
return false;
}
-static inline bool curve25519_base_arch(u8 pub[CURVE25519_POINT_SIZE],
- const u8 secret[CURVE25519_POINT_SIZE])
+static inline bool curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE])
{
return false;
}
#endif
-static __always_inline void normalize_secret(u8 secret[CURVE25519_POINT_SIZE])
+static __always_inline void normalize_secret(u8 secret[CURVE25519_KEY_SIZE])
{
secret[0] &= 248;
secret[31] &= 127;
@@ -53,35 +53,35 @@ static __always_inline void normalize_secret(u8 secret[CURVE25519_POINT_SIZE])
#include "curve25519-fiat32.h"
#endif
-static const u8 null_point[CURVE25519_POINT_SIZE] = { 0 };
+static const u8 null_point[CURVE25519_KEY_SIZE] = { 0 };
-bool curve25519(u8 mypublic[CURVE25519_POINT_SIZE],
- const u8 secret[CURVE25519_POINT_SIZE],
- const u8 basepoint[CURVE25519_POINT_SIZE])
+bool curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE],
+ const u8 basepoint[CURVE25519_KEY_SIZE])
{
if (!curve25519_arch(mypublic, secret, basepoint))
curve25519_generic(mypublic, secret, basepoint);
- return crypto_memneq(mypublic, null_point, CURVE25519_POINT_SIZE);
+ return crypto_memneq(mypublic, null_point, CURVE25519_KEY_SIZE);
}
EXPORT_SYMBOL(curve25519);
-bool curve25519_generate_public(u8 pub[CURVE25519_POINT_SIZE],
- const u8 secret[CURVE25519_POINT_SIZE])
+bool curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE])
{
- static const u8 basepoint[CURVE25519_POINT_SIZE] __aligned(32) = { 9 };
+ static const u8 basepoint[CURVE25519_KEY_SIZE] __aligned(32) = { 9 };
- if (unlikely(!crypto_memneq(secret, null_point, CURVE25519_POINT_SIZE)))
+ if (unlikely(!crypto_memneq(secret, null_point, CURVE25519_KEY_SIZE)))
return false;
if (curve25519_base_arch(pub, secret))
- return crypto_memneq(pub, null_point, CURVE25519_POINT_SIZE);
+ return crypto_memneq(pub, null_point, CURVE25519_KEY_SIZE);
return curve25519(pub, secret, basepoint);
}
EXPORT_SYMBOL(curve25519_generate_public);
-void curve25519_generate_secret(u8 secret[CURVE25519_POINT_SIZE])
+void curve25519_generate_secret(u8 secret[CURVE25519_KEY_SIZE])
{
- get_random_bytes_wait(secret, CURVE25519_POINT_SIZE);
+ get_random_bytes_wait(secret, CURVE25519_KEY_SIZE);
normalize_secret(secret);
}
EXPORT_SYMBOL(curve25519_generate_secret);