173c99d4eSJuan Castillo# 273c99d4eSJuan Castillo# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 373c99d4eSJuan Castillo# 473c99d4eSJuan Castillo# Redistribution and use in source and binary forms, with or without 573c99d4eSJuan Castillo# modification, are permitted provided that the following conditions are met: 673c99d4eSJuan Castillo# 773c99d4eSJuan Castillo# Redistributions of source code must retain the above copyright notice, this 873c99d4eSJuan Castillo# list of conditions and the following disclaimer. 973c99d4eSJuan Castillo# 1073c99d4eSJuan Castillo# Redistributions in binary form must reproduce the above copyright notice, 1173c99d4eSJuan Castillo# this list of conditions and the following disclaimer in the documentation 1273c99d4eSJuan Castillo# and/or other materials provided with the distribution. 1373c99d4eSJuan Castillo# 1473c99d4eSJuan Castillo# Neither the name of ARM nor the names of its contributors may be used 1573c99d4eSJuan Castillo# to endorse or promote products derived from this software without specific 1673c99d4eSJuan Castillo# prior written permission. 1773c99d4eSJuan Castillo# 1873c99d4eSJuan Castillo# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1973c99d4eSJuan Castillo# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2073c99d4eSJuan Castillo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2173c99d4eSJuan Castillo# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2273c99d4eSJuan Castillo# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2373c99d4eSJuan Castillo# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2473c99d4eSJuan Castillo# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2573c99d4eSJuan Castillo# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2673c99d4eSJuan Castillo# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2773c99d4eSJuan Castillo# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2873c99d4eSJuan Castillo# POSSIBILITY OF SUCH DAMAGE. 2973c99d4eSJuan Castillo# 3073c99d4eSJuan Castillo 3173c99d4eSJuan Castillo# This file defines the keys and certificates that must be created to establish 3273c99d4eSJuan Castillo# a Chain of Trust following the TBBR document. These definitions include the 3373c99d4eSJuan Castillo# command line options passed to the cert_create and fip_create tools. 3473c99d4eSJuan Castillo# 3573c99d4eSJuan Castillo# Expected environment: 3673c99d4eSJuan Castillo# 3773c99d4eSJuan Castillo# BUILD_PLAT: output directory 38d178637dSJuan Castillo# NEED_BL32: indicates whether BL32 is needed by the platform 3973c99d4eSJuan Castillo# BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN) 40f59821d5SJuan Castillo# SCP_BL2: image filename (optional). Default is IMG_BIN(30) 4173c99d4eSJuan Castillo# BL31: image filename (optional). Default is IMG_BIN(31) 4273c99d4eSJuan Castillo# BL32: image filename (optional). Default is IMG_BIN(32) 4373c99d4eSJuan Castillo# BL33: image filename (optional). Default is IMG_BIN(33) 4473c99d4eSJuan Castillo# 4573c99d4eSJuan Castillo# Build options added by this file: 4673c99d4eSJuan Castillo# 4773c99d4eSJuan Castillo# KEY_ALG 4873c99d4eSJuan Castillo# ROT_KEY 4973c99d4eSJuan Castillo# TRUSTED_WORLD_KEY 5073c99d4eSJuan Castillo# NON_TRUSTED_WORLD_KEY 51f59821d5SJuan Castillo# SCP_BL2_KEY 5273c99d4eSJuan Castillo# BL31_KEY 5373c99d4eSJuan Castillo# BL32_KEY 5473c99d4eSJuan Castillo# BL33_KEY 5573c99d4eSJuan Castillo# 5673c99d4eSJuan Castillo 5773c99d4eSJuan Castillo# Certificate generation tool default parameters 5873c99d4eSJuan CastilloTRUSTED_KEY_CERT := ${BUILD_PLAT}/trusted_key.crt 590191262dSYatharth KocharFWU_CERT := ${BUILD_PLAT}/fwu_cert.crt 6073c99d4eSJuan Castillo 61*96103d5aSJuan Castillo# Default non-volatile counter values (overridable by the platform) 62*96103d5aSJuan CastilloTFW_NVCTR_VAL ?= 0 63*96103d5aSJuan CastilloNTFW_NVCTR_VAL ?= 0 64*96103d5aSJuan Castillo 65*96103d5aSJuan Castillo# Pass the non-volatile counters to the cert_create tool 66*96103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr)) 67*96103d5aSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${NTFW_NVCTR_VAL},--ntfw-nvctr)) 68*96103d5aSJuan Castillo 6973c99d4eSJuan Castillo# Add Trusted Key certificate to the fip_create and cert_create command line options 7073c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert)) 7173c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_KEY_CERT},--trusted-key-cert)) 7273c99d4eSJuan Castillo 730191262dSYatharth Kochar# Add fwu certificate to the fip_create and cert_create command line options 740191262dSYatharth Kochar$(eval $(call FWU_FIP_ADD_PAYLOAD,${FWU_CERT},--fwu-cert)) 750191262dSYatharth Kochar$(eval $(call FWU_CERT_ADD_CMD_OPT,${FWU_CERT},--fwu-cert)) 760191262dSYatharth Kochar 7773c99d4eSJuan Castillo# Add the keys to the cert_create command line options (private keys are NOT 7873c99d4eSJuan Castillo# packed in the FIP). Developers can use their own keys by specifying the proper 7973c99d4eSJuan Castillo# build option in the command line when building the Trusted Firmware 8073c99d4eSJuan Castillo$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg))) 8173c99d4eSJuan Castillo$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key))) 820191262dSYatharth Kochar$(if ${ROT_KEY},$(eval $(call FWU_CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key))) 8373c99d4eSJuan Castillo$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key))) 8473c99d4eSJuan Castillo$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key))) 8573c99d4eSJuan Castillo 8673c99d4eSJuan Castillo# Add the BL2 CoT (image cert + image) 87516beb58SJuan Castillo$(if ${BL2},$(eval $(call CERT_ADD_CMD_OPT,${BL2},--tb-fw,true)),\ 88516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,2),--tb-fw,true))) 89516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert)) 90516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert)) 9173c99d4eSJuan Castillo 92f59821d5SJuan Castillo# Add the SCP_BL2 CoT (key cert + img cert + image) 93f59821d5SJuan Castilloifneq (${SCP_BL2},) 94f59821d5SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2},--scp-fw,true)) 95f59821d5SJuan Castillo $(if ${SCP_BL2_KEY},$(eval $(call CERT_ADD_CMD_OPT,${SCP_BL2_KEY},--scp-fw-key))) 96516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert)) 97516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert)) 98516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_content.crt,--scp-fw-cert)) 99516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/scp_fw_key.crt,--scp-fw-key-cert)) 10073c99d4eSJuan Castilloendif 10173c99d4eSJuan Castillo 10273c99d4eSJuan Castillo# Add the BL31 CoT (key cert + img cert + image) 103516beb58SJuan Castillo$(if ${BL31},$(eval $(call CERT_ADD_CMD_OPT,${BL31},--soc-fw,true)),\ 104516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,31),--soc-fw,true))) 105516beb58SJuan Castillo$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--soc-fw-key))) 106516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert)) 107516beb58SJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert)) 108516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_content.crt,--soc-fw-cert)) 109516beb58SJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/soc_fw_key.crt,--soc-fw-key-cert)) 11073c99d4eSJuan Castillo 11173c99d4eSJuan Castillo# Add the BL32 CoT (key cert + img cert + image) 11273c99d4eSJuan Castilloifeq (${NEED_BL32},yes) 113516beb58SJuan Castillo $(if ${BL32},$(eval $(call CERT_ADD_CMD_OPT,${BL32},--tos-fw,true)),\ 114516beb58SJuan Castillo $(if ${BL32_SOURCES},$(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,32),--tos-fw,true)))) 115516beb58SJuan Castillo $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--tos-fw-key))) 116516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert)) 117516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert)) 118516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_content.crt,--tos-fw-cert)) 119516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tos_fw_key.crt,--tos-fw-key-cert)) 12073c99d4eSJuan Castilloendif 12173c99d4eSJuan Castillo 12273c99d4eSJuan Castillo# Add the BL33 CoT (key cert + img cert + image) 12373c99d4eSJuan Castilloifneq (${BL33},) 124516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BL33},--nt-fw,true)) 125516beb58SJuan Castillo $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--nt-fw-key))) 126516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert)) 127516beb58SJuan Castillo $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert)) 128516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_content.crt,--nt-fw-cert)) 129516beb58SJuan Castillo $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/nt_fw_key.crt,--nt-fw-key-cert)) 13073c99d4eSJuan Castilloendif 1319003fa0bSYatharth Kochar 1329003fa0bSYatharth Kochar# Add the BL2U image 133516beb58SJuan Castillo$(if ${BL2U},$(eval $(call FWU_CERT_ADD_CMD_OPT,${BL2U},--ap-fwu-cfg,true)),\ 134516beb58SJuan Castillo $(eval $(call FWU_CERT_ADD_CMD_OPT,$(call IMG_BIN,2u),--ap-fwu-cfg,true))) 1350191262dSYatharth Kochar 1360191262dSYatharth Kochar# Add the SCP_BL2U image 1370191262dSYatharth Kocharifneq (${SCP_BL2U},) 138516beb58SJuan Castillo $(eval $(call FWU_CERT_ADD_CMD_OPT,${SCP_BL2U},--scp-fwu-cfg,true)) 1390191262dSYatharth Kocharendif 1400191262dSYatharth Kochar 1410191262dSYatharth Kochar# Add the NS_BL2U image 1420191262dSYatharth Kocharifneq (${NS_BL2U},) 143516beb58SJuan Castillo $(eval $(call FWU_CERT_ADD_CMD_OPT,${NS_BL2U},--fwu,true)) 1449003fa0bSYatharth Kocharendif 145