From c87d70cd839fa40a1d0c88fa708feab18da4b817 Mon Sep 17 00:00:00 2001 From: Matthias Gierlings Date: Sun, 24 Dec 2017 15:41:31 +0100 Subject: Fixes #1370 UBSan incompatible function ptr type Calls `Botan::redc_pXXX` directly inside non-capturing lambda function, which can be converted to `std::function`, instead of passing an incompatible `void(*)` to `NIST_Curve_Reduction_Tests::random_redc_test`. --- src/tests/unit_ecc.cpp | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src/tests/unit_ecc.cpp') 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 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& ws) -> void + { + Botan::redc_p384(p, ws); + })); + results.push_back(random_redc_test( + "P-256", + Botan::prime_p256(), + [](Botan::BigInt& p, Botan::secure_vector& ws) -> void + { + Botan::redc_p256(p, ws); + })); + results.push_back(random_redc_test( + "P-224", + Botan::prime_p224(), + [](Botan::BigInt& p, Botan::secure_vector& ws) -> void + { + Botan::redc_p224(p, ws); + })); + results.push_back(random_redc_test( + "P-192", + Botan::prime_p192(), + [](Botan::BigInt& p, Botan::secure_vector& 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& ws) -> void + { + Botan::redc_p521(p, ws); + })); return results; } -- cgit v1.2.3