tbbr.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #
  2. # Copyright 2020-2022 NXP
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. # For TRUSTED_BOARD_BOOT platforms need to include this makefile
  7. # Following definations are to be provided by platform.mk file or
  8. # by user - BL33_INPUT_FILE, BL32_INPUT_FILE, BL31_INPUT_FILE
  9. ifeq ($(CHASSIS), 2)
  10. include $(PLAT_DRIVERS_PATH)/csu/csu.mk
  11. CSF_FILE := input_blx_ch${CHASSIS}
  12. BL2_CSF_FILE := input_bl2_ch${CHASSIS}
  13. else
  14. ifeq ($(CHASSIS), 3)
  15. CSF_FILE := input_blx_ch${CHASSIS}
  16. BL2_CSF_FILE := input_bl2_ch${CHASSIS}
  17. PBI_CSF_FILE := input_pbi_ch${CHASSIS}
  18. $(eval $(call add_define, CSF_HDR_CH3))
  19. else
  20. ifeq ($(CHASSIS), 3_2)
  21. CSF_FILE := input_blx_ch3
  22. BL2_CSF_FILE := input_bl2_ch${CHASSIS}
  23. PBI_CSF_FILE := input_pbi_ch${CHASSIS}
  24. $(eval $(call add_define, CSF_HDR_CH3))
  25. else
  26. $(error -> CHASSIS not set!)
  27. endif
  28. endif
  29. endif
  30. PLAT_AUTH_PATH := $(PLAT_DRIVERS_PATH)/auth
  31. ifeq (${BL2_INPUT_FILE},)
  32. BL2_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${BL2_CSF_FILE}
  33. endif
  34. ifeq (${PBI_INPUT_FILE},)
  35. PBI_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${PBI_CSF_FILE}
  36. endif
  37. # If MBEDTLS_DIR is not specified, use CSF Header option
  38. ifeq (${MBEDTLS_DIR},)
  39. # Generic image processing filters to prepend CSF header
  40. ifeq (${BL33_INPUT_FILE},)
  41. BL33_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${CSF_FILE}
  42. endif
  43. ifeq (${BL31_INPUT_FILE},)
  44. BL31_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${CSF_FILE}
  45. endif
  46. ifeq (${BL32_INPUT_FILE},)
  47. BL32_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${CSF_FILE}
  48. endif
  49. ifeq (${FUSE_INPUT_FILE},)
  50. FUSE_INPUT_FILE := $(PLAT_AUTH_PATH)/csf_hdr_parser/${CSF_FILE}
  51. endif
  52. PLAT_INCLUDES += -I$(PLAT_DRIVERS_PATH)/sfp
  53. PLAT_TBBR_SOURCES += $(PLAT_AUTH_PATH)/csf_hdr_parser/cot.c \
  54. $(PLAT_COMMON_PATH)/tbbr/csf_tbbr.c
  55. # IMG PARSER here is CSF header parser
  56. include $(PLAT_DRIVERS_PATH)/auth/csf_hdr_parser/csf_hdr.mk
  57. PLAT_TBBR_SOURCES += $(CSF_HDR_SOURCES)
  58. SCP_BL2_PRE_TOOL_FILTER := CST_SCP_BL2
  59. BL31_PRE_TOOL_FILTER := CST_BL31
  60. BL32_PRE_TOOL_FILTER := CST_BL32
  61. BL33_PRE_TOOL_FILTER := CST_BL33
  62. else
  63. ifeq (${DISABLE_FUSE_WRITE}, 1)
  64. $(eval $(call add_define,DISABLE_FUSE_WRITE))
  65. endif
  66. # For Mbedtls currently crypto is not supported via CAAM
  67. # enable it when that support is there
  68. CAAM_INTEG := 0
  69. KEY_ALG := rsa
  70. KEY_SIZE := 2048
  71. $(eval $(call add_define,MBEDTLS_X509))
  72. ifeq (${PLAT_DDR_PHY},PHY_GEN2)
  73. $(eval $(call add_define,PLAT_DEF_OID))
  74. endif
  75. include drivers/auth/mbedtls/mbedtls_x509.mk
  76. PLAT_TBBR_SOURCES += $(PLAT_AUTH_PATH)/tbbr/tbbr_cot.c \
  77. $(PLAT_COMMON_PATH)/tbbr/nxp_rotpk.S \
  78. $(PLAT_COMMON_PATH)/tbbr/x509_tbbr.c
  79. #ROTPK key is embedded in BL2 image
  80. ifeq (${ROT_KEY},)
  81. ROT_KEY = $(BUILD_PLAT)/rot_key.pem
  82. endif
  83. ifeq (${SAVE_KEYS},1)
  84. ifeq (${TRUSTED_WORLD_KEY},)
  85. TRUSTED_WORLD_KEY = ${BUILD_PLAT}/trusted.pem
  86. endif
  87. ifeq (${NON_TRUSTED_WORLD_KEY},)
  88. NON_TRUSTED_WORLD_KEY = ${BUILD_PLAT}/non-trusted.pem
  89. endif
  90. ifeq (${BL31_KEY},)
  91. BL31_KEY = ${BUILD_PLAT}/soc.pem
  92. endif
  93. ifeq (${BL32_KEY},)
  94. BL32_KEY = ${BUILD_PLAT}/trusted_os.pem
  95. endif
  96. ifeq (${BL33_KEY},)
  97. BL33_KEY = ${BUILD_PLAT}/non-trusted_os.pem
  98. endif
  99. endif
  100. ROTPK_HASH = $(BUILD_PLAT)/rotpk_sha256.bin
  101. $(eval $(call add_define_val,ROTPK_HASH,'"$(ROTPK_HASH)"'))
  102. $(BUILD_PLAT)/bl2/nxp_rotpk.o: $(ROTPK_HASH)
  103. certificates: $(ROT_KEY)
  104. $(ROT_KEY): | $(BUILD_PLAT)
  105. @echo " OPENSSL $@"
  106. @if [ ! -f $(ROT_KEY) ]; then \
  107. ${OPENSSL_BIN_PATH}/openssl genrsa 2048 > $@ 2>/dev/null; \
  108. fi
  109. $(ROTPK_HASH): $(ROT_KEY)
  110. @echo " OPENSSL $@"
  111. $(Q)${OPENSSL_BIN_PATH}/openssl rsa -in $< -pubout -outform DER 2>/dev/null |\
  112. ${OPENSSL_BIN_PATH}/openssl dgst -sha256 -binary > $@ 2>/dev/null
  113. endif #MBEDTLS_DIR
  114. PLAT_INCLUDES += -Iinclude/common/tbbr
  115. # Generic files for authentication framework
  116. TBBR_SOURCES += drivers/auth/auth_mod.c \
  117. drivers/auth/crypto_mod.c \
  118. drivers/auth/img_parser_mod.c \
  119. plat/common/tbbr/plat_tbbr.c \
  120. ${PLAT_TBBR_SOURCES}
  121. # If CAAM_INTEG is not defined (would be scenario with MBED TLS)
  122. # include mbedtls_crypto
  123. ifeq (${CAAM_INTEG},0)
  124. include drivers/auth/mbedtls/mbedtls_crypto.mk
  125. else
  126. include $(PLAT_DRIVERS_PATH)/crypto/caam/src/auth/auth.mk
  127. TBBR_SOURCES += ${AUTH_SOURCES}
  128. endif