Skip to content

Commit

Permalink
crypto: testmgr - Skip algs not flagged fips_allowed in fips mode
Browse files Browse the repository at this point in the history
Because all fips-allowed algorithms must be self-tested before they
can be used, they will all have entries in testmgr.c's alg_test_descs[].
Skip self-tests for any algs not flagged as fips_approved and return
-EINVAL when in fips mode.

Signed-off-by: Jarod Wilson <jarod@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
jarodwilson authored and herbertx committed Jun 2, 2009
1 parent a1915d5 commit a3bef3a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,9 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
if (i < 0)
goto notest;

if (fips_enabled && !alg_test_descs[i].fips_allowed)
goto non_fips_alg;

rc = alg_test_cipher(alg_test_descs + i, driver, type, mask);
goto test_done;
}
Expand All @@ -2316,6 +2319,9 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
if (i < 0)
goto notest;

if (fips_enabled && !alg_test_descs[i].fips_allowed)
goto non_fips_alg;

rc = alg_test_descs[i].test(alg_test_descs + i, driver,
type, mask);
test_done:
Expand All @@ -2331,5 +2337,7 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
notest:
printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);
return 0;
non_fips_alg:
return -EINVAL;
}
EXPORT_SYMBOL_GPL(alg_test);

0 comments on commit a3bef3a

Please sign in to comment.