aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/unit_ecc.cpp
diff options
context:
space:
mode:
authorMatthias Gierlings <[email protected]>2017-12-24 15:41:31 +0100
committerMatthias Gierlings <[email protected]>2017-12-24 15:41:31 +0100
commitc87d70cd839fa40a1d0c88fa708feab18da4b817 (patch)
treead7934f85b90ec3860ce464241e7660ebff6f82e /src/tests/unit_ecc.cpp
parentc226725c40758af5dd5c24f810e4f1354deb3783 (diff)
Fixes #1370 UBSan incompatible function ptr type
Calls `Botan::redc_pXXX` directly inside non-capturing lambda function, which can be converted to `std::function<void (...)>`, instead of passing an incompatible `void(*)` to `NIST_Curve_Reduction_Tests::random_redc_test`.
Diffstat (limited to 'src/tests/unit_ecc.cpp')
-rw-r--r--src/tests/unit_ecc.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp
index 83e429af7..852420244 100644
--- a/src/tests/unit_ecc.cpp
+++ b/src/tests/unit_ecc.cpp
@@ -188,12 +188,42 @@ class NIST_Curve_Reduction_Tests final : public Test
std::vector<Test::Result> results;
#if defined(BOTAN_HAS_NIST_PRIME_REDUCERS_W32)
- results.push_back(random_redc_test("P-384", Botan::prime_p384(), Botan::redc_p384));
- results.push_back(random_redc_test("P-256", Botan::prime_p256(), Botan::redc_p256));
- results.push_back(random_redc_test("P-224", Botan::prime_p224(), Botan::redc_p224));
- results.push_back(random_redc_test("P-192", Botan::prime_p192(), Botan::redc_p192));
+ results.push_back(random_redc_test(
+ "P-384",
+ Botan::prime_p384(),
+ [](Botan::BigInt& p, Botan::secure_vector<Botan::word>& ws) -> void
+ {
+ Botan::redc_p384(p, ws);
+ }));
+ results.push_back(random_redc_test(
+ "P-256",
+ Botan::prime_p256(),
+ [](Botan::BigInt& p, Botan::secure_vector<Botan::word>& ws) -> void
+ {
+ Botan::redc_p256(p, ws);
+ }));
+ results.push_back(random_redc_test(
+ "P-224",
+ Botan::prime_p224(),
+ [](Botan::BigInt& p, Botan::secure_vector<Botan::word>& ws) -> void
+ {
+ Botan::redc_p224(p, ws);
+ }));
+ results.push_back(random_redc_test(
+ "P-192",
+ Botan::prime_p192(),
+ [](Botan::BigInt& p, Botan::secure_vector<Botan::word>& ws) -> void
+ {
+ Botan::redc_p192(p, ws);
+ }));
#endif
- results.push_back(random_redc_test("P-521", Botan::prime_p521(), Botan::redc_p521));
+ results.push_back(random_redc_test(
+ "P-521",
+ Botan::prime_p521(),
+ [](Botan::BigInt& p, Botan::secure_vector<Botan::word>& ws) -> void
+ {
+ Botan::redc_p521(p, ws);
+ }));
return results;
}