Fix GenerateDerivedKeys_V18 call in dynamic adpater for prov4
The deprecated GenerateDerivedKeys_V18() should only be called by OEMCrypto_PrepAndSignProvisioningRequest() in case of prov2. Test: run_dynamic_oemcrypto_v18_p40 Bug: 317900423 Change-Id: Iff75c26a3ea107fb01e636c53528e845e24193bd
This commit is contained in:
@@ -2152,8 +2152,13 @@ extern "C" OEMCryptoResult OEMCrypto_PrepAndSignProvisioningRequest(
|
||||
LevelSession pair = gAdapter->GetSession(session);
|
||||
if (!pair.fcn) return OEMCrypto_ERROR_INVALID_SESSION;
|
||||
if (pair.fcn->PrepAndSignProvisioningRequest != nullptr) {
|
||||
const OEMCrypto_ProvisioningMethod provisioning_method =
|
||||
pair.fcn->GetProvisioningMethod != nullptr
|
||||
? pair.fcn->GetProvisioningMethod()
|
||||
: OEMCrypto_Keybox;
|
||||
if (pair.fcn->version < 19 &&
|
||||
pair.fcn->GenerateDerivedKeys_V18 != nullptr) {
|
||||
pair.fcn->GenerateDerivedKeys_V18 != nullptr &&
|
||||
provisioning_method == OEMCrypto_Keybox) {
|
||||
if (!core_message_length || *core_message_length > message_length) {
|
||||
return OEMCrypto_ERROR_INVALID_CONTEXT;
|
||||
}
|
||||
@@ -2488,8 +2493,12 @@ extern "C" OEMCryptoResult OEMCrypto_LoadProvisioning(
|
||||
core_message_length, signature, signature_length, wrapped_private_key,
|
||||
wrapped_private_key_length);
|
||||
}
|
||||
if (pair.fcn->LoadProvisioning_V18 != nullptr &&
|
||||
pair.fcn->GenerateDerivedKeys_V18 != nullptr) {
|
||||
const OEMCrypto_ProvisioningMethod provisioning_method =
|
||||
pair.fcn->GetProvisioningMethod != nullptr
|
||||
? pair.fcn->GetProvisioningMethod()
|
||||
: OEMCrypto_Keybox;
|
||||
if (pair.fcn->GenerateDerivedKeys_V18 != nullptr &&
|
||||
provisioning_method == OEMCrypto_Keybox) {
|
||||
const std::vector<uint8_t> mac_context =
|
||||
MakeContext("AUTHENTICATION", request, request_length, 0x200);
|
||||
const std::vector<uint8_t> enc_context =
|
||||
@@ -2498,12 +2507,14 @@ extern "C" OEMCryptoResult OEMCrypto_LoadProvisioning(
|
||||
pair.session, mac_context.data(), mac_context.size(),
|
||||
enc_context.data(), enc_context.size());
|
||||
if (result != OEMCrypto_SUCCESS) return result;
|
||||
|
||||
}
|
||||
if (pair.fcn->LoadProvisioning_V18 != nullptr) {
|
||||
return pair.fcn->LoadProvisioning_V18(
|
||||
pair.session, message, message_length, core_message_length, signature,
|
||||
signature_length, wrapped_private_key, wrapped_private_key_length);
|
||||
} else {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
extern "C" OEMCryptoResult OEMCrypto_LoadProvisioningCast(
|
||||
|
||||
Reference in New Issue
Block a user