am 665c9c15: Verify version number of Level 1 OEMCrypto before using it
* commit '665c9c1525cd0474e58902e03ce6f19f7377e42c': Verify version number of Level 1 OEMCrypto before using it
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