aboutsummaryrefslogtreecommitdiffstats
path: root/src/extra_tests/timing/timing-tests/MangerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/extra_tests/timing/timing-tests/MangerTest.cpp')
-rw-r--r--src/extra_tests/timing/timing-tests/MangerTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/extra_tests/timing/timing-tests/MangerTest.cpp b/src/extra_tests/timing/timing-tests/MangerTest.cpp
new file mode 100644
index 000000000..6ed39819b
--- /dev/null
+++ b/src/extra_tests/timing/timing-tests/MangerTest.cpp
@@ -0,0 +1,41 @@
+/*
+ * File: MangerTest.cpp
+ * Author: Juraj Somorovsky - [email protected]
+ *
+ */
+
+#include "TimingTest.h"
+
+MangerTest::MangerTest(std::vector<std::string> &inputs, std::string result_folder, int keysize) :
+ m_privkey(system_rng(), keysize),
+ m_pubkey(m_privkey),
+ m_enc(m_pubkey, m_encrypt_padding),
+ m_dec(m_privkey, m_decrypt_padding)
+ {
+ m_inputs = inputs;
+ m_result_folder = result_folder;
+ }
+
+std::vector<byte> MangerTest::prepare_input(std::string input)
+ {
+ const std::vector<uint8_t> input_vector = Botan::hex_decode(input);
+ const std::vector<byte> encrypted = m_enc.encrypt(input_vector, system_rng());
+ return encrypted;
+ }
+
+ticks MangerTest::measure_critical_function(std::vector<byte> input)
+ {
+ const Botan::byte* in = &input[0];
+
+ ticks start = this->get_ticks();
+ try
+ {
+ m_dec.decrypt(in, m_ctext_length);
+ }
+ catch (Botan::Decoding_Error e)
+ {
+ }
+ ticks end = get_ticks();
+
+ return (end - start);
+ }