Skip to content

Commit 8c06b33

Browse files
author
Eric Biggers
committed
lib/crypto: curve25519: Move a couple functions out-of-line
Move curve25519() and curve25519_generate_public() from curve25519.h to curve25519.c. There's no good reason for them to be inline. Link: https://lore.kernel.org/r/20250906213523.84915-10-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent 643d79e commit 8c06b33

2 files changed

Lines changed: 36 additions & 26 deletions

File tree

include/crypto/curve25519.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#ifndef CURVE25519_H
77
#define CURVE25519_H
88

9-
#include <crypto/algapi.h> // For crypto_memneq.
109
#include <linux/types.h>
1110
#include <linux/random.h>
1211

@@ -28,33 +27,12 @@ void curve25519_arch(u8 out[CURVE25519_KEY_SIZE],
2827
void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
2928
const u8 secret[CURVE25519_KEY_SIZE]);
3029

31-
static inline
3230
bool __must_check curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
3331
const u8 secret[CURVE25519_KEY_SIZE],
34-
const u8 basepoint[CURVE25519_KEY_SIZE])
35-
{
36-
if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
37-
curve25519_arch(mypublic, secret, basepoint);
38-
else
39-
curve25519_generic(mypublic, secret, basepoint);
40-
return crypto_memneq(mypublic, curve25519_null_point,
41-
CURVE25519_KEY_SIZE);
42-
}
32+
const u8 basepoint[CURVE25519_KEY_SIZE]);
4333

44-
static inline bool
45-
__must_check curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
46-
const u8 secret[CURVE25519_KEY_SIZE])
47-
{
48-
if (unlikely(!crypto_memneq(secret, curve25519_null_point,
49-
CURVE25519_KEY_SIZE)))
50-
return false;
51-
52-
if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
53-
curve25519_base_arch(pub, secret);
54-
else
55-
curve25519_generic(pub, secret, curve25519_base_point);
56-
return crypto_memneq(pub, curve25519_null_point, CURVE25519_KEY_SIZE);
57-
}
34+
bool __must_check curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
35+
const u8 secret[CURVE25519_KEY_SIZE]);
5836

5937
static inline void curve25519_clamp_secret(u8 secret[CURVE25519_KEY_SIZE])
6038
{

lib/crypto/curve25519.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,40 @@
1010
*/
1111

1212
#include <crypto/curve25519.h>
13-
#include <linux/module.h>
13+
#include <crypto/utils.h>
14+
#include <linux/export.h>
1415
#include <linux/init.h>
16+
#include <linux/module.h>
17+
18+
bool __must_check
19+
curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
20+
const u8 secret[CURVE25519_KEY_SIZE],
21+
const u8 basepoint[CURVE25519_KEY_SIZE])
22+
{
23+
if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
24+
curve25519_arch(mypublic, secret, basepoint);
25+
else
26+
curve25519_generic(mypublic, secret, basepoint);
27+
return crypto_memneq(mypublic, curve25519_null_point,
28+
CURVE25519_KEY_SIZE);
29+
}
30+
EXPORT_SYMBOL(curve25519);
31+
32+
bool __must_check
33+
curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
34+
const u8 secret[CURVE25519_KEY_SIZE])
35+
{
36+
if (unlikely(!crypto_memneq(secret, curve25519_null_point,
37+
CURVE25519_KEY_SIZE)))
38+
return false;
39+
40+
if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
41+
curve25519_base_arch(pub, secret);
42+
else
43+
curve25519_generic(pub, secret, curve25519_base_point);
44+
return crypto_memneq(pub, curve25519_null_point, CURVE25519_KEY_SIZE);
45+
}
46+
EXPORT_SYMBOL(curve25519_generate_public);
1547

1648
static int __init curve25519_init(void)
1749
{

0 commit comments

Comments
 (0)