This CL removes some unused variables, and changes some integers to unsigned integers. On some platforms, we were getting compiler errors and unit test failures. Merge from Widevine repo of http://go/wvgerrit/23840 Use unsigned integer literals Merge from Widevine repo of http://go/wvgerrit/23767 Fix Gyp Files Merge from Widevine repo of http://go/wvgerrit/23500 Remove unused variables bug: 31458046 Change-Id: I4dfec95ae49187262552fbbf322f3310ab777826
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
//
|
|
// Mock implementation of OEMCrypto APIs
|
|
//
|
|
#include "oemcrypto_engine_mock.h"
|
|
|
|
#include <arpa/inet.h>
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include "keys.h"
|
|
#include "log.h"
|
|
#include "oemcrypto_key_mock.h"
|
|
#include "oemcrypto_rsa_key_shared.h"
|
|
#include "string_conversions.h"
|
|
#include "wv_cdm_constants.h"
|
|
|
|
namespace wvoec_mock {
|
|
|
|
// Note: The class CryptoEngine is configured at compile time by compiling in
|
|
// different device property files. The methods in this file are generic to
|
|
// all configurations. See the files oemcrypto_engine_device_properties*.cpp
|
|
// for methods that are configured for specific configurations.
|
|
|
|
CryptoEngine::CryptoEngine(wvcdm::FileSystem* file_system)
|
|
: root_of_trust_(config_provisioning_method()),
|
|
file_system_(file_system),
|
|
usage_table_(this) {
|
|
ERR_load_crypto_strings();
|
|
}
|
|
|
|
CryptoEngine::~CryptoEngine() {
|
|
wvcdm::AutoLock lock(session_table_lock_);
|
|
ActiveSessions::iterator it;
|
|
for (it = sessions_.begin(); it != sessions_.end(); ++it) {
|
|
delete it->second;
|
|
}
|
|
sessions_.clear();
|
|
}
|
|
|
|
void CryptoEngine::Terminate() {}
|
|
|
|
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::DestroySession(SessionId sid) {
|
|
SessionContext* sctx = FindSession(sid);
|
|
wvcdm::AutoLock lock(session_table_lock_);
|
|
if (sctx) {
|
|
sessions_.erase(sid);
|
|
delete sctx;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
SessionContext* CryptoEngine::FindSession(SessionId sid) {
|
|
wvcdm::AutoLock lock(session_table_lock_);
|
|
ActiveSessions::iterator it = sessions_.find(sid);
|
|
if (it != sessions_.end()) {
|
|
return it->second;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
} // namespace wvoec_mock
|