Add Property to Access System ID

Adds a new property to the CDM's QueryStatus called QUERY_KEY_SYSTEM_ID that
contains the System ID. (as read from OEMCrypto_GetKeyData)  Adds a new
property to the DrmPlugin (cleverly named "systemId") that allows the app to
query for this.  Also adds unit tests.

Also changes the Device ID getter in crypto_engine.cpp to return a failure
instead of an empty ID.

Bug: 8621632

Merge of https://widevine-internal-review.googlesource.com/#/c/5010/ from
widevine cdm repository to android repository.

Change-Id: I8f309af18487c499e8ce25e829059e45623ea4dc
This commit is contained in:
Jeff Tinker
2013-04-18 13:55:15 -07:00
parent 0fc9bf9699
commit 0ab787b958
8 changed files with 87 additions and 25 deletions

View File

@@ -5,6 +5,7 @@
#include "crypto_engine.h"
#include <arpa/inet.h> // TODO(fredgc): Add ntoh to wv_cdm_utilities.h
#include <iostream>
#include <vector>
@@ -195,7 +196,7 @@ CryptoEngine::SecurityLevel CryptoEngine::GetSecurityLevel() {
return kSecurityLevelUnknown;
}
std::string CryptoEngine::GetDeviceUniqueId() {
bool CryptoEngine::GetDeviceUniqueId(std::string* deviceId) {
std::vector<uint8_t> id;
size_t idLength = 32;
@@ -204,10 +205,29 @@ std::string CryptoEngine::GetDeviceUniqueId() {
OEMCryptoResult sts = OEMCrypto_GetDeviceID(&id[0], &idLength);
if (OEMCrypto_SUCCESS != sts) {
return std::string();
return false;
}
return std::string(reinterpret_cast<const char*>(&id[0]));
*deviceId = reinterpret_cast<const char*>(&id[0]);
return true;
}
bool CryptoEngine::GetSystemId(uint32_t* systemId) {
uint8_t buf[72];
size_t buflen = 72;
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &buflen);
if (OEMCrypto_SUCCESS != sts) {
return false;
}
// Decode 32-bit int encoded as network-byte-order byte array starting at
// index 4.
uint32_t* id = reinterpret_cast<uint32_t*>(&buf[4]);
*systemId = ntohl(*id);
return true;
}
}; // namespace wvcdm