Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: arm/curve25519 - Remove unused kpp support

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>

+1 -77
-1
arch/arm/crypto/Kconfig
··· 5 5 config CRYPTO_CURVE25519_NEON 6 6 tristate 7 7 depends on KERNEL_MODE_NEON 8 - select CRYPTO_KPP 9 8 select CRYPTO_LIB_CURVE25519_GENERIC 10 9 select CRYPTO_ARCH_HAVE_LIB_CURVE25519 11 10 default CRYPTO_LIB_CURVE25519_INTERNAL
+1 -76
arch/arm/crypto/curve25519-glue.c
··· 10 10 #include <asm/hwcap.h> 11 11 #include <asm/neon.h> 12 12 #include <asm/simd.h> 13 - #include <crypto/internal/kpp.h> 14 13 #include <crypto/internal/simd.h> 15 14 #include <linux/types.h> 16 15 #include <linux/module.h> 17 16 #include <linux/init.h> 18 17 #include <linux/jump_label.h> 19 - #include <linux/scatterlist.h> 20 18 #include <crypto/curve25519.h> 21 19 22 20 asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_KEY_SIZE], ··· 44 46 } 45 47 EXPORT_SYMBOL(curve25519_base_arch); 46 48 47 - static int curve25519_set_secret(struct crypto_kpp *tfm, const void *buf, 48 - unsigned int len) 49 - { 50 - u8 *secret = kpp_tfm_ctx(tfm); 51 - 52 - if (!len) 53 - curve25519_generate_secret(secret); 54 - else if (len == CURVE25519_KEY_SIZE && 55 - crypto_memneq(buf, curve25519_null_point, CURVE25519_KEY_SIZE)) 56 - memcpy(secret, buf, CURVE25519_KEY_SIZE); 57 - else 58 - return -EINVAL; 59 - return 0; 60 - } 61 - 62 - static int curve25519_compute_value(struct kpp_request *req) 63 - { 64 - struct crypto_kpp *tfm = crypto_kpp_reqtfm(req); 65 - const u8 *secret = kpp_tfm_ctx(tfm); 66 - u8 public_key[CURVE25519_KEY_SIZE]; 67 - u8 buf[CURVE25519_KEY_SIZE]; 68 - int copied, nbytes; 69 - u8 const *bp; 70 - 71 - if (req->src) { 72 - copied = sg_copy_to_buffer(req->src, 73 - sg_nents_for_len(req->src, 74 - CURVE25519_KEY_SIZE), 75 - public_key, CURVE25519_KEY_SIZE); 76 - if (copied != CURVE25519_KEY_SIZE) 77 - return -EINVAL; 78 - bp = public_key; 79 - } else { 80 - bp = curve25519_base_point; 81 - } 82 - 83 - curve25519_arch(buf, secret, bp); 84 - 85 - /* might want less than we've got */ 86 - nbytes = min_t(size_t, CURVE25519_KEY_SIZE, req->dst_len); 87 - copied = sg_copy_from_buffer(req->dst, sg_nents_for_len(req->dst, 88 - nbytes), 89 - buf, nbytes); 90 - if (copied != nbytes) 91 - return -EINVAL; 92 - return 0; 93 - } 94 - 95 - static unsigned int curve25519_max_size(struct crypto_kpp *tfm) 96 - { 97 - return CURVE25519_KEY_SIZE; 98 - } 99 - 100 - static struct kpp_alg curve25519_alg = { 101 - .base.cra_name = "curve25519", 102 - .base.cra_driver_name = "curve25519-neon", 103 - .base.cra_priority = 200, 104 - .base.cra_module = THIS_MODULE, 105 - .base.cra_ctxsize = CURVE25519_KEY_SIZE, 106 - 107 - .set_secret = curve25519_set_secret, 108 - .generate_public_key = curve25519_compute_value, 109 - .compute_shared_secret = curve25519_compute_value, 110 - .max_size = curve25519_max_size, 111 - }; 112 - 113 49 static int __init arm_curve25519_init(void) 114 50 { 115 - if (elf_hwcap & HWCAP_NEON) { 51 + if (elf_hwcap & HWCAP_NEON) 116 52 static_branch_enable(&have_neon); 117 - return IS_REACHABLE(CONFIG_CRYPTO_KPP) ? 118 - crypto_register_kpp(&curve25519_alg) : 0; 119 - } 120 53 return 0; 121 54 } 122 55 123 56 static void __exit arm_curve25519_exit(void) 124 57 { 125 - if (IS_REACHABLE(CONFIG_CRYPTO_KPP) && elf_hwcap & HWCAP_NEON) 126 - crypto_unregister_kpp(&curve25519_alg); 127 58 } 128 59 129 60 module_init(arm_curve25519_init); 130 61 module_exit(arm_curve25519_exit); 131 62 132 - MODULE_ALIAS_CRYPTO("curve25519"); 133 - MODULE_ALIAS_CRYPTO("curve25519-neon"); 134 63 MODULE_DESCRIPTION("Public key crypto: Curve25519 (NEON-accelerated)"); 135 64 MODULE_LICENSE("GPL v2");