fastboot: delete write perm-attr hash if use pre-loader pub_key

Since we use the pre-loader public key to verify permanent attribute, then
we do not need to write permanent attribute hash to otp & efuse.

Change-Id: Ic5e19fed2fc9405ab5bc7504dd930fd5f02d847c
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
This commit is contained in:
Jason Zhu 2019-01-23 16:43:43 +08:00 committed by Jianhong Chen
parent e84ef14d6d
commit 74b485fb2b
4 changed files with 15 additions and 7 deletions

View File

@ -1742,18 +1742,19 @@ static void cb_flashing(struct usb_ep *ep, struct usb_request *req)
static void cb_oem_perm_attr(void)
{
#ifdef CONFIG_RK_AVB_LIBAVB_USER
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
sha256_context ctx;
uint8_t digest[SHA256_SUM_LEN] = {0};
uint8_t digest_temp[SHA256_SUM_LEN] = {0};
uint8_t perm_attr_temp[PERM_ATTR_TOTAL_SIZE] = {0};
uint8_t flag = 0;
#endif
if (PERM_ATTR_TOTAL_SIZE != download_bytes) {
printf("Permanent attribute size is not equal!\n");
fastboot_tx_write_str("FAILincorrect perm attribute size");
return;
}
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
if (rk_avb_read_perm_attr_flag(&flag)) {
printf("rk_avb_read_perm_attr_flag error!\n");
fastboot_tx_write_str("FAILperm attr read failed");
@ -1793,7 +1794,7 @@ static void cb_oem_perm_attr(void)
return;
}
}
#endif
if (rk_avb_write_permanent_attributes((uint8_t *)
CONFIG_FASTBOOT_BUF_ADDR,
download_bytes)) {
@ -1804,7 +1805,7 @@ static void cb_oem_perm_attr(void)
fastboot_tx_write_str("FAILperm attr write failed");
return;
}
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
memset(digest, 0, SHA256_SUM_LEN);
sha256_starts(&ctx);
sha256_update(&ctx, (const uint8_t *)CONFIG_FASTBOOT_BUF_ADDR,
@ -1829,7 +1830,7 @@ static void cb_oem_perm_attr(void)
return;
}
}
#endif
if (rk_avb_write_perm_attr_flag(PERM_ATTR_SUCCESS_FLAG)) {
fastboot_tx_write_str("FAILperm attr flag write failure");
return;

View File

@ -71,7 +71,7 @@ static bool verify_permanent_attributes(
const AvbAtxPermanentAttributes* attributes,
const uint8_t expected_hash[AVB_SHA256_DIGEST_SIZE]) {
uint8_t hash[AVB_SHA256_DIGEST_SIZE];
#ifdef ROCKCHIP_USE_PRE_LOADER_PUB_KEY
#ifdef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
#ifdef CONFIG_CRYPTO_ROCKCHIP
struct rk_pub_key pub_key;
int i;

View File

@ -354,7 +354,7 @@ AvbIOResult avb_read_perm_attr(AvbAtxOps *atx_ops,
AvbIOResult avb_read_perm_attr_hash(AvbAtxOps *atx_ops,
uint8_t hash[AVB_SHA256_DIGEST_SIZE])
{
#ifndef ROCKCHIP_USE_PRE_LOADER_PUB_KEY
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
#ifdef CONFIG_OPTEE_CLIENT
if (trusty_read_attribute_hash((uint32_t *)hash,
AVB_SHA256_DIGEST_SIZE / 4))

View File

@ -20,3 +20,10 @@ config TPL_RK_AVB_LIBAVB_USER
This config support the android things system to
read/write hardware image, like vbmeta, misc, and
so on. And it can provide some a/b and avb information
config ROCKCHIP_PRELOADER_PUB_KEY
bool "Rockchip AVB use pre-loader public key"
depends on AVB_LIBAVB_USER
select CRYPTO_ROCKCHIP
help
Use pre-loader public key to decode in avb.