From b6e09f6e854477c4875fce135f2541ad72541952 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 7 Oct 2018 03:53:32 +0200 Subject: crypto: disable broken implementations in selftests --- src/crypto/zinc/selftest/run.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/crypto') diff --git a/src/crypto/zinc/selftest/run.h b/src/crypto/zinc/selftest/run.h index 4cbafe2..99079a0 100644 --- a/src/crypto/zinc/selftest/run.h +++ b/src/crypto/zinc/selftest/run.h @@ -13,9 +13,8 @@ static inline bool selftest_run(const char *name, bool (*selftest)(void), bool *const nobs[], unsigned int nobs_len) { - unsigned long subset = 0, set = 0; + unsigned long set = 0, subset = 0, largest_subset = 0; unsigned int i; - bool ret = true; BUILD_BUG_ON(!__builtin_constant_p(nobs_len) || nobs_len >= BITS_PER_LONG); @@ -29,21 +28,21 @@ static inline bool selftest_run(const char *name, bool (*selftest)(void), do { for (i = 0; i < nobs_len; ++i) *nobs[i] = (subset >> i) & 1; - if (!selftest()) { - pr_err("%s self-test combo 0x%lx: FAIL\n", name, + if (selftest()) + largest_subset = max(subset, largest_subset); + else + pr_err("%s self-test combination 0x%lx: FAIL\n", name, subset); - ret = false; - } subset = (subset - set) & set; } while (subset); for (i = 0; i < nobs_len; ++i) - *nobs[i] = (set >> i) & 1; + *nobs[i] = (largest_subset >> i) & 1; - if (ret) + if (largest_subset == set) pr_info("%s self-tests: pass\n", name); - return !WARN_ON(!ret); + return !WARN_ON(largest_subset != set); } #endif -- cgit v1.2.3-59-g8ed1b