Keep OEMCrypto testbed singleton after terminate

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

The unreleased oemcrypto test code has been modifed to keep a
singleton for the life of the process.  In order to do that, several
functions in the reference code have been made virtual, and some
initialization and termination has been moved from the constructor and
destructor to Initialize and Terminate.

Bug: http://b/120572363 Add Recoverable Errors (mod mock)
Test: unit tests
Change-Id: I300559195567a537c0700167514be0ea42363695
This commit is contained in:
Fred Gylys-Colwell
2019-02-09 10:05:09 -08:00
parent b34c9db4c7
commit d20cf6c892
4 changed files with 74 additions and 73 deletions

View File

@@ -38,12 +38,6 @@ CryptoEngine::CryptoEngine(std::unique_ptr<wvcdm::FileSystem>&& file_system)
}
CryptoEngine::~CryptoEngine() {
std::unique_lock<std::mutex> lock(session_table_lock_);
ActiveSessions::iterator it;
for (it = sessions_.begin(); it != sessions_.end(); ++it) {
delete it->second;
}
sessions_.clear();
ERR_free_strings();
}
@@ -52,6 +46,16 @@ bool CryptoEngine::Initialize() {
return true;
}
void CryptoEngine::Terminate() {
std::unique_lock<std::mutex> lock(session_table_lock_);
ActiveSessions::iterator it;
for (it = sessions_.begin(); it != sessions_.end(); ++it) {
delete it->second;
}
sessions_.clear();
root_of_trust_.Clear();
}
SessionId CryptoEngine::OpenSession() {
std::unique_lock<std::mutex> lock(session_table_lock_);
static OEMCrypto_SESSION unique_id = 1;