cot.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * Copyright 2020 NXP
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #include <stddef.h>
  9. #include <drivers/auth/auth_mod.h>
  10. #if USE_TBBR_DEFS
  11. #include <tools_share/tbbr_oid.h>
  12. #else
  13. #include <platform_oid.h>
  14. #endif
  15. static auth_param_type_desc_t sig = AUTH_PARAM_TYPE_DESC(
  16. AUTH_PARAM_SIG, 0);
  17. static auth_param_type_desc_t sig_alg = AUTH_PARAM_TYPE_DESC(
  18. AUTH_PARAM_SIG_ALG, 0);
  19. static auth_param_type_desc_t sig_hash = AUTH_PARAM_TYPE_DESC(
  20. AUTH_PARAM_HASH, 0);
  21. static auth_param_type_desc_t non_trusted_world_pk = AUTH_PARAM_TYPE_DESC(
  22. AUTH_PARAM_PUB_KEY, NON_TRUSTED_WORLD_PK_OID);
  23. /*
  24. * TBBR Chain of trust definition
  25. */
  26. static const auth_img_desc_t bl31_image = {
  27. .img_id = BL31_IMAGE_ID,
  28. .img_type = IMG_PLAT,
  29. .parent = NULL,
  30. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  31. [0] = {
  32. .type = AUTH_METHOD_SIG,
  33. .param.sig = {
  34. .pk = &non_trusted_world_pk,
  35. .sig = &sig,
  36. .alg = &sig_alg,
  37. .data = &sig_hash
  38. }
  39. }
  40. }
  41. };
  42. static const auth_img_desc_t scp_bl2_image = {
  43. .img_id = SCP_BL2_IMAGE_ID,
  44. .img_type = IMG_PLAT,
  45. .parent = NULL,
  46. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  47. [0] = {
  48. .type = AUTH_METHOD_SIG,
  49. .param.sig = {
  50. .pk = &non_trusted_world_pk,
  51. .sig = &sig,
  52. .alg = &sig_alg,
  53. .data = &sig_hash
  54. }
  55. }
  56. }
  57. };
  58. static const auth_img_desc_t bl32_image = {
  59. .img_id = BL32_IMAGE_ID,
  60. .img_type = IMG_PLAT,
  61. .parent = NULL,
  62. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  63. [0] = {
  64. .type = AUTH_METHOD_SIG,
  65. .param.sig = {
  66. .pk = &non_trusted_world_pk,
  67. .sig = &sig,
  68. .alg = &sig_alg,
  69. .data = &sig_hash
  70. }
  71. }
  72. }
  73. };
  74. static const auth_img_desc_t bl33_image = {
  75. .img_id = BL33_IMAGE_ID,
  76. .img_type = IMG_PLAT,
  77. .parent = NULL,
  78. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  79. [0] = {
  80. .type = AUTH_METHOD_SIG,
  81. .param.sig = {
  82. .pk = &non_trusted_world_pk,
  83. .sig = &sig,
  84. .alg = &sig_alg,
  85. .data = &sig_hash
  86. }
  87. }
  88. }
  89. };
  90. #ifdef POLICY_FUSE_PROVISION
  91. static const auth_img_desc_t fuse_prov_img = {
  92. .img_id = FUSE_PROV_IMAGE_ID,
  93. .img_type = IMG_PLAT,
  94. .parent = NULL,
  95. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  96. [0] = {
  97. .type = AUTH_METHOD_SIG,
  98. .param.sig = {
  99. .pk = &non_trusted_world_pk,
  100. .sig = &sig,
  101. .alg = &sig_alg,
  102. .data = &sig_hash
  103. }
  104. }
  105. }
  106. };
  107. static const auth_img_desc_t fuse_upgrade_img = {
  108. .img_id = FUSE_UP_IMAGE_ID,
  109. .img_type = IMG_PLAT,
  110. .parent = NULL,
  111. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  112. [0] = {
  113. .type = AUTH_METHOD_SIG,
  114. .param.sig = {
  115. .pk = &non_trusted_world_pk,
  116. .sig = &sig,
  117. .alg = &sig_alg,
  118. .data = &sig_hash
  119. }
  120. }
  121. }
  122. };
  123. #endif
  124. #ifdef CONFIG_DDR_FIP_IMAGE
  125. static const auth_img_desc_t ddr_imem_udimm_1d_img = {
  126. .img_id = DDR_IMEM_UDIMM_1D_IMAGE_ID,
  127. .img_type = IMG_PLAT,
  128. .parent = NULL,
  129. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  130. [0] = {
  131. .type = AUTH_METHOD_SIG,
  132. .param.sig = {
  133. .pk = &non_trusted_world_pk,
  134. .sig = &sig,
  135. .alg = &sig_alg,
  136. .data = &sig_hash
  137. }
  138. }
  139. }
  140. };
  141. static const auth_img_desc_t ddr_imem_udimm_2d_img = {
  142. .img_id = DDR_IMEM_UDIMM_2D_IMAGE_ID,
  143. .img_type = IMG_PLAT,
  144. .parent = NULL,
  145. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  146. [0] = {
  147. .type = AUTH_METHOD_SIG,
  148. .param.sig = {
  149. .pk = &non_trusted_world_pk,
  150. .sig = &sig,
  151. .alg = &sig_alg,
  152. .data = &sig_hash
  153. }
  154. }
  155. }
  156. };
  157. static const auth_img_desc_t ddr_dmem_udimm_1d_img = {
  158. .img_id = DDR_DMEM_UDIMM_1D_IMAGE_ID,
  159. .img_type = IMG_PLAT,
  160. .parent = NULL,
  161. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  162. [0] = {
  163. .type = AUTH_METHOD_SIG,
  164. .param.sig = {
  165. .pk = &non_trusted_world_pk,
  166. .sig = &sig,
  167. .alg = &sig_alg,
  168. .data = &sig_hash
  169. }
  170. }
  171. }
  172. };
  173. static const auth_img_desc_t ddr_dmem_udimm_2d_img = {
  174. .img_id = DDR_DMEM_UDIMM_2D_IMAGE_ID,
  175. .img_type = IMG_PLAT,
  176. .parent = NULL,
  177. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  178. [0] = {
  179. .type = AUTH_METHOD_SIG,
  180. .param.sig = {
  181. .pk = &non_trusted_world_pk,
  182. .sig = &sig,
  183. .alg = &sig_alg,
  184. .data = &sig_hash
  185. }
  186. }
  187. }
  188. };
  189. static const auth_img_desc_t ddr_imem_rdimm_1d_img = {
  190. .img_id = DDR_IMEM_RDIMM_1D_IMAGE_ID,
  191. .img_type = IMG_PLAT,
  192. .parent = NULL,
  193. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  194. [0] = {
  195. .type = AUTH_METHOD_SIG,
  196. .param.sig = {
  197. .pk = &non_trusted_world_pk,
  198. .sig = &sig,
  199. .alg = &sig_alg,
  200. .data = &sig_hash
  201. }
  202. }
  203. }
  204. };
  205. static const auth_img_desc_t ddr_imem_rdimm_2d_img = {
  206. .img_id = DDR_IMEM_RDIMM_2D_IMAGE_ID,
  207. .img_type = IMG_PLAT,
  208. .parent = NULL,
  209. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  210. [0] = {
  211. .type = AUTH_METHOD_SIG,
  212. .param.sig = {
  213. .pk = &non_trusted_world_pk,
  214. .sig = &sig,
  215. .alg = &sig_alg,
  216. .data = &sig_hash
  217. }
  218. }
  219. }
  220. };
  221. static const auth_img_desc_t ddr_dmem_rdimm_1d_img = {
  222. .img_id = DDR_DMEM_RDIMM_1D_IMAGE_ID,
  223. .img_type = IMG_PLAT,
  224. .parent = NULL,
  225. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  226. [0] = {
  227. .type = AUTH_METHOD_SIG,
  228. .param.sig = {
  229. .pk = &non_trusted_world_pk,
  230. .sig = &sig,
  231. .alg = &sig_alg,
  232. .data = &sig_hash
  233. }
  234. }
  235. }
  236. };
  237. static const auth_img_desc_t ddr_dmem_rdimm_2d_img = {
  238. .img_id = DDR_DMEM_RDIMM_2D_IMAGE_ID,
  239. .img_type = IMG_PLAT,
  240. .parent = NULL,
  241. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  242. [0] = {
  243. .type = AUTH_METHOD_SIG,
  244. .param.sig = {
  245. .pk = &non_trusted_world_pk,
  246. .sig = &sig,
  247. .alg = &sig_alg,
  248. .data = &sig_hash
  249. }
  250. }
  251. }
  252. };
  253. #endif
  254. static const auth_img_desc_t * const cot_desc[] = {
  255. [BL31_IMAGE_ID] = &bl31_image,
  256. [SCP_BL2_IMAGE_ID] = &scp_bl2_image,
  257. [BL32_IMAGE_ID] = &bl32_image,
  258. [BL33_IMAGE_ID] = &bl33_image,
  259. #ifdef POLICY_FUSE_PROVISION
  260. [FUSE_PROV_IMAGE_ID] = &fuse_prov_img,
  261. [FUSE_UP_IMAGE_ID] = &fuse_upgrade_img,
  262. #endif
  263. #ifdef CONFIG_DDR_FIP_IMAGE
  264. [DDR_IMEM_UDIMM_1D_IMAGE_ID] = &ddr_imem_udimm_1d_img,
  265. [DDR_IMEM_UDIMM_2D_IMAGE_ID] = &ddr_imem_udimm_2d_img,
  266. [DDR_DMEM_UDIMM_1D_IMAGE_ID] = &ddr_dmem_udimm_1d_img,
  267. [DDR_DMEM_UDIMM_2D_IMAGE_ID] = &ddr_dmem_udimm_2d_img,
  268. [DDR_IMEM_RDIMM_1D_IMAGE_ID] = &ddr_imem_rdimm_1d_img,
  269. [DDR_IMEM_RDIMM_2D_IMAGE_ID] = &ddr_imem_rdimm_2d_img,
  270. [DDR_DMEM_RDIMM_1D_IMAGE_ID] = &ddr_dmem_rdimm_1d_img,
  271. [DDR_DMEM_RDIMM_2D_IMAGE_ID] = &ddr_dmem_rdimm_2d_img,
  272. #endif
  273. };
  274. /* Register the CoT in the authentication module */
  275. REGISTER_COT(cot_desc);