1*18498657SPankaj Gupta# 2*18498657SPankaj Gupta# Copyright 2021 NXP 3*18498657SPankaj Gupta# 4*18498657SPankaj Gupta# SPDX-License-Identifier: BSD-3-Clause 5*18498657SPankaj Gupta# 6*18498657SPankaj Gupta 7*18498657SPankaj Gupta# This file defines the keys and certificates that must be created to establish 8*18498657SPankaj Gupta# a Chain of Trust for the DDR FW. These definitions include the 9*18498657SPankaj Gupta# command line options passed to the cert_create and fiptool commands for DDR FW. 10*18498657SPankaj Gupta# A DDR FW key is used for signing the DDR Firmware. The DDR key is authenticated 11*18498657SPankaj Gupta# by the Trusted World Key. Two content certificates are created: 12*18498657SPankaj Gupta# For DDR RDIMM Images [ signed by DDR FW Key] 13*18498657SPankaj Gupta# For DDR UDIMM Images [ signed by DDR FW Key] 14*18498657SPankaj Gupta# 15*18498657SPankaj Gupta# Expected environment: 16*18498657SPankaj Gupta# 17*18498657SPankaj Gupta# BUILD_PLAT: output directory 18*18498657SPankaj Gupta# 19*18498657SPankaj Gupta# Build options added by this file: 20*18498657SPankaj Gupta# 21*18498657SPankaj Gupta# KEY_ALG 22*18498657SPankaj Gupta# KEY_SIZE 23*18498657SPankaj Gupta# TRUSTED_WORLD_KEY 24*18498657SPankaj Gupta# NON_TRUSTED_WORLD_KEY 25*18498657SPankaj Gupta# 26*18498657SPankaj Gupta 27*18498657SPankaj Gupta# Certificate generation tool default parameters 28*18498657SPankaj GuptaDDR_FW_CERT := ${BUILD_PLAT}/ddr_fw_key_cert.crt 29*18498657SPankaj Gupta 30*18498657SPankaj Gupta# Default non-volatile counter values (overridable by the platform) 31*18498657SPankaj GuptaTFW_NVCTR_VAL ?= 0 32*18498657SPankaj GuptaNTFW_NVCTR_VAL ?= 0 33*18498657SPankaj Gupta 34*18498657SPankaj Gupta# Pass the non-volatile counters to the cert_create tool 35*18498657SPankaj Gupta$(eval $(call CERT_ADD_CMD_OPT,${TFW_NVCTR_VAL},--tfw-nvctr,DDR_)) 36*18498657SPankaj Gupta 37*18498657SPankaj Guptaifeq (${DDR_KEY},) 38*18498657SPankaj GuptaDDR_KEY=${BUILD_PLAT}/ddr.pem 39*18498657SPankaj Guptaendif 40*18498657SPankaj Gupta 41*18498657SPankaj Guptaifeq (${TRUSTED_KEY_CERT},) 42*18498657SPankaj Gupta$(info Generating: Trusted key certificate as part of DDR cert creation) 43*18498657SPankaj GuptaTRUSTED_KEY_CERT := ${BUILD_PLAT}/trusted_key.crt 44*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,)) 45*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert,,DDR_)) 46*18498657SPankaj Guptaelse 47*18498657SPankaj Gupta$(info Using: Trusted key certificate as part of DDR cert creation) 48*18498657SPankaj GuptaDDR_FIP_ARGS += --trusted-key-cert ${TRUSTED_KEY_CERT} 49*18498657SPankaj Guptaendif 50*18498657SPankaj Gupta 51*18498657SPankaj Gupta# Add the keys to the cert_create command line options (private keys are NOT 52*18498657SPankaj Gupta# packed in the FIP). Developers can use their own keys by specifying the proper 53*18498657SPankaj Gupta# build option in the command line when building the Trusted Firmware 54*18498657SPankaj Gupta$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg,DDR_))) 55*18498657SPankaj Gupta$(if ${KEY_SIZE},$(eval $(call CERT_ADD_CMD_OPT,${KEY_SIZE},--key-size,DDR_))) 56*18498657SPankaj Gupta$(if ${HASH_ALG},$(eval $(call CERT_ADD_CMD_OPT,${HASH_ALG},--hash-alg,DDR_))) 57*18498657SPankaj Gupta$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key,DDR_))) 58*18498657SPankaj Gupta$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key,DDR_))) 59*18498657SPankaj Gupta$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key, DDR_))) 60*18498657SPankaj Gupta 61*18498657SPankaj Gupta# Add the DDR CoT (key cert + img cert) 62*18498657SPankaj Gupta$(if ${DDR_KEY},$(eval $(call CERT_ADD_CMD_OPT,${DDR_KEY},--ddr-fw-key,DDR_))) 63*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_fw_key.crt,--ddr-fw-key-cert,,DDR_)) 64*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_udimm_fw_content.crt,--ddr-udimm-fw-cert,,DDR_)) 65*18498657SPankaj Gupta$(eval $(call TOOL_ADD_PAYLOAD,${BUILD_PLAT}/ddr_rdimm_fw_content.crt,--ddr-rdimm-fw-cert,,DDR_)) 66*18498657SPankaj Gupta 67*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_1D,--ddr-immem-udimm-1d,DDR_)) 68*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_UDIMM_2D,--ddr-immem-udimm-2d,DDR_)) 69*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_1D,--ddr-dmmem-udimm-1d,DDR_)) 70*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_UDIMM_2D,--ddr-dmmem-udimm-2d,DDR_)) 71*18498657SPankaj Gupta 72*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_1D,--ddr-immem-rdimm-1d,DDR_)) 73*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_IMEM_RDIMM_2D,--ddr-immem-rdimm-2d,DDR_)) 74*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_1D,--ddr-dmmem-rdimm-1d,DDR_)) 75*18498657SPankaj Gupta$(eval $(call TOOL_ADD_IMG,DDR_DMEM_RDIMM_2D,--ddr-dmmem-rdimm-2d,DDR_)) 76*18498657SPankaj Gupta 77*18498657SPankaj GuptaDDR_FIP_DEPS += ddr_certificates 78*18498657SPankaj Gupta 79*18498657SPankaj Gupta# Process TBB related flags 80*18498657SPankaj Guptaifneq (${GENERATE_COT},0) 81*18498657SPankaj Gupta # Common cert_create options 82*18498657SPankaj Gupta ifneq (${CREATE_KEYS},0) 83*18498657SPankaj Gupta $(eval DDR_CRT_ARGS += -n) 84*18498657SPankaj Gupta ifneq (${SAVE_KEYS},0) 85*18498657SPankaj Gupta $(eval DDR_CRT_ARGS += -k) 86*18498657SPankaj Gupta endif 87*18498657SPankaj Gupta endif 88*18498657SPankaj Guptaendif 89