]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: arm/curve25519 - Remove unused kpp support
authorEric Biggers <ebiggers@kernel.org>
Sat, 6 Sep 2025 21:35:13 +0000 (14:35 -0700)
committerEric Biggers <ebiggers@kernel.org>
Sat, 6 Sep 2025 21:45:49 +0000 (14:45 -0700)
Curve25519 is used only via the library API, not the crypto_kpp API.  In
preparation for removing the unused crypto_kpp API for Curve25519,
remove the unused "curve25519-neon" kpp algorithm.

Note that the underlying NEON optimized Curve25519 code remains fully
supported and accessible via the library API.

It's also worth noting that even if the kpp support for Curve25519 comes
back later, there is no need for arch-specific kpp glue code like this,
as a single kpp algorithm that wraps the library API is sufficient.

Link: https://lore.kernel.org/r/20250906213523.84915-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
arch/arm/crypto/Kconfig
arch/arm/crypto/curve25519-glue.c

index 1e5f3cdf691c4f7390ca817b239cb61855bb848d..97718d86f6007efacea01fb3ae9808b5c1783da4 100644 (file)
@@ -5,7 +5,6 @@ menu "Accelerated Cryptographic Algorithms for CPU (arm)"
 config CRYPTO_CURVE25519_NEON
        tristate
        depends on KERNEL_MODE_NEON
-       select CRYPTO_KPP
        select CRYPTO_LIB_CURVE25519_GENERIC
        select CRYPTO_ARCH_HAVE_LIB_CURVE25519
        default CRYPTO_LIB_CURVE25519_INTERNAL
index e7b87e09dd99f49088123b13d95f840aa0f540ee..3076020d8fbeb6c027f9d31572bb287cb9722c2e 100644 (file)
 #include <asm/hwcap.h>
 #include <asm/neon.h>
 #include <asm/simd.h>
-#include <crypto/internal/kpp.h>
 #include <crypto/internal/simd.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/jump_label.h>
-#include <linux/scatterlist.h>
 #include <crypto/curve25519.h>
 
 asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_KEY_SIZE],
@@ -46,92 +44,19 @@ void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
 }
 EXPORT_SYMBOL(curve25519_base_arch);
 
-static int curve25519_set_secret(struct crypto_kpp *tfm, const void *buf,
-                                unsigned int len)
-{
-       u8 *secret = kpp_tfm_ctx(tfm);
-
-       if (!len)
-               curve25519_generate_secret(secret);
-       else if (len == CURVE25519_KEY_SIZE &&
-                crypto_memneq(buf, curve25519_null_point, CURVE25519_KEY_SIZE))
-               memcpy(secret, buf, CURVE25519_KEY_SIZE);
-       else
-               return -EINVAL;
-       return 0;
-}
-
-static int curve25519_compute_value(struct kpp_request *req)
-{
-       struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
-       const u8 *secret = kpp_tfm_ctx(tfm);
-       u8 public_key[CURVE25519_KEY_SIZE];
-       u8 buf[CURVE25519_KEY_SIZE];
-       int copied, nbytes;
-       u8 const *bp;
-
-       if (req->src) {
-               copied = sg_copy_to_buffer(req->src,
-                                          sg_nents_for_len(req->src,
-                                                           CURVE25519_KEY_SIZE),
-                                          public_key, CURVE25519_KEY_SIZE);
-               if (copied != CURVE25519_KEY_SIZE)
-                       return -EINVAL;
-               bp = public_key;
-       } else {
-               bp = curve25519_base_point;
-       }
-
-       curve25519_arch(buf, secret, bp);
-
-       /* might want less than we've got */
-       nbytes = min_t(size_t, CURVE25519_KEY_SIZE, req->dst_len);
-       copied = sg_copy_from_buffer(req->dst, sg_nents_for_len(req->dst,
-                                                               nbytes),
-                                    buf, nbytes);
-       if (copied != nbytes)
-               return -EINVAL;
-       return 0;
-}
-
-static unsigned int curve25519_max_size(struct crypto_kpp *tfm)
-{
-       return CURVE25519_KEY_SIZE;
-}
-
-static struct kpp_alg curve25519_alg = {
-       .base.cra_name          = "curve25519",
-       .base.cra_driver_name   = "curve25519-neon",
-       .base.cra_priority      = 200,
-       .base.cra_module        = THIS_MODULE,
-       .base.cra_ctxsize       = CURVE25519_KEY_SIZE,
-
-       .set_secret             = curve25519_set_secret,
-       .generate_public_key    = curve25519_compute_value,
-       .compute_shared_secret  = curve25519_compute_value,
-       .max_size               = curve25519_max_size,
-};
-
 static int __init arm_curve25519_init(void)
 {
-       if (elf_hwcap & HWCAP_NEON) {
+       if (elf_hwcap & HWCAP_NEON)
                static_branch_enable(&have_neon);
-               return IS_REACHABLE(CONFIG_CRYPTO_KPP) ?
-                       crypto_register_kpp(&curve25519_alg) : 0;
-       }
        return 0;
 }
 
 static void __exit arm_curve25519_exit(void)
 {
-       if (IS_REACHABLE(CONFIG_CRYPTO_KPP) && elf_hwcap & HWCAP_NEON)
-               crypto_unregister_kpp(&curve25519_alg);
 }
 
 module_init(arm_curve25519_init);
 module_exit(arm_curve25519_exit);
 
-MODULE_ALIAS_CRYPTO("curve25519");
-MODULE_ALIAS_CRYPTO("curve25519-neon");
 MODULE_DESCRIPTION("Public key crypto: Curve25519 (NEON-accelerated)");
 MODULE_LICENSE("GPL v2");