From nobody Fri Oct 3 12:34:55 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ADB9270541; Mon, 1 Sep 2025 20:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756758004; cv=none; b=ftTcHPF9W9oRM9n6cDb2lwig923OahKLEESciKGI4Ej6DDCB3h1fUFkryjoQftCLc8z6dB+3yafk3ZKMvBQ+oaWflYKBtxa30f4LVXO2SbZ/J+OsjfavHTYTOyAmw1QjaZ51kcu9+2IwYMUZ0NgjtC8dbFskvO7dRWjeOjYBjls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756758004; c=relaxed/simple; bh=CQJ4knDhIHFMSRh4/nbpAJJmql9MOH99GJgLFyWdS58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DDTLEWumd7KK+bbLQ90FwZSYdnfLHd6sojyuKlqJSrzGVoX1XNa+DMOzpLuhL5JwE5aEy66er8b3LazeRXNfOnmojG3hrVqDQDVqPZFtrEJd0hFc5otddNe2QIhg3QdlKv057DZW9QvT77ou+H7VXPcENKzVxiQolk9nkogs5do= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UmTzfHJV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UmTzfHJV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0637DC4CEF9; Mon, 1 Sep 2025 20:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756758004; bh=CQJ4knDhIHFMSRh4/nbpAJJmql9MOH99GJgLFyWdS58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UmTzfHJVn58a/hi+Y2BEVI/E0gwajpfj3l1+MhWb2/inRfscleDQ32kTkuenid5SL K7l9t1IUSL9vIj3z1zolWo8XQdNqzsVPp/WnAil7mWZSAELJmSp0gjfmqgTRGDBfNg nFSyHHMR8gXykAgVPG3TvllBPw9BSha/1ZHH7Zt/o0W/D+tde7zHFcu7NygYlnFZ9K yocztZRzbyylq4hjA3CwIkGj2SsHagflp7P/Ul4KLFpCL2u8H/HVBKKXFizBMOw+UM rT6byPz4yGFr78RhaZYpil4MXKPZ8g4nY0eeMsA2VyKSey4S4Glh0FyBPtDEAzKwFC JjCJjJyaZxNIw== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , "Jason A . Donenfeld" , Zhiqi Song , Longfang Liu , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Eric Biggers Subject: [PATCH 4/6] lib/crypto: curve25519: Move a couple functions out-of-line Date: Mon, 1 Sep 2025 13:18:13 -0700 Message-ID: <20250901201815.594177-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250901201815.594177-1-ebiggers@kernel.org> References: <20250901201815.594177-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move curve25519() and curve25519_generate_public() from curve25519.h to curve25519.c. There's no good reason for them to be inline. Signed-off-by: Eric Biggers --- include/crypto/curve25519.h | 28 +++------------------------- lib/crypto/curve25519.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/include/crypto/curve25519.h b/include/crypto/curve25519.h index 4e6dc840b1592..78aa5f28c847f 100644 --- a/include/crypto/curve25519.h +++ b/include/crypto/curve25519.h @@ -4,11 +4,10 @@ */ =20 #ifndef CURVE25519_H #define CURVE25519_H =20 -#include // For crypto_memneq. #include #include =20 enum curve25519_lengths { CURVE25519_KEY_SIZE =3D 32 @@ -26,37 +25,16 @@ void curve25519_arch(u8 out[CURVE25519_KEY_SIZE], const u8 point[CURVE25519_KEY_SIZE]); =20 void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE], const u8 secret[CURVE25519_KEY_SIZE]); =20 -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]); =20 -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]); =20 static inline void curve25519_clamp_secret(u8 secret[CURVE25519_KEY_SIZE]) { secret[0] &=3D 248; secret[31] =3D (secret[31] & 127) | 64; diff --git a/lib/crypto/curve25519.c b/lib/crypto/curve25519.c index 25f16777865bf..1b786389d714a 100644 --- a/lib/crypto/curve25519.c +++ b/lib/crypto/curve25519.c @@ -8,12 +8,44 @@ * * Information: https://cr.yp.to/ecdh.html */ =20 #include -#include +#include +#include #include +#include + +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); =20 static int __init curve25519_init(void) { return 0; } --=20 2.50.1