aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-02 04:32:12 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-02 04:32:12 -0400
commita68f6610d4f1ebe61818f5926fa8fa9e75d06a95 (patch)
tree24c23aafabff2045996ed02fb5eae295f29d5e2a /crypto/testmgr.c
parent0b67fb65d1b2ba1396de69112b8b9bc95d8d5feb (diff)
crypto: testmgr - Allow implementation-specific tests
This patch adds the support for testing specific implementations. This should only be used in very specific situations. Right now this means specific implementations of random number generators. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r--crypto/testmgr.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index f9bea9d989fa..29b228d9b1a2 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -2344,6 +2344,7 @@ static int alg_find_test(const char *alg)
2344int alg_test(const char *driver, const char *alg, u32 type, u32 mask) 2344int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
2345{ 2345{
2346 int i; 2346 int i;
2347 int j;
2347 int rc; 2348 int rc;
2348 2349
2349 if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { 2350 if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
@@ -2365,14 +2366,22 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
2365 } 2366 }
2366 2367
2367 i = alg_find_test(alg); 2368 i = alg_find_test(alg);
2368 if (i < 0) 2369 j = alg_find_test(driver);
2370 if (i < 0 && j < 0)
2369 goto notest; 2371 goto notest;
2370 2372
2371 if (fips_enabled && !alg_test_descs[i].fips_allowed) 2373 if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
2374 (j >= 0 && !alg_test_descs[j].fips_allowed)))
2372 goto non_fips_alg; 2375 goto non_fips_alg;
2373 2376
2374 rc = alg_test_descs[i].test(alg_test_descs + i, driver, 2377 rc = 0;
2375 type, mask); 2378 if (i >= 0)
2379 rc |= alg_test_descs[i].test(alg_test_descs + i, driver,
2380 type, mask);
2381 if (j >= 0)
2382 rc |= alg_test_descs[j].test(alg_test_descs + j, driver,
2383 type, mask);
2384
2376test_done: 2385test_done:
2377 if (fips_enabled && rc) 2386 if (fips_enabled && rc)
2378 panic("%s: %s alg self test failed in fips mode!\n", driver, alg); 2387 panic("%s: %s alg self test failed in fips mode!\n", driver, alg);