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:
parent
e84ef14d6d
commit
74b485fb2b
|
|
@ -1742,18 +1742,19 @@ static void cb_flashing(struct usb_ep *ep, struct usb_request *req)
|
||||||
static void cb_oem_perm_attr(void)
|
static void cb_oem_perm_attr(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_RK_AVB_LIBAVB_USER
|
#ifdef CONFIG_RK_AVB_LIBAVB_USER
|
||||||
|
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
|
||||||
sha256_context ctx;
|
sha256_context ctx;
|
||||||
uint8_t digest[SHA256_SUM_LEN] = {0};
|
uint8_t digest[SHA256_SUM_LEN] = {0};
|
||||||
uint8_t digest_temp[SHA256_SUM_LEN] = {0};
|
uint8_t digest_temp[SHA256_SUM_LEN] = {0};
|
||||||
uint8_t perm_attr_temp[PERM_ATTR_TOTAL_SIZE] = {0};
|
uint8_t perm_attr_temp[PERM_ATTR_TOTAL_SIZE] = {0};
|
||||||
uint8_t flag = 0;
|
uint8_t flag = 0;
|
||||||
|
#endif
|
||||||
if (PERM_ATTR_TOTAL_SIZE != download_bytes) {
|
if (PERM_ATTR_TOTAL_SIZE != download_bytes) {
|
||||||
printf("Permanent attribute size is not equal!\n");
|
printf("Permanent attribute size is not equal!\n");
|
||||||
fastboot_tx_write_str("FAILincorrect perm attribute size");
|
fastboot_tx_write_str("FAILincorrect perm attribute size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
|
||||||
if (rk_avb_read_perm_attr_flag(&flag)) {
|
if (rk_avb_read_perm_attr_flag(&flag)) {
|
||||||
printf("rk_avb_read_perm_attr_flag error!\n");
|
printf("rk_avb_read_perm_attr_flag error!\n");
|
||||||
fastboot_tx_write_str("FAILperm attr read failed");
|
fastboot_tx_write_str("FAILperm attr read failed");
|
||||||
|
|
@ -1793,7 +1794,7 @@ static void cb_oem_perm_attr(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (rk_avb_write_permanent_attributes((uint8_t *)
|
if (rk_avb_write_permanent_attributes((uint8_t *)
|
||||||
CONFIG_FASTBOOT_BUF_ADDR,
|
CONFIG_FASTBOOT_BUF_ADDR,
|
||||||
download_bytes)) {
|
download_bytes)) {
|
||||||
|
|
@ -1804,7 +1805,7 @@ static void cb_oem_perm_attr(void)
|
||||||
fastboot_tx_write_str("FAILperm attr write failed");
|
fastboot_tx_write_str("FAILperm attr write failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
|
||||||
memset(digest, 0, SHA256_SUM_LEN);
|
memset(digest, 0, SHA256_SUM_LEN);
|
||||||
sha256_starts(&ctx);
|
sha256_starts(&ctx);
|
||||||
sha256_update(&ctx, (const uint8_t *)CONFIG_FASTBOOT_BUF_ADDR,
|
sha256_update(&ctx, (const uint8_t *)CONFIG_FASTBOOT_BUF_ADDR,
|
||||||
|
|
@ -1829,7 +1830,7 @@ static void cb_oem_perm_attr(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (rk_avb_write_perm_attr_flag(PERM_ATTR_SUCCESS_FLAG)) {
|
if (rk_avb_write_perm_attr_flag(PERM_ATTR_SUCCESS_FLAG)) {
|
||||||
fastboot_tx_write_str("FAILperm attr flag write failure");
|
fastboot_tx_write_str("FAILperm attr flag write failure");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ static bool verify_permanent_attributes(
|
||||||
const AvbAtxPermanentAttributes* attributes,
|
const AvbAtxPermanentAttributes* attributes,
|
||||||
const uint8_t expected_hash[AVB_SHA256_DIGEST_SIZE]) {
|
const uint8_t expected_hash[AVB_SHA256_DIGEST_SIZE]) {
|
||||||
uint8_t 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
|
#ifdef CONFIG_CRYPTO_ROCKCHIP
|
||||||
struct rk_pub_key pub_key;
|
struct rk_pub_key pub_key;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ AvbIOResult avb_read_perm_attr(AvbAtxOps *atx_ops,
|
||||||
AvbIOResult avb_read_perm_attr_hash(AvbAtxOps *atx_ops,
|
AvbIOResult avb_read_perm_attr_hash(AvbAtxOps *atx_ops,
|
||||||
uint8_t hash[AVB_SHA256_DIGEST_SIZE])
|
uint8_t hash[AVB_SHA256_DIGEST_SIZE])
|
||||||
{
|
{
|
||||||
#ifndef ROCKCHIP_USE_PRE_LOADER_PUB_KEY
|
#ifndef CONFIG_ROCKCHIP_PRELOADER_PUB_KEY
|
||||||
#ifdef CONFIG_OPTEE_CLIENT
|
#ifdef CONFIG_OPTEE_CLIENT
|
||||||
if (trusty_read_attribute_hash((uint32_t *)hash,
|
if (trusty_read_attribute_hash((uint32_t *)hash,
|
||||||
AVB_SHA256_DIGEST_SIZE / 4))
|
AVB_SHA256_DIGEST_SIZE / 4))
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,10 @@ config TPL_RK_AVB_LIBAVB_USER
|
||||||
This config support the android things system to
|
This config support the android things system to
|
||||||
read/write hardware image, like vbmeta, misc, and
|
read/write hardware image, like vbmeta, misc, and
|
||||||
so on. And it can provide some a/b and avb information
|
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.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue