Add build info API to OEMCrypto

Merge from master branch of Widevine repo of http://go/wvgerrit/66065
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63080

This is for the reference code, the unit tests, and the oemcrypto adapter.

Bug: 116414218
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: I05a631f6cfcf1584a748b3a0c9ae48633893589f
This commit is contained in:
Fred Gylys-Colwell
2018-11-12 14:11:55 -08:00
parent f2edb8f2dd
commit f3e9d84484
4 changed files with 39 additions and 2 deletions

View File

@@ -56,6 +56,7 @@ OEMCryptoResult OEMCrypto_CreateOldUsageEntry(SecurityLevel level,
uint8_t* server_mac_key, uint8_t* client_mac_key, const uint8_t* pst,
size_t pst_length);
uint32_t OEMCrypto_GetAnalogOutputFlags(SecurityLevel level);
const char* OEMCrypto_BuildInformation(SecurityLevel level);
} // namespace wvcdm
/* The following functions are deprecated in OEMCrypto v13. They are defined

View File

@@ -264,6 +264,7 @@ typedef OEMCryptoResult (*L1_CreateOldUsageEntry_t)(
uint8_t* server_mac_key, uint8_t* client_mac_key, const uint8_t* pst,
size_t pst_length);
typedef uint32_t (*L1_GetAnalogOutputFlags_t)(void);
typedef const char* (*L1_BuildInformation_t)(void);
struct FunctionPointers {
uint32_t version;
@@ -330,6 +331,7 @@ struct FunctionPointers {
L1_CopyOldUsageEntry_t CopyOldUsageEntry;
L1_CreateOldUsageEntry_t CreateOldUsageEntry;
L1_GetAnalogOutputFlags_t GetAnalogOutputFlags;
L1_BuildInformation_t BuildInformation;
L1_LoadKeys_V8_t LoadKeys_V8;
L1_GenerateRSASignature_V8_t GenerateRSASignature_V8;
@@ -567,6 +569,10 @@ class Adapter {
WatchDog *watcher = new WatchDog();
watcher->CheckForPreviousFailure(&metrics);
watcher->StartThread();
if (level3_.BuildInformation) {
LOGI("Level 3 Build Info (v%d): %s", level3_.version,
level3_.BuildInformation());
}
OEMCryptoResult result = watcher->WaitForStatusAndCleanUp();
if (Level3_IsInApp()) {
metrics.SetInitializationMode(
@@ -599,6 +605,10 @@ class Adapter {
}
if (LoadLevel1(&metrics)) {
LOGD("OEMCrypto_Initialize Level 1 success. I will use level 1.");
if (level1_.BuildInformation) {
LOGI("Level 1 Build Info (v%d): %s", level1_.version,
level1_.BuildInformation());
}
} else {
level1_ = FunctionPointers(); // revert to all null pointers.
level1_valid_ = false;
@@ -677,15 +687,16 @@ class Adapter {
LOOKUP( 9, 9, GetHDCPCapability_V9, OEMCrypto_GetHDCPCapability_V9);
LOOKUP_ALL(10, GetHDCPCapability, OEMCrypto_GetHDCPCapability);
LOOKUP_ALL(14, GetAnalogOutputFlags, OEMCrypto_GetAnalogOutputFlags);
LOOKUP_ALL(15, BuildInformation, OEMCrypto_BuildInformation);
LOOKUP_ALL( 8, GetKeyData, OEMCrypto_GetKeyData);
LOOKUP_ALL(10, GetMaxNumberOfSessions, OEMCrypto_GetMaxNumberOfSessions);
LOOKUP_ALL(10, GetNumberOfOpenSessions, OEMCrypto_GetNumberOfOpenSessions);
LOOKUP_ALL(12, GetOEMPublicCertificate, OEMCrypto_GetOEMPublicCertificate);
LOOKUP_ALL(12, GetProvisioningMethod, OEMCrypto_GetProvisioningMethod);
LOOKUP_ALL( 8, GetRandom, OEMCrypto_GetRandom);
LOOKUP_ALL( 8, InstallKeyboxOrOEMCert, OEMCrypto_InstallKeyboxOrOEMCert);
LOOKUP_ALL( 8, InstallKeyboxOrOEMCert, OEMCrypto_InstallKeyboxOrOEMCert);
LOOKUP_ALL(10, IsAntiRollbackHwPresent, OEMCrypto_IsAntiRollbackHwPresent);
LOOKUP_ALL( 8, IsKeyboxOrOEMCertValid, OEMCrypto_IsKeyboxOrOEMCertValid);
LOOKUP_ALL( 8, IsKeyboxOrOEMCertValid, OEMCrypto_IsKeyboxOrOEMCertValid);
LOOKUP_ALL(13, IsSRMUpdateSupported, OEMCrypto_IsSRMUpdateSupported);
LOOKUP_ALL( 8, LoadDeviceRSAKey, OEMCrypto_LoadDeviceRSAKey);
LOOKUP( 8, 8, LoadKeys_V8, OEMCrypto_LoadKeys_V8);
@@ -820,6 +831,7 @@ class Adapter {
level3_.SecurityLevel = Level3_SecurityLevel;
level3_.GetHDCPCapability = Level3_GetHDCPCapability;
level3_.GetAnalogOutputFlags = Level3_GetAnalogOutputFlags;
// TODO(srujzs) level3_.BuildInformation = Level3_BuildInformation;
level3_.SupportsUsageTable = Level3_SupportsUsageTable;
level3_.IsAntiRollbackHwPresent = Level3_IsAntiRollbackHwPresent;
level3_.GetNumberOfOpenSessions = Level3_GetNumberOfOpenSessions;
@@ -1066,6 +1078,15 @@ uint32_t OEMCrypto_GetAnalogOutputFlags(SecurityLevel level) {
return fcn->GetAnalogOutputFlags();
}
const char* OEMCrypto_BuildInformation(SecurityLevel level) {
if (!gAdapter.get()) return "<not initialized>";
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
if (!fcn) return "<not initialized>";
if (fcn->version < 14) return "pre v15";
if (fcn->BuildInformation == NULL) return "unknown";
return fcn->BuildInformation();
}
bool OEMCrypto_SupportsUsageTable(SecurityLevel level) {
if (!gAdapter.get()) return false;
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
@@ -1231,6 +1252,10 @@ extern "C" uint32_t OEMCrypto_GetAnalogOutputFlags() {
return OEMCrypto_GetAnalogOutputFlags(kLevelDefault);
}
extern "C" const char* OEMCrypto_BuildInformation(){
return OEMCrypto_BuildInformation(kLevelDefault);
}
extern "C" OEMCryptoResult OEMCrypto_LoadKeys_Back_Compat(
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
const uint8_t* signature, size_t signature_length,