Skip CSR generation for AVF RKP HAL when it is not supported

Test: Run `adb shell rkp_factory_extraction_tool
--output_format build+csr` on a device AVF RKP HAL is unsupported

Change-Id: I8f1ffa63710be6f566fb6f0800c45f3cfb907d69
This commit is contained in:
Alice Wang 2024-06-07 12:41:22 +00:00
parent a8fc566120
commit 16e3442965
3 changed files with 23 additions and 0 deletions

View file

@ -267,3 +267,17 @@ CborResult<Array> getCsr(std::string_view componentName, IRemotelyProvisionedCom
return getCsrV3(componentName, irpc, selfTest);
}
}
bool isRemoteProvisioningSupported(IRemotelyProvisionedComponent* irpc) {
RpcHardwareInfo hwInfo;
auto status = irpc->getHardwareInfo(&hwInfo);
if (status.isOk()) {
return true;
}
if (status.getExceptionCode() == EX_UNSUPPORTED_OPERATION) {
return false;
}
std::cerr << "Unexpected error when getting hardware info. Description: "
<< status.getDescription() << "." << std::endl;
exit(-1);
}

View file

@ -53,3 +53,7 @@ getCsr(std::string_view componentName,
void selfTestGetCsr(
std::string_view componentName,
aidl::android::hardware::security::keymint::IRemotelyProvisionedComponent* irpc);
// Returns true if the given IRemotelyProvisionedComponent supports remote provisioning.
bool isRemoteProvisioningSupported(
aidl::android::hardware::security::keymint::IRemotelyProvisionedComponent* irpc);

View file

@ -78,6 +78,11 @@ void writeOutput(const std::string instance_name, const Array& csr) {
}
void getCsrForIRpc(const char* descriptor, const char* name, IRemotelyProvisionedComponent* irpc) {
// AVF RKP HAL is not always supported, so we need to check if it is supported before
// generating the CSR.
if (std::string(name) == "avf" && !isRemoteProvisioningSupported(irpc)) {
return;
}
auto [request, errMsg] = getCsr(name, irpc, FLAGS_self_test);
auto fullName = getFullServiceName(descriptor, name);
if (!request) {