am f2afd994: Add Property for Provisioning ID
* commit 'f2afd99431694ac9f45ab729bbba6d7ff63505d6': Add Property for Provisioning ID
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#define CDM_BASE_CRYPTO_ENGINE_H_
|
#define CDM_BASE_CRYPTO_ENGINE_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "crypto_session.h"
|
#include "crypto_session.h"
|
||||||
@@ -51,6 +52,7 @@ class CryptoEngine {
|
|||||||
SecurityLevel GetSecurityLevel();
|
SecurityLevel GetSecurityLevel();
|
||||||
bool GetDeviceUniqueId(std::string* deviceId);
|
bool GetDeviceUniqueId(std::string* deviceId);
|
||||||
bool GetSystemId(uint32_t* systemId);
|
bool GetSystemId(uint32_t* systemId);
|
||||||
|
bool GetProvisioningId(std::string* provisioningId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ static const size_t KEY_IV_SIZE = 16;
|
|||||||
static const size_t KEY_PAD_SIZE = 16;
|
static const size_t KEY_PAD_SIZE = 16;
|
||||||
static const size_t KEY_SIZE = 16;
|
static const size_t KEY_SIZE = 16;
|
||||||
static const size_t MAC_KEY_SIZE = 32;
|
static const size_t MAC_KEY_SIZE = 32;
|
||||||
|
static const size_t KEYBOX_KEY_DATA_SIZE = 72;
|
||||||
|
|
||||||
static const std::string SESSION_ID_PREFIX = "sid";
|
static const std::string SESSION_ID_PREFIX = "sid";
|
||||||
static const std::string KEY_SET_ID_PREFIX = "ksid";
|
static const std::string KEY_SET_ID_PREFIX = "ksid";
|
||||||
@@ -46,6 +47,8 @@ static const std::string QUERY_KEY_DEVICE_ID = "DeviceID";
|
|||||||
// device unique id
|
// device unique id
|
||||||
static const std::string QUERY_KEY_SYSTEM_ID = "SystemID";
|
static const std::string QUERY_KEY_SYSTEM_ID = "SystemID";
|
||||||
// system id
|
// system id
|
||||||
|
static const std::string QUERY_KEY_PROVISIONING_ID = "ProvisioningID";
|
||||||
|
// provisioning unique id
|
||||||
|
|
||||||
static const std::string QUERY_VALUE_TRUE = "True";
|
static const std::string QUERY_VALUE_TRUE = "True";
|
||||||
static const std::string QUERY_VALUE_FALSE = "False";
|
static const std::string QUERY_VALUE_FALSE = "False";
|
||||||
|
|||||||
@@ -403,6 +403,12 @@ CdmResponseType CdmEngine::QueryStatus(CdmQueryMap* key_info) {
|
|||||||
(*key_info)[QUERY_KEY_SYSTEM_ID] = system_id_stream.str();
|
(*key_info)[QUERY_KEY_SYSTEM_ID] = system_id_stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string provisioning_id;
|
||||||
|
success = crypto_engine->GetProvisioningId(&provisioning_id);
|
||||||
|
if (success) {
|
||||||
|
(*key_info)[QUERY_KEY_PROVISIONING_ID] = provisioning_id;
|
||||||
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,13 +168,13 @@ bool CryptoEngine::GetToken(std::string* token) {
|
|||||||
LOGE("CryptoEngine::GetToken : No token passed to method.");
|
LOGE("CryptoEngine::GetToken : No token passed to method.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t buf[72];
|
uint8_t buf[KEYBOX_KEY_DATA_SIZE];
|
||||||
size_t buflen = 72;
|
size_t bufSize = sizeof(buf);
|
||||||
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &buflen);
|
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &bufSize);
|
||||||
if (OEMCrypto_SUCCESS != sts) {
|
if (OEMCrypto_SUCCESS != sts) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
token->assign((const char*)buf, (size_t)buflen);
|
token->assign((const char*)buf, bufSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +182,9 @@ CryptoEngine::SecurityLevel CryptoEngine::GetSecurityLevel() {
|
|||||||
if (!Init())
|
if (!Init())
|
||||||
return kSecurityLevelUnknown;
|
return kSecurityLevelUnknown;
|
||||||
|
|
||||||
|
LOGV("CryptoEngine::GetSecurityLevel: Lock");
|
||||||
|
AutoLock auto_lock(crypto_lock_);
|
||||||
|
|
||||||
std::string security_level = OEMCrypto_SecurityLevel();
|
std::string security_level = OEMCrypto_SecurityLevel();
|
||||||
|
|
||||||
if ((security_level.size() != 2) ||
|
if ((security_level.size() != 2) ||
|
||||||
@@ -203,6 +206,14 @@ bool CryptoEngine::GetDeviceUniqueId(std::string* deviceId) {
|
|||||||
if (!Init())
|
if (!Init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!deviceId) {
|
||||||
|
LOGE("CryptoEngine::GetDeviceUniqueId : No buffer passed to method.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGV("CryptoEngine::GetDeviceUniqueId: Lock");
|
||||||
|
AutoLock auto_lock(crypto_lock_);
|
||||||
|
|
||||||
std::vector<uint8_t> id;
|
std::vector<uint8_t> id;
|
||||||
size_t idLength = 32;
|
size_t idLength = 32;
|
||||||
|
|
||||||
@@ -222,10 +233,18 @@ bool CryptoEngine::GetSystemId(uint32_t* systemId) {
|
|||||||
if (!Init())
|
if (!Init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t buf[72];
|
if (!systemId) {
|
||||||
size_t buflen = 72;
|
LOGE("CryptoEngine::GetSystemId : No buffer passed to method.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &buflen);
|
LOGV("CryptoEngine::GetSystemId: Lock");
|
||||||
|
AutoLock auto_lock(crypto_lock_);
|
||||||
|
|
||||||
|
uint8_t buf[KEYBOX_KEY_DATA_SIZE];
|
||||||
|
size_t bufSize = sizeof(buf);
|
||||||
|
|
||||||
|
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &bufSize);
|
||||||
|
|
||||||
if (OEMCrypto_SUCCESS != sts) {
|
if (OEMCrypto_SUCCESS != sts) {
|
||||||
return false;
|
return false;
|
||||||
@@ -239,4 +258,29 @@ bool CryptoEngine::GetSystemId(uint32_t* systemId) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CryptoEngine::GetProvisioningId(std::string* provisioningId) {
|
||||||
|
if (!Init())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!provisioningId) {
|
||||||
|
LOGE("CryptoEngine::GetProvisioningId : No buffer passed to method.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGV("CryptoEngine::GetProvisioningId: Lock");
|
||||||
|
AutoLock auto_lock(crypto_lock_);
|
||||||
|
|
||||||
|
uint8_t buf[KEYBOX_KEY_DATA_SIZE];
|
||||||
|
size_t bufSize = sizeof(buf);
|
||||||
|
|
||||||
|
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &bufSize);
|
||||||
|
|
||||||
|
if (OEMCrypto_SUCCESS != sts) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioningId->assign(reinterpret_cast<char*>(&buf[8]), 16);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace wvcdm
|
}; // namespace wvcdm
|
||||||
|
|||||||
@@ -534,6 +534,10 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
|||||||
EXPECT_TRUE(ss >> system_id);
|
EXPECT_TRUE(ss >> system_id);
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
|
|
||||||
|
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
|
||||||
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
|
EXPECT_EQ(16, (int)itr->second.size());
|
||||||
|
|
||||||
decryptor_.CloseSession(session_id_);
|
decryptor_.CloseSession(session_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -382,12 +382,30 @@ status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
|||||||
ALOGE("Error querying CDM status: %u", res);
|
ALOGE("Error querying CDM status: %u", res);
|
||||||
return mapCdmResponseType(res);
|
return mapCdmResponseType(res);
|
||||||
} else if (!status.count(QUERY_KEY_DEVICE_ID)) {
|
} else if (!status.count(QUERY_KEY_DEVICE_ID)) {
|
||||||
ALOGE("CDM did not report a unique ID");
|
ALOGE("CDM did not report a device unique ID");
|
||||||
return kErrorCDMGeneric;
|
return kErrorCDMGeneric;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& uniqueId = status[QUERY_KEY_DEVICE_ID];
|
const string& uniqueId = status[QUERY_KEY_DEVICE_ID];
|
||||||
|
|
||||||
|
value.clear();
|
||||||
|
value.appendArray(reinterpret_cast<const uint8_t*>(uniqueId.data()),
|
||||||
|
uniqueId.size());
|
||||||
|
} else if (name == "provisioningUniqueId") {
|
||||||
|
CdmQueryMap status;
|
||||||
|
|
||||||
|
CdmResponseType res = mCDM->QueryStatus(&status);
|
||||||
|
|
||||||
|
if (!isCdmResponseTypeSuccess(res)) {
|
||||||
|
ALOGE("Error querying CDM status: %u", res);
|
||||||
|
return mapCdmResponseType(res);
|
||||||
|
} else if (!status.count(QUERY_KEY_PROVISIONING_ID)) {
|
||||||
|
ALOGE("CDM did not report a provisioning unique ID");
|
||||||
|
return kErrorCDMGeneric;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string& uniqueId = status[QUERY_KEY_PROVISIONING_ID];
|
||||||
|
|
||||||
value.clear();
|
value.clear();
|
||||||
value.appendArray(reinterpret_cast<const uint8_t*>(uniqueId.data()),
|
value.appendArray(reinterpret_cast<const uint8_t*>(uniqueId.data()),
|
||||||
uniqueId.size());
|
uniqueId.size());
|
||||||
|
|||||||
@@ -520,6 +520,10 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
|||||||
CdmQueryMap systemIDMap;
|
CdmQueryMap systemIDMap;
|
||||||
systemIDMap[QUERY_KEY_SYSTEM_ID] = systemId;
|
systemIDMap[QUERY_KEY_SYSTEM_ID] = systemId;
|
||||||
|
|
||||||
|
static const string provisioningId("Life\0&Everything", 16);
|
||||||
|
CdmQueryMap provisioningIDMap;
|
||||||
|
provisioningIDMap[QUERY_KEY_PROVISIONING_ID] = provisioningId;
|
||||||
|
|
||||||
EXPECT_CALL(cdm, QueryStatus(_))
|
EXPECT_CALL(cdm, QueryStatus(_))
|
||||||
.WillOnce(DoAll(SetArgPointee<0>(l1Map),
|
.WillOnce(DoAll(SetArgPointee<0>(l1Map),
|
||||||
Return(wvcdm::NO_ERROR)))
|
Return(wvcdm::NO_ERROR)))
|
||||||
@@ -528,6 +532,8 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
|||||||
.WillOnce(DoAll(SetArgPointee<0>(deviceIDMap),
|
.WillOnce(DoAll(SetArgPointee<0>(deviceIDMap),
|
||||||
Return(wvcdm::NO_ERROR)))
|
Return(wvcdm::NO_ERROR)))
|
||||||
.WillOnce(DoAll(SetArgPointee<0>(systemIDMap),
|
.WillOnce(DoAll(SetArgPointee<0>(systemIDMap),
|
||||||
|
Return(wvcdm::NO_ERROR)))
|
||||||
|
.WillOnce(DoAll(SetArgPointee<0>(provisioningIDMap),
|
||||||
Return(wvcdm::NO_ERROR)));
|
Return(wvcdm::NO_ERROR)));
|
||||||
|
|
||||||
String8 stringResult;
|
String8 stringResult;
|
||||||
@@ -564,6 +570,11 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
|||||||
res = plugin.getPropertyString(String8("systemId"), stringResult);
|
res = plugin.getPropertyString(String8("systemId"), stringResult);
|
||||||
ASSERT_EQ(OK, res);
|
ASSERT_EQ(OK, res);
|
||||||
EXPECT_STREQ(systemId.c_str(), stringResult.string());
|
EXPECT_STREQ(systemId.c_str(), stringResult.string());
|
||||||
|
|
||||||
|
res = plugin.getPropertyByteArray(String8("provisioningUniqueId"), vectorResult);
|
||||||
|
ASSERT_EQ(OK, res);
|
||||||
|
EXPECT_THAT(vectorResult, ElementsAreArray(provisioningId.data(),
|
||||||
|
provisioningId.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WVDrmPluginTest, DoesNotGetUnknownProperties) {
|
TEST_F(WVDrmPluginTest, DoesNotGetUnknownProperties) {
|
||||||
|
|||||||
Reference in New Issue
Block a user