/* * File: Lucky13Test.cpp * Author: Juraj Somorovsky - juraj.somorovsky@hackmanit.de * */ #include "TimingTest.h" Lucky13Test::Lucky13Test(std::vector &inputs, std::string result_folder, const std::string& mac_name, size_t mac_keylen) : m_dec("AES-128", 16, mac_name, mac_keylen, true, false), m_mac_keylen (mac_keylen) { m_inputs = inputs; m_result_folder = result_folder; } std::vector Lucky13Test::prepare_input(std::string input) { const std::vector input_vector = Botan::hex_decode(input); const std::vector key(16); const std::vector iv(16); std::unique_ptr enc(Botan::get_cipher_mode("AES-128/CBC/NoPadding", Botan::ENCRYPTION)); enc->set_key(key); enc->start(iv); Botan::secure_vector buf(input_vector.begin(), input_vector.end()); enc->finish(buf); return unlock(buf); } ticks Lucky13Test::measure_critical_function(std::vector input) { Botan::secure_vector data(input.begin(), input.end()); Botan::secure_vector aad(13); const Botan::secure_vector iv(16); Botan::secure_vector key(16 + m_mac_keylen); m_dec.set_key(unlock(key)); m_dec.set_ad(unlock(aad)); m_dec.start(unlock(iv)); ticks start = this->get_ticks(); try { m_dec.finish(data); } catch (Botan::TLS::TLS_Exception e) { } ticks end = get_ticks(); return (end - start); }