xref: /rk3399_ARM-atf/make_helpers/tbbr/tbbr_tools.mk (revision 6c74c9977d12f57b524ab1d8cd78ece9933840be)
173c99d4eSJuan Castillo#
2*6c74c997SPankaj Gupta# Copyright (c) 2015-2021, 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
14d178637dSJuan Castillo#   NEED_BL32: indicates whether BL32 is needed by the platform
1573c99d4eSJuan Castillo#   BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN)
16f59821d5SJuan Castillo#   SCP_BL2: image filename (optional). Default is IMG_BIN(30)
1773c99d4eSJuan Castillo#   BL31: image filename (optional). Default is IMG_BIN(31)
1873c99d4eSJuan Castillo#   BL32: image filename (optional). Default is IMG_BIN(32)
1973c99d4eSJuan Castillo#   BL33: image filename (optional). Default is IMG_BIN(33)
2073c99d4eSJuan Castillo#
2173c99d4eSJuan Castillo# Build options added by this file:
2273c99d4eSJuan Castillo#
2373c99d4eSJuan Castillo#   KEY_ALG
24dfe0f4c2SJustin Chadwell#   KEY_SIZE
2573c99d4eSJuan Castillo#   ROT_KEY
2653b985a0SSandrine Bailleux#   PROT_KEY
2773c99d4eSJuan Castillo#   TRUSTED_WORLD_KEY
2873c99d4eSJuan Castillo#   NON_TRUSTED_WORLD_KEY
29f59821d5SJuan Castillo#   SCP_BL2_KEY
3073c99d4eSJuan Castillo#   BL31_KEY
3173c99d4eSJuan Castillo#   BL32_KEY
3273c99d4eSJuan Castillo#   BL33_KEY
3373c99d4eSJuan Castillo#
3473c99d4eSJuan Castillo
3573c99d4eSJuan Castillo# Certificate generation tool default parameters
36*6c74c997SPankaj GuptaTRUSTED_KEY_CERT	?=	${BUILD_PLAT}/trusted_key.crt
370191262dSYatharth KocharFWU_CERT		:=	${BUILD_PLAT}/fwu_cert.crt
3873c99d4eSJuan Castillo
3996103d5aSJuan Castillo# Default non-volatile counter values (overridable by the platform)
4096103d5aSJuan CastilloTFW_NVCTR_VAL		?=	0
4196103d5aSJuan CastilloNTFW_NVCTR_VAL		?=	0
4296103d5aSJuan Castillo
4396103d5aSJuan Castillo# Pass the non-volatile counters to the cert_create tool
4496103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr))
4596103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${NTFW_NVCTR_VAL},--ntfw-nvctr))
4696103d5aSJuan Castillo
47819281eeSdp-arm# Add Trusted Key certificate to the fiptool and cert_create command line options
4810cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert))
4973c99d4eSJuan Castillo
50819281eeSdp-arm# Add fwu certificate to the fiptool and cert_create command line options
5110cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${FWU_CERT},--fwu-cert,,FWU_))
520191262dSYatharth Kochar
5373c99d4eSJuan Castillo# Add the keys to the cert_create command line options (private keys are NOT
5473c99d4eSJuan Castillo# packed in the FIP). Developers can use their own keys by specifying the proper
5573c99d4eSJuan Castillo# build option in the command line when building the Trusted Firmware
5673c99d4eSJuan Castillo$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg)))
578cdb1693SManish V Badarkhe$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,FWU_)))
58dfe0f4c2SJustin Chadwell$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size)))
598cdb1693SManish V Badarkhe$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,FWU_)))
609a3088a5SQixiang Xu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg)))
618cdb1693SManish V Badarkhe$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,FWU_)))
6273c99d4eSJuan Castillo$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key)))
6391704d9dSMasahiro Yamada$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,FWU_)))
6453b985a0SSandrine Bailleux$(if ${PROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${PROT_KEY},--prot-key)))
6573c99d4eSJuan Castillo$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key)))
6673c99d4eSJuan Castillo$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key)))
6773c99d4eSJuan Castillo
68f30ee0b9SMasahiro Yamada
69f30ee0b9SMasahiro Yamada# Add the BL2 CoT (image cert)
70c9b31ae8SRoberto Vargasifeq (${BL2_AT_EL3}, 0)
7110cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
72c9b31ae8SRoberto Vargasendif
7373c99d4eSJuan Castillo
74f30ee0b9SMasahiro Yamada# Add the SCP_BL2 CoT (key cert + img cert)
75f59821d5SJuan Castilloifneq (${SCP_BL2},)
76f59821d5SJuan Castillo    $(if ${SCP_BL2_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2_KEY},--scp-fw-key)))
7710cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert))
7810cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert))
7973c99d4eSJuan Castilloendif
8073c99d4eSJuan Castillo
81a4409008Sdp-armifeq (${ARCH},aarch64)
825744e874SSoby Mathewifeq (${NEED_BL31},yes)
83f30ee0b9SMasahiro Yamada# Add the BL31 CoT (key cert + img cert)
84516beb58SJuan Castillo$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--soc-fw-key)))
8510cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert))
8610cea934SMasahiro Yamada$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert))
87a4409008Sdp-armendif
885744e874SSoby Mathewendif
8973c99d4eSJuan Castillo
90f30ee0b9SMasahiro Yamada# Add the BL32 CoT (key cert + img cert)
9173c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
92516beb58SJuan Castillo    $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--tos-fw-key)))
9310cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert))
9410cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert))
9573c99d4eSJuan Castilloendif
9673c99d4eSJuan Castillo
97f30ee0b9SMasahiro Yamada# Add the BL33 CoT (key cert + img cert)
9873c99d4eSJuan Castilloifneq (${BL33},)
99516beb58SJuan Castillo    $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--nt-fw-key)))
10010cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert))
10153b985a0SSandrine Bailleuxifneq (${COT},dualroot)
10210cea934SMasahiro Yamada    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert))
10373c99d4eSJuan Castilloendif
10453b985a0SSandrine Bailleuxendif
1050792dd7dSManish Pandey
1060792dd7dSManish Pandey# Add SiP owned Secure Partitions CoT (image cert)
1070792dd7dSManish Pandeyifneq (${SP_LAYOUT_FILE},)
1080792dd7dSManish Pandey    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/sip_sp_content.crt,--sip-sp-cert))
10923d5f03aSManish Pandeyifeq (${COT},dualroot)
11023d5f03aSManish Pandey    $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat_sp_content.crt,--plat-sp-cert))
11123d5f03aSManish Pandeyendif
1120792dd7dSManish Pandeyendif
113