MA-18914 Don't load key from RPMB in hard-code case
authorJi Luo <ji.luo@nxp.com>
Tue, 13 Apr 2021 06:18:24 +0000 (14:18 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:19 +0000 (09:49 +0800)
Use hard-code public key instead of reading it from RPMB
When "CONFIG_LOAD_KEY_FROM_RPMB" is setting to "n".

Test: Boots on imx8mp.

Change-Id: I701777a0cfe3790a4e38f2cbe858e1fbddc2552a
Signed-off-by: Ji Luo <ji.luo@nxp.com>
Reviewed-by: Wang Haoran <elven.wang@nxp.com>
(cherry picked from commit 740eaa338b656b20611affb22572fe0a2253161d)

drivers/fastboot/fb_fsl/fb_fsl_boot.c
lib/avb/fsl/fsl_public_key.h

index 500d6f0..949a53b 100644 (file)
 #include "u-boot/sha256.h"
 #include <trusty/libtipc.h>
 #include <trusty/hwcrypto.h>
+
+#ifndef CONFIG_LOAD_KEY_FROM_RPMB
+#include "../lib/avb/fsl/fsl_public_key.h"
+#endif
+
 #endif
 
 #include "fb_fsl_common.h"
@@ -451,11 +456,15 @@ int trusty_setbootparameter(uint32_t os_version,
        }
 #else
        uint8_t public_key_buf[AVB_MAX_BUFFER_LENGTH];
+#ifdef CONFIG_LOAD_KEY_FROM_RPMB
        if (trusty_read_vbmeta_public_key(public_key_buf,
                                                AVB_MAX_BUFFER_LENGTH) != 0) {
                printf("ERROR - failed to read public key for keymaster\n");
                memset(boot_key_hash, '\0', AVB_SHA256_DIGEST_SIZE);
        } else
+#else
+       memcpy(public_key_buf, fsl_public_key, AVB_SHA256_DIGEST_SIZE);
+#endif
                sha256_csum_wd((unsigned char *)public_key_buf, AVB_SHA256_DIGEST_SIZE,
                                (unsigned char *)boot_key_hash, CHUNKSZ_SHA256);
 #endif
index f590cdb..b3b6d65 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef __FSL_PUBLIC_KEY_H_
 #define __FSL_PUBLIC_KEY_H_
 /*This public key is generated from testkey_rsa4096.pem.*/
-unsigned char fsl_public_key[] = {
+static unsigned char fsl_public_key[] = {
        0x00,0x00,0x10,0x00,0x55,0xd9,0x04,0xad,
        0xd8,0x04,0xaf,0xe3,0xd3,0x84,0x6c,0x7e,
        0x0d,0x89,0x3d,0xc2,0x8c,0xd3,0x12,0x55,