Testbed classes inherit from oemcrypto reference code

Merge from Widevine repo of http://go/wvgerrit/58200

This CL removes code from the testbed that is duplicated in the
reference code using inheritance.

bug: 76393338 Split mock into reference code and testbed code
test: unit tests
Change-Id: I7b5f5330a595fa1756e6dfdf75bc07addb6107a8
This commit is contained in:
Fred Gylys-Colwell
2018-09-02 13:20:14 -07:00
parent a0961a8834
commit 3a2d291dc5
8 changed files with 98 additions and 97 deletions

View File

@@ -30,7 +30,7 @@ namespace wvoec_ref {
CryptoEngine::CryptoEngine(scoped_ptr<wvcdm::FileSystem> file_system)
: root_of_trust_(config_provisioning_method()),
file_system_(file_system),
usage_table_(this) {
usage_table_(NULL) {
ERR_load_crypto_strings();
}
@@ -44,16 +44,25 @@ CryptoEngine::~CryptoEngine() {
ERR_free_strings();
}
SessionId CryptoEngine::CreateSession() {
wvcdm::AutoLock lock(session_table_lock_);
static int unique_id = 1;
SessionId sid = (SessionId)++unique_id;
SessionContext* sctx =
new SessionContext(this, sid, root_of_trust_.SharedRsaKey());
sessions_[sid] = sctx;
return sid;
bool CryptoEngine::Initialize() {
usage_table_.reset(MakeUsageTable());
return true;
}
SessionId CryptoEngine::OpenSession() {
wvcdm::AutoLock lock(session_table_lock_);
static OEMCrypto_SESSION unique_id = 1;
SessionId id = ++unique_id;
sessions_[id] = MakeSession(id);
return id;
}
SessionContext* CryptoEngine::MakeSession(SessionId sid) {
return new SessionContext(this, sid, root_of_trust_.SharedRsaKey());
}
UsageTable* CryptoEngine::MakeUsageTable() { return new UsageTable(this); }
bool CryptoEngine::DestroySession(SessionId sid) {
SessionContext* sctx = FindSession(sid);
wvcdm::AutoLock lock(session_table_lock_);