From e895e90dadddcdd631419589d2e7a9f7e7361bcb Mon Sep 17 00:00:00 2001 From: Matthew Shyu Date: Wed, 17 Jan 2024 19:38:12 -0800 Subject: [PATCH 2/2] avb: force test key [1/1] PD#SWPL-154626 Problem: For projects that uses test key to boot up but wish to change avb key afterwards. Solution: For test key hash. DANGEROUS: THINK BEFORE YOU MERGE. Verify: Ohm Change-Id: If975bf4f1d6d1b78556e000c2ba952d8d5e554b3 Signed-off-by: Matthew Shyu --- lib/libavb/avb_slot_verify.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/libavb/avb_slot_verify.c b/lib/libavb/avb_slot_verify.c index 4429d4c824d..8790092881f 100644 --- a/lib/libavb/avb_slot_verify.c +++ b/lib/libavb/avb_slot_verify.c @@ -28,6 +28,14 @@ uint8_t boot_key_hash[AVB_SHA256_DIGEST_SIZE]; +#define FORCE_TEST_KEY (1) +uint8_t test_key_hash[AVB_SHA256_DIGEST_SIZE] = { + 0x22, 0xde, 0x39, 0x94, 0x53, 0x21, 0x96, 0xf6, + 0x1c, 0x03, 0x9e, 0x90, 0x26, 0x0d, 0x78, 0xa9, + 0x3a, 0x4c, 0x57, 0x36, 0x2c, 0x7e, 0x78, 0x9b, + 0xe9, 0x28, 0x03, 0x6e, 0x80, 0xb7, 0x7c, 0x8c, +}; + static AvbSlotVerifyResult initialize_persistent_digest( AvbOps* ops, const char* part_name, @@ -746,6 +754,10 @@ static AvbSlotVerifyResult load_and_verify_vbmeta( avb_memcpy(boot_key_hash, avb_sha256_final(&boot_key_sha256_ctx), AVB_SHA256_DIGEST_SIZE); +#if FORCE_TEST_KEY + avb_memcpy(boot_key_hash, test_key_hash, + AVB_SHA256_DIGEST_SIZE); +#endif } } } -- 2.29.0