diff --git a/benchmark/bench_crypto.cpp b/benchmark/bench_crypto.cpp index eaca9c8e2..d957c2272 100644 --- a/benchmark/bench_crypto.cpp +++ b/benchmark/bench_crypto.cpp @@ -206,14 +206,40 @@ class AesCtrOpenSSLBench : public td::Benchmark { } }; -class AesCbcBench : public td::Benchmark { +class AesCbcDecryptBench : public td::Benchmark { public: alignas(64) unsigned char data[DATA_SIZE]; td::UInt256 key; td::UInt128 iv; std::string get_description() const override { - return PSTRING() << "AES CBC OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + return PSTRING() << "AES CBC Decrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; + } + + void start_up() override { + for (int i = 0; i < DATA_SIZE; i++) { + data[i] = 123; + } + td::Random::secure_bytes(as_slice(key)); + td::Random::secure_bytes(as_slice(iv)); + } + + void run(int n) override { + td::MutableSlice data_slice(data, DATA_SIZE); + for (int i = 0; i < n; i++) { + td::aes_cbc_decrypt(as_slice(key), as_slice(iv), data_slice, data_slice); + } + } +}; + +class AesCbcEncryptBench : public td::Benchmark { + public: + alignas(64) unsigned char data[DATA_SIZE]; + td::UInt256 key; + td::UInt128 iv; + + std::string get_description() const override { + return PSTRING() << "AES CBC Encrypt OpenSSL [" << (DATA_SIZE >> 10) << "KB]"; } void start_up() override { @@ -391,6 +417,8 @@ int main() { td::bench(AesCtrBench()); td::bench(AesCtrOpenSSLBench()); + td::bench(AesCbcDecryptBench()); + td::bench(AesCbcEncryptBench()); td::bench(AesIgeShortBench()); td::bench(AesIgeShortBench()); td::bench(AesIgeEncryptBench());