Files
whitebox/api/license_whitebox_benchmark.h
Aaron Vaage 5d90e8d89b Benchmarking and Unmasking
In this code drop we introduce the benchmarking tests that allow us to
compare the performance of different implementations. Like the other
tests, any implementation can link with them to create their own
binary.

There are two types of benchmarks:
  1 - Throughput, which measures the speed that a function can process
      information (bits per second). These are used for AEAD decrypt
      and license white-box decrypt functions.
  2 - Samples, which measures the min, 25% percentile, median, 75%
      percentile, and max observed values. These is used for all other
      functions as a way to measure the execute duration of a call.

The other change in this code drop is the update to the unmasking
function to only unmask a subset of the bytes in the masked buffer.
This was added to better align with the decoder behaviour in the CDM.
2020-06-24 15:30:50 -07:00

48 lines
1.2 KiB
C++

// Copyright 2020 Google LLC. All Rights Reserved.
#ifndef WHITEBOX_API_LICENSE_WHITEBOX_BENCHMARK_H_
#define WHITEBOX_API_LICENSE_WHITEBOX_BENCHMARK_H_
#include <stdint.h>
#include <memory>
#include <vector>
#include "api/license_whitebox.h"
#include "api/test_license_builder.h"
#include "benchmarking/data_source.h"
#include "crypto_utils/rsa_key.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace widevine {
class LicenseWhiteboxBenchmark : public ::testing::Test {
protected:
virtual void SetUp() override;
License CreateLicense() const;
std::vector<uint8_t> SignAsServer(const std::vector<uint8_t>& message) const;
DataSource& Data() { return data_source_; }
const RsaPublicKey* PublicKey() const { return public_key_.get(); }
const std::vector<uint8_t>& ContentKeyId() const { return key_id_; }
const std::vector<uint8_t>& ContentKey() const { return key_; }
const std::vector<uint8_t>& ContentIV() const { return iv_; }
private:
DataSource data_source_;
std::unique_ptr<RsaPublicKey> public_key_;
std::vector<uint8_t> key_id_;
std::vector<uint8_t> key_;
std::vector<uint8_t> iv_;
};
} // namespace widevine
#endif // WHITEBOX_API_LICENSE_WHITEBOX_BENCHMARK_H_