Fix System ID problem for devices with no keybox am: f6d682b182 am: bf776ef27d
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/16408945 Change-Id: I5e1965104ff03a6d973ecf3727121d9f91dc1e26
This commit is contained in:
committed by
Automerger Merge Worker
commit
1373c554a8
@@ -25,7 +25,6 @@ using ::testing::Ge;
|
||||
using ::testing::Le;
|
||||
|
||||
namespace {
|
||||
|
||||
const uint8_t kOemCert[] = {
|
||||
0x30, 0x82, 0x09, 0xf7, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
|
||||
0x01, 0x07, 0x02, 0xa0, 0x82, 0x09, 0xe8, 0x30, 0x82, 0x09, 0xe4, 0x02,
|
||||
@@ -243,6 +242,8 @@ const uint8_t kOemCert[] = {
|
||||
|
||||
const uint32_t kOemCertSystemId = 7346;
|
||||
|
||||
constexpr uint32_t kNullSystemId =
|
||||
static_cast<uint32_t>(std::numeric_limits<int>::max());
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -274,14 +275,16 @@ TEST(CryptoSessionTest, CanExtractSystemIdFromOemCertificate) {
|
||||
class CryptoSessionMetricsTest : public WvCdmTestBase {
|
||||
protected:
|
||||
uint32_t FindKeyboxSystemID() {
|
||||
OEMCryptoResult sts;
|
||||
if (CryptoSession::needs_keybox_provisioning()) {
|
||||
return kNullSystemId;
|
||||
}
|
||||
uint8_t key_data[256];
|
||||
size_t key_data_len = sizeof(key_data);
|
||||
sts = OEMCrypto_GetKeyData(key_data, &key_data_len, kLevelDefault);
|
||||
if (sts != OEMCrypto_SUCCESS) return 0;
|
||||
uint32_t* data = reinterpret_cast<uint32_t*>(key_data);
|
||||
uint32_t system_id = htonl(data[1]);
|
||||
return system_id;
|
||||
const OEMCryptoResult sts =
|
||||
OEMCrypto_GetKeyData(key_data, &key_data_len, kLevelDefault);
|
||||
if (sts != OEMCrypto_SUCCESS) return kNullSystemId;
|
||||
const uint32_t* data = reinterpret_cast<uint32_t*>(key_data);
|
||||
return htonl(data[1]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -318,18 +321,24 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||
CdmClientTokenType token_type = session->GetPreProvisionTokenType();
|
||||
|
||||
if (token_type == kClientTokenKeybox) {
|
||||
uint32_t system_id = FindKeyboxSystemID();
|
||||
EXPECT_EQ(system_id, metrics_proto.crypto_session_system_id().int_value());
|
||||
const uint32_t expected_system_id = FindKeyboxSystemID();
|
||||
const uint32_t recorded_system_id =
|
||||
metrics_proto.crypto_session_system_id().int_value();
|
||||
EXPECT_EQ(expected_system_id, recorded_system_id);
|
||||
EXPECT_EQ(OEMCrypto_Keybox,
|
||||
metrics_proto.oemcrypto_provisioning_method().int_value());
|
||||
EXPECT_EQ(1, metrics_proto.oemcrypto_get_key_data_time_us().size());
|
||||
if (recorded_system_id != kNullSystemId) {
|
||||
// Devices with a null system ID don't actually call into the
|
||||
// TEE for the keybox.
|
||||
EXPECT_EQ(1, metrics_proto.oemcrypto_get_key_data_time_us().size());
|
||||
}
|
||||
} else if (token_type == kClientTokenOemCert) {
|
||||
// Recent devices all have a system id between 1k and 6 or 7k. Errors
|
||||
// we are trying to catch are 0, byte swapped 32 bit numbers, or
|
||||
// garbage. These errors will most likely be outside the range of 1000
|
||||
// to 2^16.
|
||||
EXPECT_LE(1000, metrics_proto.crypto_session_system_id().int_value());
|
||||
EXPECT_GT(0X10000, metrics_proto.crypto_session_system_id().int_value());
|
||||
EXPECT_GT(0x10000, metrics_proto.crypto_session_system_id().int_value());
|
||||
|
||||
EXPECT_EQ(OEMCrypto_OEMCertificate,
|
||||
metrics_proto.oemcrypto_provisioning_method().int_value());
|
||||
@@ -368,9 +377,13 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
||||
ASSERT_EQ(1, metrics_proto.crypto_session_get_token().size());
|
||||
EXPECT_EQ(1, metrics_proto.crypto_session_get_token(0).count());
|
||||
|
||||
uint32_t system_id = FindKeyboxSystemID();
|
||||
EXPECT_EQ(system_id, metrics_proto.crypto_session_system_id().int_value());
|
||||
EXPECT_EQ(1, metrics_proto.oemcrypto_get_key_data_time_us().size());
|
||||
const uint32_t expected_system_id = FindKeyboxSystemID();
|
||||
const uint32_t recorded_system_id =
|
||||
metrics_proto.crypto_session_system_id().int_value();
|
||||
EXPECT_EQ(expected_system_id, recorded_system_id);
|
||||
if (recorded_system_id != kNullSystemId) {
|
||||
EXPECT_EQ(1, metrics_proto.oemcrypto_get_key_data_time_us().size());
|
||||
}
|
||||
} else if (token_type == kClientTokenOemCert) {
|
||||
// Recent devices all have a system id between 1k and 6 or 7k. Errors
|
||||
// we are trying to catch are 0, byte swapped 32 bit numbers, or
|
||||
|
||||
Reference in New Issue
Block a user