/* * File: TimingTest.h * Author: Juraj Somorovsky - juraj.somorovsky@hackmanit.de * */ #ifndef TIMINGTEST_H #define TIMINGTEST_H #include #include #include #include #include #include #include #include #include #include #include #include using namespace Botan; typedef unsigned long long ticks; class TimingTest { protected: std::string m_result_folder; std::vector m_inputs; std::vector m_results; unsigned int m_warmup_iterations = 500; unsigned int m_measurement_iterations = 10000; virtual std::vector prepare_input(std::string input) = 0; virtual ticks measure_critical_function(std::vector input) = 0; public: TimingTest(); virtual ~TimingTest(); void execute_evaluation(); void store_results_in_file(std::string file_name); ticks get_ticks(); }; class BleichenbacherTest : public TimingTest { private: const std::string m_encrypt_padding = "Raw"; const std::string m_decrypt_padding = "PKCS1v15"; const size_t m_expected_content_size = 48; const size_t m_ctext_length = 256; RSA_PrivateKey m_privkey; RSA_PublicKey m_pubkey; PK_Encryptor_EME m_enc; PK_Decryptor_EME m_dec; protected: std::vector prepare_input(std::string input) override; ticks measure_critical_function(std::vector input) override; public: BleichenbacherTest(std::vector &inputs, std::string result_file, int keysize); }; class MangerTest : public TimingTest { private: const std::string m_encrypt_padding = "Raw"; const std::string m_decrypt_padding = "EME1(SHA-256)"; const size_t m_ctext_length = 256; RSA_PrivateKey m_privkey; RSA_PublicKey m_pubkey; PK_Encryptor_EME m_enc; PK_Decryptor_EME m_dec; protected: std::vector prepare_input(std::string input) override; ticks measure_critical_function(std::vector input) override; public: MangerTest(std::vector &inputs, std::string result_file, int keysize); }; class Lucky13Test : public TimingTest { private: const std::string m_mac_algo; const size_t m_mac_keylen; Botan::TLS::TLS_CBC_HMAC_AEAD_Decryption m_dec; protected: std::vector prepare_input(std::string input) override; ticks measure_critical_function(std::vector input) override; public: Lucky13Test(std::vector &inputs, std::string result_file, const std::string& mac_name, size_t mac_keylen); }; #endif /* TIMINGTEST_H */