Source release 14.2.0
This commit is contained in:
@@ -12,12 +12,10 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "test_keybox.h"
|
||||
#include "oec_test_data.h"
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
using namespace wvcdm_test_auth;
|
||||
|
||||
DeviceFeatures global_features;
|
||||
|
||||
void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
@@ -112,9 +110,6 @@ void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
case LOAD_TEST_RSA_KEY:
|
||||
printf("LOAD_TEST_RSA_KEY: Call LoadTestRSAKey before deriving keys.\n");
|
||||
break;
|
||||
case EXISTING_TEST_KEYBOX:
|
||||
printf("EXISTING_TEST_KEYBOX: Keybox is already the test keybox.\n");
|
||||
break;
|
||||
case FORCE_TEST_KEYBOX:
|
||||
printf("FORCE_TEST_KEYBOX: User requested calling InstallKeybox.\n");
|
||||
break;
|
||||
@@ -122,6 +117,11 @@ void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
printf("TEST_PROVISION_30: Device provisioed with OEM Cert.\n");
|
||||
break;
|
||||
}
|
||||
std::string security_level = OEMCrypto_SecurityLevel();
|
||||
supports_level_1 = (security_level == "L1");
|
||||
printf("SecurityLevel is %s (%s)",
|
||||
supports_level_1 ? "Level 1" : "Not Level 1",
|
||||
security_level.c_str());
|
||||
OEMCrypto_Terminate();
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) {
|
||||
if (api_version < 12) FilterOut(&filter, "*API12*");
|
||||
if (api_version < 13) FilterOut(&filter, "*API13*");
|
||||
if (api_version < 14) FilterOut(&filter, "*API14*");
|
||||
if (api_version < 15) FilterOut(&filter, "*API15*");
|
||||
// Some tests may require root access. If user is not root, filter these tests
|
||||
// out.
|
||||
if (getuid()) {
|
||||
@@ -184,33 +185,12 @@ void DeviceFeatures::PickDerivedKey() {
|
||||
// If device uses a keybox, try to load the test keybox.
|
||||
if (OEMCrypto_ERROR_NOT_IMPLEMENTED != OEMCrypto_LoadTestKeybox(NULL, 0)) {
|
||||
derive_key_method = LOAD_TEST_KEYBOX;
|
||||
} else if (IsTestKeyboxInstalled()) {
|
||||
derive_key_method = EXISTING_TEST_KEYBOX;
|
||||
}
|
||||
} else if (OEMCrypto_ERROR_NOT_IMPLEMENTED != OEMCrypto_LoadTestRSAKey()) {
|
||||
derive_key_method = LOAD_TEST_RSA_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceFeatures::IsTestKeyboxInstalled() {
|
||||
uint8_t key_data[256];
|
||||
size_t key_data_len = sizeof(key_data);
|
||||
if (OEMCrypto_GetKeyData(key_data, &key_data_len) != OEMCrypto_SUCCESS)
|
||||
return false;
|
||||
if (key_data_len != sizeof(wvcdm_test_auth::kValidKeybox01.data_)) return false;
|
||||
if (memcmp(key_data, wvcdm_test_auth::kValidKeybox01.data_, key_data_len)) return false;
|
||||
uint8_t dev_id[128] = {0};
|
||||
size_t dev_id_len = 128;
|
||||
if (OEMCrypto_GetDeviceID(dev_id, &dev_id_len) != OEMCrypto_SUCCESS)
|
||||
return false;
|
||||
// We use strncmp instead of memcmp because we don't really care about the
|
||||
// multiple '\0' characters at the end of the device id.
|
||||
return 0 == strncmp(
|
||||
reinterpret_cast<const char*>(dev_id),
|
||||
reinterpret_cast<const char*>(wvcdm_test_auth::kValidKeybox01.device_id_),
|
||||
sizeof(wvcdm_test_auth::kValidKeybox01.device_id_));
|
||||
}
|
||||
|
||||
void DeviceFeatures::FilterOut(std::string* current_filter,
|
||||
const std::string& new_filter) {
|
||||
if (current_filter->find('-') == std::string::npos) {
|
||||
|
||||
Reference in New Issue
Block a user