TI AM62X Secure Boot 流程简述

By Toradex秦海

1). 简介

嵌入式设备对于网络安全的要求越来越高,而 Secure boot就是其中重要的一部分。 TI AM62X 处理器基于行业标准 X.509 认证来提供 Secure boot 启动过程中的 Chain of Trust; X.509 认证是基于公共密钥加密 (Public Key Cryptography) 和数字签名 (Digital Signature) 技术来实现 Secure boot 的。AM62X 处理器涉及 Security 的架构框图如下。

TI AM62X Secure Boot 流程简述305.png

AM62X 处理器启动流程图参考如下。本文就基于 TI AM625 处理器平台简单介绍其 Secure Boot 的部署流程。

TI AM62X Secure Boot 流程简述372.png

本文所演示的平台来自于 Toradex Verdin AM62 嵌入式平台,主要介绍基本的 Chain of Trust,也就是 U-boot和Linux Kernel/DTB 两个层级的加密和验证启动,后面 Rootfs 以及 Application 层面暂不涉及。

2. 准备

a). Verdin AM62 ARM核心版配合Dahlia 载板,并连接调试串口用于测试。

b). 参考这里下载 Toradex Yocto Linux BSP6 Reference Image 用于后续测试,目前最新的是 6.7.0 版本。

3). 生成 Customer Key Set 文件

a). TI AM62 处理器有如下三种设备类型,其中 GP (General Purpose) 类型的处理器是不具备支持 Secure Boot 功能的,只有 HS (High Security) 类型的处理器是支持的,然后其还细分为两个状态,HS-FS (Field Securable) 和 HS-SE (Security Enforced),具体的说明请见如下。TI AM62X HS 类型处理器出厂配置为 HS-FS 状态,且都已经预先写入了 TI Dummy Key 在设备中。

TI AM62X Secure Boot 流程简述1252.png

b). 由于将 HS 设备从 HS-FS 状态配置为 HS-SE 状态是不可逆的,因此本文为了方便演示流程仅仅使用 TI 预置的 Dummy Key 在 HS-FS 状态下进行 Signed Image Authentication 流程演示,但会将 Customer key 的生成和烧录流程进行说明。

TI AM62X Secure Boot 流程简述1408.png

c). 通过下面命令生成 Customer Root Key Set (SMPK) 和 Customer Back-up Key Set (BMPK)文件,用于后续的 Boot Image 签名以及烧录 Image 生成。

--------------------------------

### key name should not be changed ###

$ export Customer_KEYS_DIR=<DIR to store keys>

$ export SMPK_NAME=custMpk

$ export BMPK_NAME=backMpk

### Create the SMPK key pair and certificate using RSA 4096 ###

$ cd $Customer_KEYS_DIR

$ openssl genrsa -F4 -out ${SMPK_NAME}.key 4096

$ cp ${SMPK_NAME}.key ${SMPK_NAME}.pem

$ openssl req -batch -new -x509 -key ${SMPK_NAME}.key -out ${SMPK_NAME}.crt

### Create the BMPK key pair and certificate using RSA 4096 ###

$ openssl genrsa -F4 -out ${BMPK_NAME}.key 4096

$ cp ${BMPK_NAME}.key ${BMPK_NAME}.pem

$ openssl req -batch -new -x509 -key ${BMPK_NAME}.key -out ${BMPK_NAME}.crt

### Remove write access to the keys and certificates ###

$ chmod a-w *

--------------------------------

 

 

4). Boot Image 编译和签名

a). 参考这里说明下载 Toradex Yocto Linux BSP 6.x.y 版本包含 U-boot在内的编译 Boot Images 所需要的全部源代码

--------------------------------

### Get the U-Boot source code for Yocto Linux BSP 6.x.y ###

$ git clone -b toradex_ti-u-boot-2023.04 https://git.toradex.cn/u-boot-toradex.git

$ export UBOOT_DIR=$(pwd)/u-boot-toradex

### Get the binary-only System Firmware (SYSFW) ###

$ git clone git://git.ti.com/k3-image-gen/k3-image-gen.git

$ export K3_DIR=$(pwd)/k3-image-gen

### Get the TI Linux Firmware ###

$ git clone -b ti-linux-firmware git://git.ti.com/processor-firmware/ti-linux-firmware.git

$ export TI_LINUX_FW_DIR=$(pwd)/ti-linux-firmware

### Get the ARM Trusted Firmware (ATF/TF-A) ###

$ git clone https://github.com/ARM-software/arm-trusted-firmware.git

$ export TFA_DIR=$(pwd)/arm-trusted-firmware

### Get the OP-TEE image source code ###

$ git clone https://github.com/OP-TEE/optee_os.git

$ export OPTEE_DIR=$(pwd)/optee_os

### Get the K3 Security development package:###

$ git clone https://git.ti.com/git/security-development-tools/core-secdev-k3.git -b master

$ export CORE_SECDEV_K3_DIR=$(pwd)/core-secdev-k3

--------------------------------

b). Customer Key Set 需要部署在 K3 Security development package 和 U-Boot source code 如下位置,默认部署的是 TI Dummy Key,本文因为都是基于 TI Dummy Key 进行测试,因此不做替换修改。

./ K3 Security development package

--------------------------------

$ cd $CORE_SECDEV_K3_DIR/keys

$ ls

custMpk.crt  custMpk.key  custMpk.pem  swrv.txt  ti-degenerate-key.pem

$ md5sum custMpk.key

bd90ee9fe69667315eeee32bc7a01b39  custMpk.key

$ md5sum custMpk.pem

bd90ee9fe69667315eeee32bc7a01b39  custMpk.pem

$ md5sum custMpk.crt

f2a1562c002fc38319bf82471b0661a3  custMpk.crt

### replace TI Dummy Key with Customer Key if needed ###

$ cp $Customer_KEYS_DIR/* $CORE_SECDEV_K3_DIR/keys

--------------------------------

./ U-Boot source code

--------------------------------

$ cd $UBOOT_DIR/board/ti/keys/

$ ls

custMpk.crt  custMpk.key  custMpk.pem  swrv.txt  ti-degenerate-key.pem

$ md5sum custMpk.key

bd90ee9fe69667315eeee32bc7a01b39  custMpk.key

$ md5sum custMpk.pem

bd90ee9fe69667315eeee32bc7a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值