xref: /rk3399_ARM-atf/make_helpers/tbbr/tbbr_tools.mk (revision 73c99d4eb377e0e25f7951be53087bf92e7b4b18)
1*73c99d4eSJuan Castillo#
2*73c99d4eSJuan Castillo# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3*73c99d4eSJuan Castillo#
4*73c99d4eSJuan Castillo# Redistribution and use in source and binary forms, with or without
5*73c99d4eSJuan Castillo# modification, are permitted provided that the following conditions are met:
6*73c99d4eSJuan Castillo#
7*73c99d4eSJuan Castillo# Redistributions of source code must retain the above copyright notice, this
8*73c99d4eSJuan Castillo# list of conditions and the following disclaimer.
9*73c99d4eSJuan Castillo#
10*73c99d4eSJuan Castillo# Redistributions in binary form must reproduce the above copyright notice,
11*73c99d4eSJuan Castillo# this list of conditions and the following disclaimer in the documentation
12*73c99d4eSJuan Castillo# and/or other materials provided with the distribution.
13*73c99d4eSJuan Castillo#
14*73c99d4eSJuan Castillo# Neither the name of ARM nor the names of its contributors may be used
15*73c99d4eSJuan Castillo# to endorse or promote products derived from this software without specific
16*73c99d4eSJuan Castillo# prior written permission.
17*73c99d4eSJuan Castillo#
18*73c99d4eSJuan Castillo# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*73c99d4eSJuan Castillo# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*73c99d4eSJuan Castillo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*73c99d4eSJuan Castillo# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*73c99d4eSJuan Castillo# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*73c99d4eSJuan Castillo# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*73c99d4eSJuan Castillo# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*73c99d4eSJuan Castillo# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*73c99d4eSJuan Castillo# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*73c99d4eSJuan Castillo# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*73c99d4eSJuan Castillo# POSSIBILITY OF SUCH DAMAGE.
29*73c99d4eSJuan Castillo#
30*73c99d4eSJuan Castillo
31*73c99d4eSJuan Castillo# This file defines the keys and certificates that must be created to establish
32*73c99d4eSJuan Castillo# a Chain of Trust following the TBBR document. These definitions include the
33*73c99d4eSJuan Castillo# command line options passed to the cert_create and fip_create tools.
34*73c99d4eSJuan Castillo#
35*73c99d4eSJuan Castillo# Expected environment:
36*73c99d4eSJuan Castillo#
37*73c99d4eSJuan Castillo#   BUILD_PLAT: output directory
38*73c99d4eSJuan Castillo#   NEED_BL32: indicates whether BL3-2 is needed by the platform
39*73c99d4eSJuan Castillo#   BL2: image filename (optional). Default is IMG_BIN(2) (see macro IMG_BIN)
40*73c99d4eSJuan Castillo#   BL30: image filename (optional). Default is IMG_BIN(30)
41*73c99d4eSJuan Castillo#   BL31: image filename (optional). Default is IMG_BIN(31)
42*73c99d4eSJuan Castillo#   BL32: image filename (optional). Default is IMG_BIN(32)
43*73c99d4eSJuan Castillo#   BL33: image filename (optional). Default is IMG_BIN(33)
44*73c99d4eSJuan Castillo#
45*73c99d4eSJuan Castillo# Build options added by this file:
46*73c99d4eSJuan Castillo#
47*73c99d4eSJuan Castillo#   KEY_ALG
48*73c99d4eSJuan Castillo#   ROT_KEY
49*73c99d4eSJuan Castillo#   TRUSTED_WORLD_KEY
50*73c99d4eSJuan Castillo#   NON_TRUSTED_WORLD_KEY
51*73c99d4eSJuan Castillo#   BL30_KEY
52*73c99d4eSJuan Castillo#   BL31_KEY
53*73c99d4eSJuan Castillo#   BL32_KEY
54*73c99d4eSJuan Castillo#   BL33_KEY
55*73c99d4eSJuan Castillo#
56*73c99d4eSJuan Castillo
57*73c99d4eSJuan Castillo# Certificate generation tool default parameters
58*73c99d4eSJuan CastilloTRUSTED_KEY_CERT	:=	${BUILD_PLAT}/trusted_key.crt
59*73c99d4eSJuan Castillo
60*73c99d4eSJuan Castillo# Add Trusted Key certificate to the fip_create and cert_create command line options
61*73c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${TRUSTED_KEY_CERT},--trusted-key-cert))
62*73c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_KEY_CERT},--trusted-key-cert))
63*73c99d4eSJuan Castillo
64*73c99d4eSJuan Castillo# Add the keys to the cert_create command line options (private keys are NOT
65*73c99d4eSJuan Castillo# packed in the FIP). Developers can use their own keys by specifying the proper
66*73c99d4eSJuan Castillo# build option in the command line when building the Trusted Firmware
67*73c99d4eSJuan Castillo$(if ${KEY_ALG},$(eval $(call CERT_ADD_CMD_OPT,${KEY_ALG},--key-alg)))
68*73c99d4eSJuan Castillo$(if ${ROT_KEY},$(eval $(call CERT_ADD_CMD_OPT,${ROT_KEY},--rot-key)))
69*73c99d4eSJuan Castillo$(if ${TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${TRUSTED_WORLD_KEY},--trusted-world-key)))
70*73c99d4eSJuan Castillo$(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD_KEY},--non-trusted-world-key)))
71*73c99d4eSJuan Castillo
72*73c99d4eSJuan Castillo# Add the BL2 CoT (image cert + image)
73*73c99d4eSJuan Castillo$(if ${BL2},$(eval $(call CERT_ADD_CMD_OPT,${BL2},--bl2,true)),\
74*73c99d4eSJuan Castillo            $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,2),--bl2,true)))
75*73c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl2.crt,--bl2-cert))
76*73c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl2.crt,--bl2-cert))
77*73c99d4eSJuan Castillo
78*73c99d4eSJuan Castillo# Add the BL30 CoT (key cert + img cert + image)
79*73c99d4eSJuan Castilloifneq (${BL30},)
80*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BL30},--bl30,true))
81*73c99d4eSJuan Castillo    $(if ${BL30_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL30_KEY},--bl30-key)))
82*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl30.crt,--bl30-cert))
83*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl30_key.crt,--bl30-key-cert))
84*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl30.crt,--bl30-cert))
85*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl30_key.crt,--bl30-key-cert))
86*73c99d4eSJuan Castilloendif
87*73c99d4eSJuan Castillo
88*73c99d4eSJuan Castillo# Add the BL31 CoT (key cert + img cert + image)
89*73c99d4eSJuan Castillo$(if ${BL31},$(eval $(call CERT_ADD_CMD_OPT,${BL31},--bl31,true)),\
90*73c99d4eSJuan Castillo             $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,31),--bl31,true)))
91*73c99d4eSJuan Castillo$(if ${BL31_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL31_KEY},--bl31-key)))
92*73c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl31.crt,--bl31-cert))
93*73c99d4eSJuan Castillo$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl31_key.crt,--bl31-key-cert))
94*73c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl31.crt,--bl31-cert))
95*73c99d4eSJuan Castillo$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl31_key.crt,--bl31-key-cert))
96*73c99d4eSJuan Castillo
97*73c99d4eSJuan Castillo# Add the BL32 CoT (key cert + img cert + image)
98*73c99d4eSJuan Castilloifeq (${NEED_BL32},yes)
99*73c99d4eSJuan Castillo    $(if ${BL32},$(eval $(call CERT_ADD_CMD_OPT,${BL32},--bl32,true)),\
100*73c99d4eSJuan Castillo                 $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,32),--bl32,true)))
101*73c99d4eSJuan Castillo    $(if ${BL32_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL32_KEY},--bl32-key)))
102*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl32.crt,--bl32-cert))
103*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl32_key.crt,--bl32-key-cert))
104*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl32.crt,--bl32-cert))
105*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl32_key.crt,--bl32-key-cert))
106*73c99d4eSJuan Castilloendif
107*73c99d4eSJuan Castillo
108*73c99d4eSJuan Castillo# Add the BL33 CoT (key cert + img cert + image)
109*73c99d4eSJuan Castilloifneq (${BL33},)
110*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BL33},--bl33,true))
111*73c99d4eSJuan Castillo    $(if ${BL33_KEY},$(eval $(call CERT_ADD_CMD_OPT,${BL33_KEY},--bl33-key)))
112*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl33.crt,--bl33-cert))
113*73c99d4eSJuan Castillo    $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/bl33_key.crt,--bl33-key-cert))
114*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl33.crt,--bl33-cert))
115*73c99d4eSJuan Castillo    $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/bl33_key.crt,--bl33-key-cert))
116*73c99d4eSJuan Castilloendif
117