aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 03:53:32 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 03:59:44 +0200
commitb6e09f6e854477c4875fce135f2541ad72541952 (patch)
tree8f26a30a8be5e06b0247d8ae5947dc0be5ec3daf
parentcompat: clang cannot handle __builtin_constant_p (diff)
downloadwireguard-monolithic-historical-b6e09f6e854477c4875fce135f2541ad72541952.tar.xz
wireguard-monolithic-historical-b6e09f6e854477c4875fce135f2541ad72541952.zip
crypto: disable broken implementations in selftests
-rw-r--r--src/crypto/zinc/selftest/run.h17
1 files changed, 8 insertions, 9 deletions
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