Skip to content

Commit

Permalink
crypto: testmgr - Add a flag allowing the self-tests to be disabled a…
Browse files Browse the repository at this point in the history
…t runtime.

Running self-tests for a short-lived KVM VM takes 28ms on my laptop.
This commit adds a flag 'cryptomgr.notests' which allows them to be
disabled.

However if fips=1 as well, we ignore this flag as FIPS mode mandates
that the self-tests are run.

Signed-off-by: Richard W.M. Jones <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
rwmjones authored and herbertx committed May 5, 2016
1 parent bc197b2 commit 9e5c9fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
It will be ignored when crashkernel=X,high is not used
or memory reserved is below 4G.

cryptomgr.notests
[KNL] Disable crypto self-tests

cs89x0_dma= [HW,NET]
Format: <dma>

Expand Down
9 changes: 9 additions & 0 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#include "internal.h"

static bool notests;
module_param(notests, bool, 0644);
MODULE_PARM_DESC(notests, "disable crypto self-tests");

#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS

/* a perfect nop */
Expand Down Expand Up @@ -3868,6 +3872,11 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
int j;
int rc;

if (!fips_enabled && notests) {
printk_once(KERN_INFO "alg: self-tests disabled\n");
return 0;
}

alg_test_descs_check_order();

if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
Expand Down

0 comments on commit 9e5c9fe

Please sign in to comment.