Verify version number of Level 1 OEMCrypto before using it
There is an OEMCrypto wrapper that loads the OEM provided library. For debugging and initial implementation, this only verified that some of the API existed before continuing. With this CL, the level 1 library is not used if any of the API functions are missing, or if the version number is not correct. There is no plan to make this library backwards compatible. bug: 8621521 Merge of https://widevine-internal-review.googlesource.com/#/c/5264/ from the Widevine CDM repo. Change-Id: Ie82907925450b9fe93d0d857c1133f5382f55d21
This commit is contained in:
@@ -199,15 +199,6 @@ OEMCryptoResult OEMCrypto_Initialize(void) {
|
||||
LOOKUP(L1_GetKeyData_t, OEMCrypto_GetKeyData);
|
||||
LOOKUP(L1_GetRandom_t, OEMCrypto_GetRandom);
|
||||
LOOKUP(L1_WrapKeybox_t, OEMCrypto_WrapKeybox);
|
||||
|
||||
// TODO(fredgc): Move the validity check from here to below after we have
|
||||
// an L1 library that matches current version.
|
||||
if (!dll_valid) {
|
||||
dlclose(level1.library);
|
||||
level1.library = NULL;
|
||||
LOGW("Could not load functions from liboemcrypto.so. Falling Back to L3.");
|
||||
return Level3_Initialize();
|
||||
}
|
||||
LOOKUP(L1_RewrapDeviceRSAKey_t, OEMCrypto_RewrapDeviceRSAKey);
|
||||
LOOKUP(L1_LoadDeviceRSAKey_t, OEMCrypto_LoadDeviceRSAKey);
|
||||
LOOKUP(L1_GenerateRSASignature_t, OEMCrypto_GenerateRSASignature);
|
||||
@@ -218,10 +209,12 @@ OEMCryptoResult OEMCrypto_Initialize(void) {
|
||||
LOOKUP(L1_Generic_Encrypt_t, OEMCrypto_Generic_Encrypt);
|
||||
LOOKUP(L1_Generic_Sign_t, OEMCrypto_Generic_Sign);
|
||||
LOOKUP(L1_Generic_Verify_t, OEMCrypto_Generic_Verify);
|
||||
|
||||
// TODO(fredgc): Move the validity check from above to here after we have
|
||||
// a current L1 library.
|
||||
|
||||
if (!dll_valid) {
|
||||
dlclose(level1.library);
|
||||
level1.library = NULL;
|
||||
LOGW("Could not load functions from liboemcrypto.so. Falling Back to L3.");
|
||||
return Level3_Initialize();
|
||||
}
|
||||
OEMCryptoResult st = level1.OEMCrypto_Initialize();
|
||||
if (st != OEMCrypto_SUCCESS) {
|
||||
LOGW("Could not initialize liboemcrypto.so. Falling Back to L3.");
|
||||
@@ -231,7 +224,7 @@ OEMCryptoResult OEMCrypto_Initialize(void) {
|
||||
}
|
||||
if (level1.OEMCrypto_APIVersion) {
|
||||
uint32_t level1_version = level1.OEMCrypto_APIVersion();
|
||||
if (level1_version > oec_latest_version) { // Check for foward jump.
|
||||
if (level1_version != oec_latest_version) {
|
||||
LOGW("liboemcrypto.so is version %d, not %d. Falling Back to L3.",
|
||||
level1_version, oec_latest_version);
|
||||
dlclose(level1.library);
|
||||
|
||||
Reference in New Issue
Block a user