xref: /rk3399_ARM-atf/make_helpers/tbbr/tbbr_tools.mk (revision 982ee634e7c4decd941b2fe97d85181b5615797a)
173c99d4eSJuan Castillo#
2*d57362bdSXialin Liu# Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved.
373c99d4eSJuan Castillo#
482cb2c1aSdp-arm# SPDX-License-Identifier: BSD-3-Clause
573c99d4eSJuan Castillo#
673c99d4eSJuan Castillo
773c99d4eSJuan Castillo# This file defines the keys and certificates that must be created to establish
873c99d4eSJuan Castillo# a Chain of Trust following the TBBR document. These definitions include the
9819281eeSdp-arm# command line options passed to the cert_create and fiptool commands.
1073c99d4eSJuan Castillo#
1173c99d4eSJuan Castillo# Expected environment:
1273c99d4eSJuan Castillo#
1373c99d4eSJuan Castillo#   BUILD_PLAT: output directory
1408c699e7SManish Pandey#   NEED_BL2: indicates whether BL2 is needed by the platform
15d178637dSJuan Castillo#   NEED_BL32: indicates whether BL32 is needed by the platform
1673c99d4eSJuan Castillo#   BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN)
17f59821d5SJuan Castillo#   SCP_BL2: image filename (optional). Default is IMG_BIN(30)
1873c99d4eSJuan Castillo#   BL31: image filename (optional). Default is IMG_BIN(31)
1973c99d4eSJuan Castillo#   BL32: image filename (optional). Default is IMG_BIN(32)
2073c99d4eSJuan Castillo#   BL33: image filename (optional). Default is IMG_BIN(33)
2173c99d4eSJuan Castillo#
2273c99d4eSJuan Castillo# Build options added by this file:
2373c99d4eSJuan Castillo#
2473c99d4eSJuan Castillo#   KEY_ALG
25dfe0f4c2SJustin Chadwell#   KEY_SIZE
2673c99d4eSJuan Castillo#   ROT_KEY
2753b985a0SSandrine Bailleux#   PROT_KEY
281b7d656aSlaurenw-arm#   PLAT_KEY
291b7d656aSlaurenw-arm#   SWD_ROT_KEY
301b7d656aSlaurenw-arm#   CORE_SWD_KEY
3173c99d4eSJuan Castillo#   TRUSTED_WORLD_KEY
3273c99d4eSJuan Castillo#   NON_TRUSTED_WORLD_KEY
33f59821d5SJuan Castillo#   SCP_BL2_KEY
3473c99d4eSJuan Castillo#   BL31_KEY
3573c99d4eSJuan Castillo#   BL32_KEY
3673c99d4eSJuan Castillo#   BL33_KEY
3773c99d4eSJuan Castillo#
3873c99d4eSJuan Castillo
3973c99d4eSJuan Castillo# Certificate generation tool default parameters
406c74c997SPankaj GuptaTRUSTED_KEY_CERT	?=	${BUILD_PLAT}/trusted_key.crt
410191262dSYatharth KocharFWU_CERT		:=	${BUILD_PLAT}/fwu_cert.crt
4273c99d4eSJuan Castillo
4396103d5aSJuan Castillo# Default non-volatile counter values (overridable by the platform)
4496103d5aSJuan CastilloTFW_NVCTR_VAL		?=	0
4596103d5aSJuan CastilloNTFW_NVCTR_VAL		?=	0
460f19b7aaSlaurenw-armCCAFW_NVCTR_VAL		?=	0
4796103d5aSJuan Castillo
4896103d5aSJuan Castillo# Pass the non-volatile counters to the cert_create tool
4996103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr))
50*d57362bdSXialin Liu$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr, BL2_))
5196103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${NTFW_NVCTR_VAL},--ntfw-nvctr))
520f19b7aaSlaurenw-armifeq (${COT},cca)
530f19b7aaSlaurenw-arm$(eval $(call CERT_ADD_CMD_OPT,${CCAFW_NVCTR_VAL},--ccafw-nvctr))
540f19b7aaSlaurenw-armendif
5596103d5aSJuan Castillo
56819281eeSdp-arm# Add Trusted Key certificate to the fiptool and cert_create command line options
571b7d656aSlaurenw-armifneq (${COT},cca)
5810cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert))
591b7d656aSlaurenw-armelse
601b7d656aSlaurenw-arm$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/cca.crt,--cca-cert))
611b7d656aSlaurenw-arm$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/core-swd.crt,--core-swd-cert))
621b7d656aSlaurenw-arm$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat-key.crt,--plat-key-cert))
631b7d656aSlaurenw-armendif
6473c99d4eSJuan Castillo
65819281eeSdp-arm# Add fwu certificate to the fiptool and cert_create command line options
661b7d656aSlaurenw-armifneq (${COT},cca)
6710cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${FWU_CERT},--fwu-cert,,FWU_))
681b7d656aSlaurenw-armendif
690191262dSYatharth Kochar
7073c99d4eSJuan Castillo# Add the keys to the cert_create command line options (private keys are NOT
7173c99d4eSJuan Castillo# packed in the FIP). Developers can use their own keys by specifying the proper
7273c99d4eSJuan Castillo# build option in the command line when building the Trusted Firmware
7373c99d4eSJuan Castillo$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg)))
748cdb1693SManish V Badarkhe$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,FWU_)))
75*d57362bdSXialin Liu$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,BL2_)))
76dfe0f4c2SJustin Chadwell$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size)))
778cdb1693SManish V Badarkhe$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,FWU_)))
78*d57362bdSXialin Liu$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,BL2_)))
799a3088a5SQixiang Xu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg)))
808cdb1693SManish V Badarkhe$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,FWU_)))
81*d57362bdSXialin Liu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,BL2_)))
8273c99d4eSJuan Castillo$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key)))
8391704d9dSMasahiro Yamada$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,FWU_)))
84*d57362bdSXialin Liu$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,BL2_)))
8553b985a0SSandrine Bailleux$(if ${PROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${PROT_KEY},--prot-key)))
861b7d656aSlaurenw-arm$(if ${PLAT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${PLAT_KEY},--plat-key)))
871b7d656aSlaurenw-arm$(if ${SWD_ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SWD_ROT_KEY},--swd-rot-key)))
881b7d656aSlaurenw-arm$(if ${CORE_SWD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${CORE_SWD_KEY},--core-swd-key)))
8973c99d4eSJuan Castillo$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key)))
9073c99d4eSJuan Castillo$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key)))
9173c99d4eSJuan Castillo
92f30ee0b9SMasahiro Yamada
93f30ee0b9SMasahiro Yamada# Add the BL2 CoT (image cert)
9408c699e7SManish Pandeyifeq (${NEED_BL2},yes)
9542d4d3baSArvind Ram Prakashifeq (${RESET_TO_BL2}, 0)
961b7d656aSlaurenw-armifneq (${COT},cca)
97*d57362bdSXialin Liuifeq (${SEPARATE_BL2_FIP},1)
98*d57362bdSXialin Liu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert,,BL2_))
99*d57362bdSXialin Liuendif
10010cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
101c9b31ae8SRoberto Vargasendif
102e31fb0faSlaurenw-armendif
1031b7d656aSlaurenw-armendif
10473c99d4eSJuan Castillo
105f30ee0b9SMasahiro Yamada# Add the SCP_BL2 CoT (key cert + img cert)
106f59821d5SJuan Castilloifneq (${SCP_BL2},)
1071b7d656aSlaurenw-armifneq (${COT},cca)
108f59821d5SJuan Castillo    $(if ${SCP_BL2_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2_KEY},--scp-fw-key)))
10910cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert))
11010cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert))
11173c99d4eSJuan Castilloendif
1121b7d656aSlaurenw-armendif
11373c99d4eSJuan Castillo
114a4409008Sdp-armifeq (${ARCH},aarch64)
1155744e874SSoby Mathewifeq (${NEED_BL31},yes)
116f30ee0b9SMasahiro Yamada# Add the BL31 CoT (key cert + img cert)
117516beb58SJuan Castillo$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--soc-fw-key)))
1181b7d656aSlaurenw-armifneq (${COT},cca)
11910cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert))
12010cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert))
121a4409008Sdp-armendif
1225744e874SSoby Mathewendif
1231b7d656aSlaurenw-armendif
12473c99d4eSJuan Castillo
125f30ee0b9SMasahiro Yamada# Add the BL32 CoT (key cert + img cert)
12673c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
127516beb58SJuan Castillo    $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--tos-fw-key)))
12810cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert))
129f1cb5bd1SManish V Badarkheifneq (${COT},cca)
13010cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert))
13173c99d4eSJuan Castilloendif
132f1cb5bd1SManish V Badarkheendif
13373c99d4eSJuan Castillo
134f30ee0b9SMasahiro Yamada# Add the BL33 CoT (key cert + img cert)
13573c99d4eSJuan Castilloifneq (${BL33},)
136516beb58SJuan Castillo    $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--nt-fw-key)))
13710cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert))
13853b985a0SSandrine Bailleuxifneq (${COT},dualroot)
1391b7d656aSlaurenw-arm    ifneq (${COT},cca)
14010cea934SMasahiro Yamada        $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert))
14173c99d4eSJuan Castillo    endif
14253b985a0SSandrine Bailleuxendif
1431b7d656aSlaurenw-armendif
1440792dd7dSManish Pandey
1450792dd7dSManish Pandey# Add SiP owned Secure Partitions CoT (image cert)
1460792dd7dSManish Pandeyifneq (${SP_LAYOUT_FILE},)
1470792dd7dSManish Pandey    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/sip_sp_content.crt,--sip-sp-cert))
14823d5f03aSManish Pandeyifeq (${COT},dualroot)
14923d5f03aSManish Pandey    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat_sp_content.crt,--plat-sp-cert))
15023d5f03aSManish Pandeyendif
1511b7d656aSlaurenw-armifeq (${COT},cca)
1521b7d656aSlaurenw-arm    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat_sp_content.crt,--plat-sp-cert))
1531b7d656aSlaurenw-armendif
1540792dd7dSManish Pandeyendif
155