Factory BCC extraction tool to consume verified device info

BCC extraction tool calls OEMCrypto_GetDeviceInformation() to read
verified device info from TEE. If the verified device info is not
available, (e.g. not implemented), it falls back to using OS properties.

This CL is mostly identical to ag/20799640, which has the same change
for our internal extraction tool. For historical reason, we keep two
copies of the extraction tool which are slightly different from each
other, one for factory use, one for debug use. Long term they will be
merged.

Test: Ran the tool on Pixel 7 w/wo verified device info being present
Bug: 263312447
Change-Id: Ib9c77dee45e9ff996fc2dc2da14f16f60eaff77c
This commit is contained in:
Cong Lin
2022-12-20 20:07:10 -08:00
parent ead412cc55
commit 691f43cbef
5 changed files with 143 additions and 31 deletions

View File

@@ -21,6 +21,8 @@
LOGE("%s", dlerror()); \
return false; \
}
#define LOAD_SYM_IF_EXIST(name) \
name = reinterpret_cast<name##_t>(LOOKUP(handle_, OEMCrypto_##name));
// These are implementations required by OEMCrypto Reference Implementation
// and/or the Testbed, but not needed in this package.
@@ -78,6 +80,7 @@ bool OEMCryptoInterface::Init(const std::string& oemcrypto_path) {
LOAD_SYM(Terminate);
LOAD_SYM(GetBootCertificateChain);
LOAD_SYM(BuildInformation);
LOAD_SYM_IF_EXIST(GetDeviceInformation);
OEMCryptoResult status = Initialize();
if (status != OEMCrypto_SUCCESS) {
@@ -141,4 +144,37 @@ OEMCryptoResult OEMCryptoInterface::GetOEMCryptoBuildInfo(
return result;
}
OEMCryptoResult OEMCryptoInterface::GetVerifiedDeviceInformation(
VerifiedDeviceInfo& verified_device_info) {
if (handle_ == nullptr) {
return OEMCrypto_ERROR_INIT_FAILED;
}
if (GetDeviceInformation == nullptr) {
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
}
verified_device_info.device_info.resize(0);
size_t device_info_size = 0;
verified_device_info.signed_csr_payload.resize(0);
size_t signed_csr_payload_size = 0;
OEMCryptoResult result = GetDeviceInformation(
verified_device_info.device_info.data(), &device_info_size,
verified_device_info.signed_csr_payload.data(), &signed_csr_payload_size);
LOGI("GetVerifiedDeviceInformation first attempt result %d", result);
if (result == OEMCrypto_ERROR_SHORT_BUFFER) {
verified_device_info.device_info.resize(device_info_size);
verified_device_info.signed_csr_payload.resize(signed_csr_payload_size);
result = GetDeviceInformation(
verified_device_info.device_info.data(), &device_info_size,
verified_device_info.signed_csr_payload.data(),
&signed_csr_payload_size);
verified_device_info.device_info.resize(device_info_size);
verified_device_info.signed_csr_payload.resize(signed_csr_payload_size);
LOGI("GetVerifiedDeviceInformation second attempt result %d", result);
}
return result;
}
} // namespace widevine