1*91f16700Schasinglulu# 2*91f16700Schasinglulu# Copyright 2021 NXP 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 for the DDR FW. These definitions include the 9*91f16700Schasinglulu# command line options passed to the cert_create and fiptool commands for DDR FW. 10*91f16700Schasinglulu# A DDR FW key is used for signing the DDR Firmware. The DDR key is authenticated 11*91f16700Schasinglulu# by the Trusted World Key. Two content certificates are created: 12*91f16700Schasinglulu# For DDR RDIMM Images [ signed by DDR FW Key] 13*91f16700Schasinglulu# For DDR UDIMM Images [ signed by DDR FW Key] 14*91f16700Schasinglulu# 15*91f16700Schasinglulu# Expected environment: 16*91f16700Schasinglulu# 17*91f16700Schasinglulu# BUILD_PLAT: output directory 18*91f16700Schasinglulu# 19*91f16700Schasinglulu# Build options added by this file: 20*91f16700Schasinglulu# 21*91f16700Schasinglulu# KEY_ALG 22*91f16700Schasinglulu# KEY_SIZE 23*91f16700Schasinglulu# TRUSTED_WORLD_KEY 24*91f16700Schasinglulu# NON_TRUSTED_WORLD_KEY 25*91f16700Schasinglulu# 26*91f16700Schasinglulu 27*91f16700Schasinglulu# Copy the tbbr.mk from PLAT_TOOL_PATH/cert_create_helper 28*91f16700Schasinglulu# to the ${PLAT_DIR}. So that cert_create is enabled 29*91f16700Schasinglulu# to create certificates for DDR 30*91f16700Schasinglulu$(shell cp ${PLAT_TOOL_PATH}/cert_create_helper/cert_create_tbbr.mk ${PLAT_DIR}) 31*91f16700Schasinglulu 32*91f16700Schasinglulu# Certificate generation tool default parameters 33*91f16700SchasingluluDDR_FW_CERT := ${BUILD_PLAT}/ddr_fw_key_cert.crt 34*91f16700Schasinglulu 35*91f16700Schasinglulu# Default non-volatile counter values (overridable by the platform) 36*91f16700SchasingluluTFW_NVCTR_VAL ?= 0 37*91f16700SchasingluluNTFW_NVCTR_VAL ?= 0 38*91f16700Schasinglulu 39*91f16700Schasinglulu# Pass the non-volatile counters to the cert_create tool 40*91f16700Schasinglulu$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr,DDR_)) 41*91f16700Schasinglulu 42*91f16700Schasinglulu$(shell mkdir -p '${BUILD_PLAT}') 43*91f16700Schasinglulu 44*91f16700Schasingluluifeq (${DDR_KEY},) 45*91f16700SchasingluluDDR_KEY=${BUILD_PLAT}/ddr.pem 46*91f16700Schasingluluendif 47*91f16700Schasinglulu 48*91f16700Schasingluluifeq (${TRUSTED_KEY_CERT},) 49*91f16700Schasinglulu$(info Generating: Trusted key certificate as part of DDR cert creation) 50*91f16700SchasingluluTRUSTED_KEY_CERT := ${BUILD_PLAT}/trusted_key.crt 51*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,)) 52*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,,DDR_)) 53*91f16700Schasingluluelse 54*91f16700Schasinglulu$(info Using: Trusted key certificate as part of DDR cert creation) 55*91f16700SchasingluluDDR_FIP_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT} 56*91f16700Schasingluluendif 57*91f16700Schasinglulu 58*91f16700Schasinglulu# Add the keys to the cert_create command line options (private keys are NOT 59*91f16700Schasinglulu# packed in the FIP). Developers can use their own keys by specifying the proper 60*91f16700Schasinglulu# build option in the command line when building the Trusted Firmware 61*91f16700Schasinglulu$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,DDR_))) 62*91f16700Schasinglulu$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,DDR_))) 63*91f16700Schasinglulu$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,DDR_))) 64*91f16700Schasinglulu$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,DDR_))) 65*91f16700Schasinglulu$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key,DDR_))) 66*91f16700Schasinglulu$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key, DDR_))) 67*91f16700Schasinglulu 68*91f16700Schasinglulu# Add the DDR CoT (key cert + img cert) 69*91f16700Schasinglulu$(if ${DDR_KEY},$(eval $(call CERT_ADD_CMD_OPT,${DDR_KEY},--ddr-fw-key,DDR_))) 70*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_fw_key.crt,--ddr-fw-key-cert,,DDR_)) 71*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_udimm_fw_content.crt,--ddr-udimm-fw-cert,,DDR_)) 72*91f16700Schasinglulu$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_rdimm_fw_content.crt,--ddr-rdimm-fw-cert,,DDR_)) 73*91f16700Schasinglulu 74*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_1D,--ddr-immem-udimm-1d,DDR_)) 75*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_2D,--ddr-immem-udimm-2d,DDR_)) 76*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_1D,--ddr-dmmem-udimm-1d,DDR_)) 77*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_2D,--ddr-dmmem-udimm-2d,DDR_)) 78*91f16700Schasinglulu 79*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_1D,--ddr-immem-rdimm-1d,DDR_)) 80*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_2D,--ddr-immem-rdimm-2d,DDR_)) 81*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_1D,--ddr-dmmem-rdimm-1d,DDR_)) 82*91f16700Schasinglulu$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_2D,--ddr-dmmem-rdimm-2d,DDR_)) 83*91f16700Schasinglulu 84*91f16700SchasingluluDDR_FIP_DEPS += ddr_certificates 85*91f16700Schasinglulu 86*91f16700Schasinglulu# Process TBB related flags 87*91f16700Schasingluluifneq (${GENERATE_COT},0) 88*91f16700Schasinglulu # Common cert_create options 89*91f16700Schasinglulu ifneq (${CREATE_KEYS},0) 90*91f16700Schasinglulu $(eval DDR_CRT_ARGS += -n) 91*91f16700Schasinglulu ifneq (${SAVE_KEYS},0) 92*91f16700Schasinglulu $(eval DDR_CRT_ARGS += -k) 93*91f16700Schasinglulu endif 94*91f16700Schasinglulu endif 95*91f16700Schasingluluendif 96