]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lib/crypto: curve25519: Move a couple functions out-of-line
authorEric Biggers <ebiggers@kernel.org>
Sat, 6 Sep 2025 21:35:20 +0000 (14:35 -0700)
committerEric Biggers <ebiggers@kernel.org>
Sat, 6 Sep 2025 23:32:43 +0000 (16:32 -0700)
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>
include/crypto/curve25519.h
lib/crypto/curve25519.c

index 4e6dc840b1592c53cb38b3687a2ff3b55fa8364f..78aa5f28c847f27af1f3c0921e77be48973262a5 100644 (file)
@@ -6,7 +6,6 @@
 #ifndef CURVE25519_H
 #define CURVE25519_H
 
-#include <crypto/algapi.h> // For crypto_memneq.
 #include <linux/types.h>
 #include <linux/random.h>
 
@@ -28,33 +27,12 @@ void curve25519_arch(u8 out[CURVE25519_KEY_SIZE],
 void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
                          const u8 secret[CURVE25519_KEY_SIZE]);
 
-static inline
 bool __must_check curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
                             const u8 secret[CURVE25519_KEY_SIZE],
-                            const u8 basepoint[CURVE25519_KEY_SIZE])
-{
-       if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
-               curve25519_arch(mypublic, secret, basepoint);
-       else
-               curve25519_generic(mypublic, secret, basepoint);
-       return crypto_memneq(mypublic, curve25519_null_point,
-                            CURVE25519_KEY_SIZE);
-}
+                            const u8 basepoint[CURVE25519_KEY_SIZE]);
 
-static inline bool
-__must_check curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
-                                       const u8 secret[CURVE25519_KEY_SIZE])
-{
-       if (unlikely(!crypto_memneq(secret, curve25519_null_point,
-                                   CURVE25519_KEY_SIZE)))
-               return false;
-
-       if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
-               curve25519_base_arch(pub, secret);
-       else
-               curve25519_generic(pub, secret, curve25519_base_point);
-       return crypto_memneq(pub, curve25519_null_point, 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])
 {
index 25f16777865bfcc9b2a7fdc2d5547a18a12882c6..1b786389d714a09a2aa7fb739d8ff8c1193627fb 100644 (file)
  */
 
 #include <crypto/curve25519.h>
-#include <linux/module.h>
+#include <crypto/utils.h>
+#include <linux/export.h>
 #include <linux/init.h>
+#include <linux/module.h>
+
+bool __must_check
+curve25519(u8 mypublic[CURVE25519_KEY_SIZE],
+          const u8 secret[CURVE25519_KEY_SIZE],
+          const u8 basepoint[CURVE25519_KEY_SIZE])
+{
+       if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
+               curve25519_arch(mypublic, secret, basepoint);
+       else
+               curve25519_generic(mypublic, secret, basepoint);
+       return crypto_memneq(mypublic, curve25519_null_point,
+                            CURVE25519_KEY_SIZE);
+}
+EXPORT_SYMBOL(curve25519);
+
+bool __must_check
+curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE],
+                          const u8 secret[CURVE25519_KEY_SIZE])
+{
+       if (unlikely(!crypto_memneq(secret, curve25519_null_point,
+                                   CURVE25519_KEY_SIZE)))
+               return false;
+
+       if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CURVE25519))
+               curve25519_base_arch(pub, secret);
+       else
+               curve25519_generic(pub, secret, curve25519_base_point);
+       return crypto_memneq(pub, curve25519_null_point, CURVE25519_KEY_SIZE);
+}
+EXPORT_SYMBOL(curve25519_generate_public);
 
 static int __init curve25519_init(void)
 {