aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_utils.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-08-15 14:34:06 -0400
committerJack Lloyd <[email protected]>2017-08-15 14:34:06 -0400
commit2266362024009f0364a07dd1bcff5115180f40a7 (patch)
tree18804ff157bab625de6c095099f74971e529b566 /src/tests/test_utils.cpp
parentba2c6c7b020497178776b4574ed329586f97c211 (diff)
Improve polynomial doubling code, move to util
Now does 64-bits at a time instead of 8 bits, and avoids conditional timing channel on the XOR carry. Confirmed that at least GCC 7 and Clang 4 on x86-64 compile the functions without conditional jumps. Also removes CMAC as a dependency of OCB, which only needed it in order to call CMAC::poly_double
Diffstat (limited to 'src/tests/test_utils.cpp')
-rw-r--r--src/tests/test_utils.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tests/test_utils.cpp b/src/tests/test_utils.cpp
index a1e583cd8..0ca79b6e9 100644
--- a/src/tests/test_utils.cpp
+++ b/src/tests/test_utils.cpp
@@ -12,6 +12,7 @@
#include <botan/loadstor.h>
#include <botan/calendar.h>
#include <botan/internal/rounding.h>
+#include <botan/internal/poly_dbl.h>
#include <botan/charset.h>
#include <botan/parsing.h>
@@ -177,6 +178,27 @@ class Utility_Function_Tests : public Text_Based_Test
BOTAN_REGISTER_TEST("util", Utility_Function_Tests);
+class Poly_Double_Tests : public Text_Based_Test
+ {
+ public:
+ Poly_Double_Tests() : Text_Based_Test("poly_dbl.vec", "In,Out") {}
+
+ Test::Result run_one_test(const std::string&, const VarMap& vars) override
+ {
+ Test::Result result("Polynomial doubling");
+ const std::vector<uint8_t> in = get_req_bin(vars, "In");
+ const std::vector<uint8_t> out = get_req_bin(vars, "Out");
+
+ std::vector<uint8_t> b = in;
+ Botan::poly_double_n(b.data(), b.size());
+
+ result.test_eq("Expected value", b, out);
+ return result;
+ }
+ };
+
+BOTAN_REGISTER_TEST("poly_dbl", Poly_Double_Tests);
+
class Date_Format_Tests : public Text_Based_Test
{
public: