Skip to content

Commit c1e592f

Browse files
virtuosogregkh
authored andcommitted
crypto: testmgr - add an option to disable cryptoalgos' self-tests
commit 0b767f96164b2b27488e3daa722ff16e89d49314 upstream. By default, CONFIG_CRYPTO_MANAGER_TESTS will be enabled and thus self-tests will still run, but it is now possible to disable them to gain some time during bootup. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 925a7e4 commit c1e592f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

crypto/Kconfig

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ config CRYPTO_MANAGER2
9696
select CRYPTO_BLKCIPHER2
9797
select CRYPTO_PCOMP
9898

99+
config CRYPTO_MANAGER_TESTS
100+
bool "Run algolithms' self-tests"
101+
default y
102+
depends on CRYPTO_MANAGER2
103+
help
104+
Run cryptomanager's tests for the new crypto algorithms being
105+
registered.
106+
99107
config CRYPTO_GF128MUL
100108
tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
101109
depends on EXPERIMENTAL

crypto/algboss.c

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
206206
return NOTIFY_OK;
207207
}
208208

209+
#ifdef CONFIG_CRYPTO_MANAGER_TESTS
209210
static int cryptomgr_test(void *data)
210211
{
211212
struct crypto_test_param *param = data;
@@ -266,15 +267,18 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
266267
err:
267268
return NOTIFY_OK;
268269
}
270+
#endif /* CONFIG_CRYPTO_MANAGER_TESTS */
269271

270272
static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
271273
void *data)
272274
{
273275
switch (msg) {
274276
case CRYPTO_MSG_ALG_REQUEST:
275277
return cryptomgr_schedule_probe(data);
278+
#ifdef CONFIG_CRYPTO_MANAGER_TESTS
276279
case CRYPTO_MSG_ALG_REGISTER:
277280
return cryptomgr_schedule_test(data);
281+
#endif
278282
}
279283

280284
return NOTIFY_DONE;

crypto/testmgr.c

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
#include <crypto/rng.h>
2323

2424
#include "internal.h"
25+
26+
#ifndef CONFIG_CRYPTO_MANAGER_TESTS
27+
28+
/* a perfect nop */
29+
int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
30+
{
31+
return 0;
32+
}
33+
34+
#else
35+
2536
#include "testmgr.h"
2637

2738
/*
@@ -2530,4 +2541,7 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
25302541
non_fips_alg:
25312542
return -EINVAL;
25322543
}
2544+
2545+
#endif /* CONFIG_CRYPTO_MANAGER_TESTS */
2546+
25332547
EXPORT_SYMBOL_GPL(alg_test);

0 commit comments

Comments
 (0)