Full decrypt path testing

Merge from master branch of Widevine repo of http://go/wvgerrit/66080
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64002

This CL updates OEMCrypto reference code and unit tests to support full decrypt
path testing.

Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 34078913
Change-Id: Ia67374599d6619698a336f41513068ad04294e7f
This commit is contained in:
Fred Gylys-Colwell
2018-11-12 14:21:17 -08:00
parent 4ffacfdcc7
commit 246621c5ce
12 changed files with 287 additions and 5 deletions

View File

@@ -55,6 +55,7 @@ OEMCryptoResult OEMCrypto_CreateOldUsageEntry(SecurityLevel level,
uint32_t OEMCrypto_GetAnalogOutputFlags(SecurityLevel level);
const char* OEMCrypto_BuildInformation(SecurityLevel level);
uint32_t OEMCrypto_ResourceRatingTier(SecurityLevel level);
uint32_t OEMCrypto_SupportsDecryptHash(SecurityLevel level);
} // namespace wvcdm
/* The following functions are deprecated in OEMCrypto v13. They are defined

View File

@@ -277,6 +277,15 @@ typedef OEMCryptoResult (*L1_CreateOldUsageEntry_t)(
typedef uint32_t (*L1_GetAnalogOutputFlags_t)(void);
typedef const char* (*L1_BuildInformation_t)(void);
typedef uint32_t (*L1_ResourceRatingTier_t)(void);
typedef uint32_t (*L1_SupportsDecryptHash_t)(void);
typedef OEMCryptoResult (*L1_InitializeDecryptHash_t)(
OEMCrypto_SESSION session);
typedef OEMCryptoResult (*L1_SetDecryptHash_t)(OEMCrypto_SESSION session,
uint32_t frame_number,
const uint8_t* hash,
size_t hash_length);
typedef OEMCryptoResult (*L1_GetHashErrorCode_t)(OEMCrypto_SESSION session,
uint32_t* failed_frame_number);
struct FunctionPointers {
uint32_t version;
@@ -347,6 +356,10 @@ struct FunctionPointers {
L1_GetAnalogOutputFlags_t GetAnalogOutputFlags;
L1_BuildInformation_t BuildInformation;
L1_ResourceRatingTier_t ResourceRatingTier;
L1_SupportsDecryptHash_t SupportsDecryptHash;
L1_InitializeDecryptHash_t InitializeDecryptHash;
L1_SetDecryptHash_t SetDecryptHash;
L1_GetHashErrorCode_t GetHashErrorCode;
L1_LoadKeys_V8_t LoadKeys_V8;
L1_GenerateRSASignature_V8_t GenerateRSASignature_V8;
@@ -766,6 +779,10 @@ class Adapter {
LOOKUP_ALL(13, UpdateUsageEntry, OEMCrypto_UpdateUsageEntry);
LOOKUP( 9, 12, UpdateUsageTable, OEMCrypto_UpdateUsageTable);
LOOKUP_ALL( 8, WrapKeybox, OEMCrypto_WrapKeybox);
LOOKUP_ALL(15, SupportsDecryptHash, OEMCrypto_SupportsDecryptHash);
LOOKUP_ALL(15, InitializeDecryptHash, OEMCrypto_InitializeDecryptHash);
LOOKUP_ALL(15, SetDecryptHash, OEMCrypto_SetDecryptHash);
LOOKUP_ALL(15, GetHashErrorCode, OEMCrypto_GetHashErrorCode);
// clang-format on
// If the keybox or oem certificate is valid, we are done.
@@ -902,6 +919,10 @@ class Adapter {
level3_.MoveEntry = Level3_MoveEntry;
level3_.CopyOldUsageEntry = Level3_CopyOldUsageEntry;
level3_.CreateOldUsageEntry = Level3_CreateOldUsageEntry;
// TODO(srujzs) level3_.SupportsDecryptHash = Level3_SupportsDecryptHash;
// TODO(srujzs) level3_.InitializeDecryptHash = Level3_InitializeDecryptHash;
// TODO(srujzs) level3_.SetDecryptHash = Level3_SetDecryptHash;
// TODO(srujzs) level3_.GetHashErrorCode = Level3_GetHashErrorCode;
// clang-format on
level3_.version = Level3_APIVersion();
@@ -1128,6 +1149,15 @@ uint32_t OEMCrypto_ResourceRatingTier(SecurityLevel level) {
return fcn->ResourceRatingTier();
}
uint32_t OEMCrypto_SupportsDecryptHash(SecurityLevel level) {
if (!gAdapter.get()) return OEMCrypto_Hash_Not_Supported;
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
if (!fcn) return OEMCrypto_Hash_Not_Supported;
if (fcn->version < 14) return OEMCrypto_Hash_Not_Supported;
if (fcn->BuildInformation == NULL) return OEMCrypto_Hash_Not_Supported;
return fcn->SupportsDecryptHash();
}
bool OEMCrypto_SupportsUsageTable(SecurityLevel level) {
if (!gAdapter.get()) return false;
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
@@ -2307,3 +2337,42 @@ extern "C" OEMCryptoResult OEMCrypto_CreateOldUsageEntry(
time_since_last_decrypt, status, server_mac_key, client_mac_key, pst,
pst_length);
}
extern "C" uint32_t OEMCrypto_SupportsDecryptHash(){
return OEMCrypto_SupportsDecryptHash(kLevelDefault);
}
extern "C" OEMCryptoResult OEMCrypto_InitializeDecryptHash(
OEMCrypto_SESSION session) {
if (!gAdapter.get()) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
LevelSession pair = gAdapter->GetSession(session);
if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION;
if (pair.fcn->InitializeDecryptHash == NULL) {
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
return pair.fcn->InitializeDecryptHash(pair.session);
}
extern "C" OEMCryptoResult OEMCrypto_SetDecryptHash(OEMCrypto_SESSION session,
uint32_t frame_number,
const uint8_t* hash,
size_t hash_length) {
if (!gAdapter.get()) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
LevelSession pair = gAdapter->GetSession(session);
if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION;
if (pair.fcn->SetDecryptHash == NULL) {
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
return pair.fcn->SetDecryptHash(pair.session, frame_number, hash, hash_length);
}
extern "C" OEMCryptoResult OEMCrypto_GetHashErrorCode(OEMCrypto_SESSION session,
uint32_t* failed_frame_number) {
if (!gAdapter.get()) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
LevelSession pair = gAdapter->GetSession(session);
if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION;
if (pair.fcn->GetHashErrorCode == NULL) {
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
return pair.fcn->GetHashErrorCode(pair.session, failed_frame_number);
}