1*91f16700Schasinglulu# 2*91f16700Schasinglulu# Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu# 4*91f16700Schasinglulu# SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu# 6*91f16700Schasinglulu 7*91f16700Schasinglulu# This file defines the keys and certificates that must be created to establish 8*91f16700Schasinglulu# a Chain of Trust following the TBBR document. These definitions include the 9*91f16700Schasinglulu# command line options passed to the cert_create and fiptool commands. 10*91f16700Schasinglulu# 11*91f16700Schasinglulu# Expected environment: 12*91f16700Schasinglulu# 13*91f16700Schasinglulu# BUILD_PLAT: output directory 14*91f16700Schasinglulu# NEED_BL2: indicates whether BL2 is needed by the platform 15*91f16700Schasinglulu# NEED_BL32: indicates whether BL32 is needed by the platform 16*91f16700Schasinglulu# BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN) 17*91f16700Schasinglulu# SCP_BL2: image filename (optional). Default is IMG_BIN(30) 18*91f16700Schasinglulu# BL31: image filename (optional). Default is IMG_BIN(31) 19*91f16700Schasinglulu# BL32: image filename (optional). Default is IMG_BIN(32) 20*91f16700Schasinglulu# BL33: image filename (optional). Default is IMG_BIN(33) 21*91f16700Schasinglulu# 22*91f16700Schasinglulu# Build options added by this file: 23*91f16700Schasinglulu# 24*91f16700Schasinglulu# KEY_ALG 25*91f16700Schasinglulu# KEY_SIZE 26*91f16700Schasinglulu# ROT_KEY 27*91f16700Schasinglulu# PROT_KEY 28*91f16700Schasinglulu# PLAT_KEY 29*91f16700Schasinglulu# SWD_ROT_KEY 30*91f16700Schasinglulu# CORE_SWD_KEY 31*91f16700Schasinglulu# TRUSTED_WORLD_KEY 32*91f16700Schasinglulu# NON_TRUSTED_WORLD_KEY 33*91f16700Schasinglulu# SCP_BL2_KEY 34*91f16700Schasinglulu# BL31_KEY 35*91f16700Schasinglulu# BL32_KEY 36*91f16700Schasinglulu# BL33_KEY 37*91f16700Schasinglulu# 38*91f16700Schasinglulu 39*91f16700Schasinglulu# Certificate generation tool default parameters 40*91f16700SchasingluluTRUSTED_KEY_CERT ?= ${BUILD_PLAT}/trusted_key.crt 41*91f16700SchasingluluFWU_CERT := ${BUILD_PLAT}/fwu_cert.crt 42*91f16700Schasinglulu 43*91f16700Schasinglulu# Default non-volatile counter values (overridable by the platform) 44*91f16700SchasingluluTFW_NVCTR_VAL ?= 0 45*91f16700SchasingluluNTFW_NVCTR_VAL ?= 0 46*91f16700SchasingluluCCAFW_NVCTR_VAL ?= 0 47*91f16700Schasinglulu 48*91f16700Schasinglulu# Pass the non-volatile counters to the cert_create tool 49*91f16700Schasinglulu$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr)) 50*91f16700Schasinglulu$(eval $(call CERT_ADD_CMD_OPT,${NTFW_NVCTR_VAL},--ntfw-nvctr)) 51*91f16700Schasingluluifeq (${COT},cca) 52*91f16700Schasinglulu$(eval $(call CERT_ADD_CMD_OPT,${CCAFW_NVCTR_VAL},--ccafw-nvctr)) 53*91f16700Schasingluluendif 54*91f16700Schasinglulu 55*91f16700Schasinglulu# Add Trusted Key certificate to the fiptool and cert_create command line options 56*91f16700Schasingluluifneq (${COT},cca) 57*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert)) 58*91f16700Schasingluluelse 59*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/cca.crt,--cca-cert)) 60*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/core-swd.crt,--core-swd-cert)) 61*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat-key.crt,--plat-key-cert)) 62*91f16700Schasingluluendif 63*91f16700Schasinglulu 64*91f16700Schasinglulu# Add fwu certificate to the fiptool and cert_create command line options 65*91f16700Schasingluluifneq (${COT},cca) 66*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${FWU_CERT},--fwu-cert,,FWU_)) 67*91f16700Schasingluluendif 68*91f16700Schasinglulu 69*91f16700Schasinglulu# Add the keys to the cert_create command line options (private keys are NOT 70*91f16700Schasinglulu# packed in the FIP). Developers can use their own keys by specifying the proper 71*91f16700Schasinglulu# build option in the command line when building the Trusted Firmware 72*91f16700Schasinglulu$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg))) 73*91f16700Schasinglulu$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,FWU_))) 74*91f16700Schasinglulu$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size))) 75*91f16700Schasinglulu$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,FWU_))) 76*91f16700Schasinglulu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg))) 77*91f16700Schasinglulu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,FWU_))) 78*91f16700Schasinglulu$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key))) 79*91f16700Schasinglulu$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,FWU_))) 80*91f16700Schasinglulu$(if ${PROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${PROT_KEY},--prot-key))) 81*91f16700Schasinglulu$(if ${PLAT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${PLAT_KEY},--plat-key))) 82*91f16700Schasinglulu$(if ${SWD_ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SWD_ROT_KEY},--swd-rot-key))) 83*91f16700Schasinglulu$(if ${CORE_SWD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${CORE_SWD_KEY},--core-swd-key))) 84*91f16700Schasinglulu$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key))) 85*91f16700Schasinglulu$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key))) 86*91f16700Schasinglulu 87*91f16700Schasinglulu 88*91f16700Schasinglulu# Add the BL2 CoT (image cert) 89*91f16700Schasingluluifeq (${NEED_BL2},yes) 90*91f16700Schasingluluifeq (${RESET_TO_BL2}, 0) 91*91f16700Schasingluluifneq (${COT},cca) 92*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert)) 93*91f16700Schasingluluendif 94*91f16700Schasingluluendif 95*91f16700Schasingluluendif 96*91f16700Schasinglulu 97*91f16700Schasinglulu# Add the SCP_BL2 CoT (key cert + img cert) 98*91f16700Schasingluluifneq (${SCP_BL2},) 99*91f16700Schasingluluifneq (${COT},cca) 100*91f16700Schasinglulu $(if ${SCP_BL2_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2_KEY},--scp-fw-key))) 101*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert)) 102*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert)) 103*91f16700Schasingluluendif 104*91f16700Schasingluluendif 105*91f16700Schasinglulu 106*91f16700Schasingluluifeq (${ARCH},aarch64) 107*91f16700Schasingluluifeq (${NEED_BL31},yes) 108*91f16700Schasinglulu# Add the BL31 CoT (key cert + img cert) 109*91f16700Schasinglulu$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--soc-fw-key))) 110*91f16700Schasingluluifneq (${COT},cca) 111*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert)) 112*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert)) 113*91f16700Schasingluluendif 114*91f16700Schasingluluendif 115*91f16700Schasingluluendif 116*91f16700Schasinglulu 117*91f16700Schasinglulu# Add the BL32 CoT (key cert + img cert) 118*91f16700Schasingluluifeq (${NEED_BL32},yes) 119*91f16700Schasinglulu $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--tos-fw-key))) 120*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert)) 121*91f16700Schasingluluifneq (${COT},cca) 122*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert)) 123*91f16700Schasingluluendif 124*91f16700Schasingluluendif 125*91f16700Schasinglulu 126*91f16700Schasinglulu# Add the BL33 CoT (key cert + img cert) 127*91f16700Schasingluluifneq (${BL33},) 128*91f16700Schasinglulu $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--nt-fw-key))) 129*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert)) 130*91f16700Schasingluluifneq (${COT},dualroot) 131*91f16700Schasinglulu ifneq (${COT},cca) 132*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert)) 133*91f16700Schasinglulu endif 134*91f16700Schasingluluendif 135*91f16700Schasingluluendif 136*91f16700Schasinglulu 137*91f16700Schasinglulu# Add SiP owned Secure Partitions CoT (image cert) 138*91f16700Schasingluluifneq (${SP_LAYOUT_FILE},) 139*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/sip_sp_content.crt,--sip-sp-cert)) 140*91f16700Schasingluluifeq (${COT},dualroot) 141*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat_sp_content.crt,--plat-sp-cert)) 142*91f16700Schasingluluendif 143*91f16700Schasingluluifeq (${COT},cca) 144*91f16700Schasinglulu $(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/plat_sp_content.crt,--plat-sp-cert)) 145*91f16700Schasingluluendif 146*91f16700Schasingluluendif 147