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: powerpc/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-ppc64le" kpp algorithm.

Note that the underlying PowerPC 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-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

-106
-1
arch/powerpc/crypto/Kconfig
··· 5 5 config CRYPTO_CURVE25519_PPC64 6 6 tristate 7 7 depends on PPC64 && CPU_LITTLE_ENDIAN 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
-105
arch/powerpc/crypto/curve25519-ppc64le-core.c
··· 8 8 */ 9 9 10 10 #include <crypto/curve25519.h> 11 - #include <crypto/internal/kpp.h> 12 11 13 12 #include <linux/types.h> 14 13 #include <linux/jump_label.h> 15 14 #include <linux/kernel.h> 16 15 #include <linux/module.h> 17 - #include <linux/scatterlist.h> 18 16 19 17 #include <linux/cpufeature.h> 20 18 #include <linux/processor.h> ··· 190 192 } 191 193 EXPORT_SYMBOL(curve25519_base_arch); 192 194 193 - static int curve25519_set_secret(struct crypto_kpp *tfm, const void *buf, 194 - unsigned int len) 195 - { 196 - u8 *secret = kpp_tfm_ctx(tfm); 197 - 198 - if (!len) 199 - curve25519_generate_secret(secret); 200 - else if (len == CURVE25519_KEY_SIZE && 201 - crypto_memneq(buf, curve25519_null_point, CURVE25519_KEY_SIZE)) 202 - memcpy(secret, buf, CURVE25519_KEY_SIZE); 203 - else 204 - return -EINVAL; 205 - return 0; 206 - } 207 - 208 - static int curve25519_generate_public_key(struct kpp_request *req) 209 - { 210 - struct crypto_kpp *tfm = crypto_kpp_reqtfm(req); 211 - const u8 *secret = kpp_tfm_ctx(tfm); 212 - u8 buf[CURVE25519_KEY_SIZE]; 213 - int copied, nbytes; 214 - 215 - if (req->src) 216 - return -EINVAL; 217 - 218 - curve25519_base_arch(buf, secret); 219 - 220 - /* might want less than we've got */ 221 - nbytes = min_t(size_t, CURVE25519_KEY_SIZE, req->dst_len); 222 - copied = sg_copy_from_buffer(req->dst, sg_nents_for_len(req->dst, 223 - nbytes), 224 - buf, nbytes); 225 - if (copied != nbytes) 226 - return -EINVAL; 227 - return 0; 228 - } 229 - 230 - static int curve25519_compute_shared_secret(struct kpp_request *req) 231 - { 232 - struct crypto_kpp *tfm = crypto_kpp_reqtfm(req); 233 - const u8 *secret = kpp_tfm_ctx(tfm); 234 - u8 public_key[CURVE25519_KEY_SIZE]; 235 - u8 buf[CURVE25519_KEY_SIZE]; 236 - int copied, nbytes; 237 - 238 - if (!req->src) 239 - return -EINVAL; 240 - 241 - copied = sg_copy_to_buffer(req->src, 242 - sg_nents_for_len(req->src, 243 - CURVE25519_KEY_SIZE), 244 - public_key, CURVE25519_KEY_SIZE); 245 - if (copied != CURVE25519_KEY_SIZE) 246 - return -EINVAL; 247 - 248 - curve25519_arch(buf, secret, public_key); 249 - 250 - /* might want less than we've got */ 251 - nbytes = min_t(size_t, CURVE25519_KEY_SIZE, req->dst_len); 252 - copied = sg_copy_from_buffer(req->dst, sg_nents_for_len(req->dst, 253 - nbytes), 254 - buf, nbytes); 255 - if (copied != nbytes) 256 - return -EINVAL; 257 - return 0; 258 - } 259 - 260 - static unsigned int curve25519_max_size(struct crypto_kpp *tfm) 261 - { 262 - return CURVE25519_KEY_SIZE; 263 - } 264 - 265 - static struct kpp_alg curve25519_alg = { 266 - .base.cra_name = "curve25519", 267 - .base.cra_driver_name = "curve25519-ppc64le", 268 - .base.cra_priority = 200, 269 - .base.cra_module = THIS_MODULE, 270 - .base.cra_ctxsize = CURVE25519_KEY_SIZE, 271 - 272 - .set_secret = curve25519_set_secret, 273 - .generate_public_key = curve25519_generate_public_key, 274 - .compute_shared_secret = curve25519_compute_shared_secret, 275 - .max_size = curve25519_max_size, 276 - }; 277 - 278 - 279 - static int __init curve25519_mod_init(void) 280 - { 281 - return IS_REACHABLE(CONFIG_CRYPTO_KPP) ? 282 - crypto_register_kpp(&curve25519_alg) : 0; 283 - } 284 - 285 - static void __exit curve25519_mod_exit(void) 286 - { 287 - if (IS_REACHABLE(CONFIG_CRYPTO_KPP)) 288 - crypto_unregister_kpp(&curve25519_alg); 289 - } 290 - 291 - module_init(curve25519_mod_init); 292 - module_exit(curve25519_mod_exit); 293 - 294 - MODULE_ALIAS_CRYPTO("curve25519"); 295 - MODULE_ALIAS_CRYPTO("curve25519-ppc64le"); 296 195 MODULE_DESCRIPTION("PPC64le Curve25519 scalar multiplication with 51 bits limbs"); 297 196 MODULE_LICENSE("GPL v2"); 298 197 MODULE_AUTHOR("Danny Tsen <dtsen@us.ibm.com>");