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

crypto: ccp - Allow for selective disablement of crypto API algorithms

Introduce module parameters that allow for disabling of a
crypto algorithm by not registering the algorithm with the
crypto API.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Tom Lendacky and committed by
Herbert Xu
d81ed653 80e84c16

+25 -12
+25 -12
drivers/crypto/ccp/ccp-crypto-main.c
··· 11 11 */ 12 12 13 13 #include <linux/module.h> 14 + #include <linux/moduleparam.h> 14 15 #include <linux/kernel.h> 15 16 #include <linux/list.h> 16 17 #include <linux/ccp.h> ··· 24 23 MODULE_LICENSE("GPL"); 25 24 MODULE_VERSION("1.0.0"); 26 25 MODULE_DESCRIPTION("AMD Cryptographic Coprocessor crypto API support"); 26 + 27 + static unsigned int aes_disable; 28 + module_param(aes_disable, uint, 0444); 29 + MODULE_PARM_DESC(aes_disable, "Disable use of AES - any non-zero value"); 30 + 31 + static unsigned int sha_disable; 32 + module_param(sha_disable, uint, 0444); 33 + MODULE_PARM_DESC(sha_disable, "Disable use of SHA - any non-zero value"); 27 34 28 35 29 36 /* List heads for the supported algorithms */ ··· 346 337 { 347 338 int ret; 348 339 349 - ret = ccp_register_aes_algs(&cipher_algs); 350 - if (ret) 351 - return ret; 340 + if (!aes_disable) { 341 + ret = ccp_register_aes_algs(&cipher_algs); 342 + if (ret) 343 + return ret; 352 344 353 - ret = ccp_register_aes_cmac_algs(&hash_algs); 354 - if (ret) 355 - return ret; 345 + ret = ccp_register_aes_cmac_algs(&hash_algs); 346 + if (ret) 347 + return ret; 356 348 357 - ret = ccp_register_aes_xts_algs(&cipher_algs); 358 - if (ret) 359 - return ret; 349 + ret = ccp_register_aes_xts_algs(&cipher_algs); 350 + if (ret) 351 + return ret; 352 + } 360 353 361 - ret = ccp_register_sha_algs(&hash_algs); 362 - if (ret) 363 - return ret; 354 + if (!sha_disable) { 355 + ret = ccp_register_sha_algs(&hash_algs); 356 + if (ret) 357 + return ret; 358 + } 364 359 365 360 return 0; 366 361 }