Source release v3.5.0
This commit is contained in:
@@ -8,10 +8,12 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "oec_test_data.h"
|
||||
#include "test_keybox.h"
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
using namespace wvcdm_test_auth;
|
||||
|
||||
DeviceFeatures global_features;
|
||||
|
||||
void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
@@ -22,6 +24,7 @@ void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
loads_certificate = false;
|
||||
generic_crypto = false;
|
||||
usage_table = false;
|
||||
supports_rsa_3072 = false;
|
||||
api_version = 0;
|
||||
derive_key_method = NO_METHOD;
|
||||
if (OEMCrypto_SUCCESS != OEMCrypto_Initialize()) {
|
||||
@@ -70,13 +73,24 @@ void DeviceFeatures::Initialize(bool is_cast_receiver,
|
||||
OEMCrypto_CloseSession(session);
|
||||
api_version = OEMCrypto_APIVersion();
|
||||
printf("api_version = %d.\n", api_version);
|
||||
usage_table = OEMCrypto_SupportsUsageTable();
|
||||
// These unit tests only work with new usage tables. We do not test v12
|
||||
// usage tables.
|
||||
if (api_version > 12) usage_table = OEMCrypto_SupportsUsageTable();
|
||||
printf("usage_table = %s.\n", usage_table ? "true" : "false");
|
||||
if (force_load_test_keybox) {
|
||||
derive_key_method = FORCE_TEST_KEYBOX;
|
||||
} else {
|
||||
PickDerivedKey();
|
||||
}
|
||||
if (api_version >= 13) {
|
||||
uint32_t supported_cert = OEMCrypto_SupportedCertificates();
|
||||
if (supported_cert & OEMCrypto_Supports_RSA_CAST) {
|
||||
cast_receiver = true;
|
||||
}
|
||||
if (supported_cert & OEMCrypto_Supports_RSA_3072bit) {
|
||||
supports_rsa_3072 = true;
|
||||
}
|
||||
}
|
||||
printf("cast_receiver = %s.\n", cast_receiver ? "true" : "false");
|
||||
switch (derive_key_method) {
|
||||
case NO_METHOD:
|
||||
@@ -120,9 +134,12 @@ std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) {
|
||||
if (derive_key_method == NO_METHOD) FilterOut(&filter, "*SessionTest*");
|
||||
if (provisioning_method
|
||||
!= OEMCrypto_OEMCertificate) FilterOut(&filter, "*Prov30*");
|
||||
if (!supports_rsa_3072) FilterOut(&filter, "*RSAKey3072*");
|
||||
if (api_version < 9) FilterOut(&filter, "*API09*");
|
||||
if (api_version < 10) FilterOut(&filter, "*API10*");
|
||||
if (api_version < 11) FilterOut(&filter, "*API11*");
|
||||
if (api_version < 12) FilterOut(&filter, "*API12*");
|
||||
if (api_version < 13) FilterOut(&filter, "*API13*");
|
||||
// Performance tests take a long time. Filter them out if they are not
|
||||
// specifically requested.
|
||||
if (filter.find("Performance") == std::string::npos) {
|
||||
@@ -170,17 +187,18 @@ bool DeviceFeatures::IsTestKeyboxInstalled() {
|
||||
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(kTestKeybox.data_)) return false;
|
||||
if (memcmp(key_data, kTestKeybox.data_, key_data_len)) return false;
|
||||
if (key_data_len != kKeyboxDataSize) return false;
|
||||
if (memcmp(key_data, &kKeybox[kKeyboxDataOffset], 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*>(kTestKeybox.device_id_),
|
||||
sizeof(kTestKeybox.device_id_));
|
||||
return 0 == strncmp(
|
||||
reinterpret_cast<const char*>(dev_id),
|
||||
reinterpret_cast<const char*>(&kKeybox[kKeyboxDeviceIdOffset]),
|
||||
kKeyboxDeviceIdSize);
|
||||
}
|
||||
|
||||
void DeviceFeatures::FilterOut(std::string* current_filter,
|
||||
@@ -203,6 +221,7 @@ const char* ProvisioningMethodName(OEMCrypto_ProvisioningMethod method) {
|
||||
case OEMCrypto_OEMCertificate:
|
||||
return "OEMCrypto_OEMCertificate";
|
||||
}
|
||||
// Not reachable
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user