Skip to content

Commit

Permalink
crypto: testmgr - add an option to disable cryptoalgos' self-tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
virtuoso authored and herbertx committed Jun 3, 2010
1 parent bc94e59 commit 0b767f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ config CRYPTO_MANAGER2
select CRYPTO_BLKCIPHER2
select CRYPTO_PCOMP2

config CRYPTO_MANAGER_TESTS
bool "Run algolithms' self-tests"
default y
depends on CRYPTO_MANAGER2
help
Run cryptomanager's tests for the new crypto algorithms being
registered.

config CRYPTO_GF128MUL
tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
depends on EXPERIMENTAL
Expand Down
4 changes: 4 additions & 0 deletions crypto/algboss.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
return NOTIFY_OK;
}

#ifdef CONFIG_CRYPTO_MANAGER_TESTS
static int cryptomgr_test(void *data)
{
struct crypto_test_param *param = data;
Expand Down Expand Up @@ -266,15 +267,18 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
err:
return NOTIFY_OK;
}
#endif /* CONFIG_CRYPTO_MANAGER_TESTS */

static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
void *data)
{
switch (msg) {
case CRYPTO_MSG_ALG_REQUEST:
return cryptomgr_schedule_probe(data);
#ifdef CONFIG_CRYPTO_MANAGER_TESTS
case CRYPTO_MSG_ALG_REGISTER:
return cryptomgr_schedule_test(data);
#endif
}

return NOTIFY_DONE;
Expand Down
14 changes: 14 additions & 0 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
#include <crypto/rng.h>

#include "internal.h"

#ifndef CONFIG_CRYPTO_MANAGER_TESTS

/* a perfect nop */
int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
{
return 0;
}

#else

#include "testmgr.h"

/*
Expand Down Expand Up @@ -2530,4 +2541,7 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
non_fips_alg:
return -EINVAL;
}

#endif /* CONFIG_CRYPTO_MANAGER_TESTS */

EXPORT_SYMBOL_GPL(alg_test);

0 comments on commit 0b767f9

Please sign in to comment.