tbbr_cot_bl2.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stddef.h>
  7. #include <mbedtls/version.h>
  8. #include <drivers/auth/auth_mod.h>
  9. #include <drivers/auth/tbbr_cot_common.h>
  10. #if USE_TBBR_DEFS
  11. #include <tools_share/tbbr_oid.h>
  12. #else
  13. #include <platform_oid.h>
  14. #endif
  15. #include <platform_def.h>
  16. static unsigned char soc_fw_hash_buf[HASH_DER_LEN];
  17. static unsigned char tos_fw_hash_buf[HASH_DER_LEN];
  18. static unsigned char tos_fw_extra1_hash_buf[HASH_DER_LEN];
  19. static unsigned char tos_fw_extra2_hash_buf[HASH_DER_LEN];
  20. static unsigned char trusted_world_pk_buf[PK_DER_LEN];
  21. static unsigned char non_trusted_world_pk_buf[PK_DER_LEN];
  22. static unsigned char content_pk_buf[PK_DER_LEN];
  23. static unsigned char soc_fw_config_hash_buf[HASH_DER_LEN];
  24. static unsigned char tos_fw_config_hash_buf[HASH_DER_LEN];
  25. static unsigned char nt_fw_config_hash_buf[HASH_DER_LEN];
  26. #if defined(SPD_spmd)
  27. static unsigned char sp_pkg_hash_buf[MAX_SP_IDS][HASH_DER_LEN];
  28. #endif /* SPD_spmd */
  29. static auth_param_type_desc_t non_trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
  30. AUTH_PARAM_NV_CTR, NON_TRUSTED_FW_NVCOUNTER_OID);
  31. static auth_param_type_desc_t trusted_world_pk = AUTH_PARAM_TYPE_DESC(
  32. AUTH_PARAM_PUB_KEY, TRUSTED_WORLD_PK_OID);
  33. static auth_param_type_desc_t non_trusted_world_pk = AUTH_PARAM_TYPE_DESC(
  34. AUTH_PARAM_PUB_KEY, NON_TRUSTED_WORLD_PK_OID);
  35. static auth_param_type_desc_t scp_fw_content_pk = AUTH_PARAM_TYPE_DESC(
  36. AUTH_PARAM_PUB_KEY, SCP_FW_CONTENT_CERT_PK_OID);
  37. static auth_param_type_desc_t soc_fw_content_pk = AUTH_PARAM_TYPE_DESC(
  38. AUTH_PARAM_PUB_KEY, SOC_FW_CONTENT_CERT_PK_OID);
  39. static auth_param_type_desc_t tos_fw_content_pk = AUTH_PARAM_TYPE_DESC(
  40. AUTH_PARAM_PUB_KEY, TRUSTED_OS_FW_CONTENT_CERT_PK_OID);
  41. static auth_param_type_desc_t nt_fw_content_pk = AUTH_PARAM_TYPE_DESC(
  42. AUTH_PARAM_PUB_KEY, NON_TRUSTED_FW_CONTENT_CERT_PK_OID);
  43. static auth_param_type_desc_t scp_fw_hash = AUTH_PARAM_TYPE_DESC(
  44. AUTH_PARAM_HASH, SCP_FW_HASH_OID);
  45. static auth_param_type_desc_t soc_fw_hash = AUTH_PARAM_TYPE_DESC(
  46. AUTH_PARAM_HASH, SOC_AP_FW_HASH_OID);
  47. static auth_param_type_desc_t soc_fw_config_hash = AUTH_PARAM_TYPE_DESC(
  48. AUTH_PARAM_HASH, SOC_FW_CONFIG_HASH_OID);
  49. static auth_param_type_desc_t tos_fw_hash = AUTH_PARAM_TYPE_DESC(
  50. AUTH_PARAM_HASH, TRUSTED_OS_FW_HASH_OID);
  51. static auth_param_type_desc_t tos_fw_config_hash = AUTH_PARAM_TYPE_DESC(
  52. AUTH_PARAM_HASH, TRUSTED_OS_FW_CONFIG_HASH_OID);
  53. static auth_param_type_desc_t tos_fw_extra1_hash = AUTH_PARAM_TYPE_DESC(
  54. AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA1_HASH_OID);
  55. static auth_param_type_desc_t tos_fw_extra2_hash = AUTH_PARAM_TYPE_DESC(
  56. AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA2_HASH_OID);
  57. static auth_param_type_desc_t nt_world_bl_hash = AUTH_PARAM_TYPE_DESC(
  58. AUTH_PARAM_HASH, NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID);
  59. static auth_param_type_desc_t nt_fw_config_hash = AUTH_PARAM_TYPE_DESC(
  60. AUTH_PARAM_HASH, NON_TRUSTED_FW_CONFIG_HASH_OID);
  61. #if defined(SPD_spmd)
  62. static auth_param_type_desc_t sp_pkg1_hash = AUTH_PARAM_TYPE_DESC(
  63. AUTH_PARAM_HASH, SP_PKG1_HASH_OID);
  64. static auth_param_type_desc_t sp_pkg2_hash = AUTH_PARAM_TYPE_DESC(
  65. AUTH_PARAM_HASH, SP_PKG2_HASH_OID);
  66. static auth_param_type_desc_t sp_pkg3_hash = AUTH_PARAM_TYPE_DESC(
  67. AUTH_PARAM_HASH, SP_PKG3_HASH_OID);
  68. static auth_param_type_desc_t sp_pkg4_hash = AUTH_PARAM_TYPE_DESC(
  69. AUTH_PARAM_HASH, SP_PKG4_HASH_OID);
  70. static auth_param_type_desc_t sp_pkg5_hash = AUTH_PARAM_TYPE_DESC(
  71. AUTH_PARAM_HASH, SP_PKG5_HASH_OID);
  72. static auth_param_type_desc_t sp_pkg6_hash = AUTH_PARAM_TYPE_DESC(
  73. AUTH_PARAM_HASH, SP_PKG6_HASH_OID);
  74. static auth_param_type_desc_t sp_pkg7_hash = AUTH_PARAM_TYPE_DESC(
  75. AUTH_PARAM_HASH, SP_PKG7_HASH_OID);
  76. static auth_param_type_desc_t sp_pkg8_hash = AUTH_PARAM_TYPE_DESC(
  77. AUTH_PARAM_HASH, SP_PKG8_HASH_OID);
  78. #endif /* SPD_spmd */
  79. /*
  80. * Trusted key certificate
  81. */
  82. static const auth_img_desc_t trusted_key_cert = {
  83. .img_id = TRUSTED_KEY_CERT_ID,
  84. .img_type = IMG_CERT,
  85. .parent = NULL,
  86. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  87. [0] = {
  88. .type = AUTH_METHOD_SIG,
  89. .param.sig = {
  90. .pk = &subject_pk,
  91. .sig = &sig,
  92. .alg = &sig_alg,
  93. .data = &raw_data
  94. }
  95. },
  96. [1] = {
  97. .type = AUTH_METHOD_NV_CTR,
  98. .param.nv_ctr = {
  99. .cert_nv_ctr = &trusted_nv_ctr,
  100. .plat_nv_ctr = &trusted_nv_ctr
  101. }
  102. }
  103. },
  104. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  105. [0] = {
  106. .type_desc = &trusted_world_pk,
  107. .data = {
  108. .ptr = (void *)trusted_world_pk_buf,
  109. .len = (unsigned int)PK_DER_LEN
  110. }
  111. },
  112. [1] = {
  113. .type_desc = &non_trusted_world_pk,
  114. .data = {
  115. .ptr = (void *)non_trusted_world_pk_buf,
  116. .len = (unsigned int)PK_DER_LEN
  117. }
  118. }
  119. }
  120. };
  121. /*
  122. * SCP Firmware
  123. */
  124. static const auth_img_desc_t scp_fw_key_cert = {
  125. .img_id = SCP_FW_KEY_CERT_ID,
  126. .img_type = IMG_CERT,
  127. .parent = &trusted_key_cert,
  128. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  129. [0] = {
  130. .type = AUTH_METHOD_SIG,
  131. .param.sig = {
  132. .pk = &trusted_world_pk,
  133. .sig = &sig,
  134. .alg = &sig_alg,
  135. .data = &raw_data
  136. }
  137. },
  138. [1] = {
  139. .type = AUTH_METHOD_NV_CTR,
  140. .param.nv_ctr = {
  141. .cert_nv_ctr = &trusted_nv_ctr,
  142. .plat_nv_ctr = &trusted_nv_ctr
  143. }
  144. }
  145. },
  146. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  147. [0] = {
  148. .type_desc = &scp_fw_content_pk,
  149. .data = {
  150. .ptr = (void *)content_pk_buf,
  151. .len = (unsigned int)PK_DER_LEN
  152. }
  153. }
  154. }
  155. };
  156. static const auth_img_desc_t scp_fw_content_cert = {
  157. .img_id = SCP_FW_CONTENT_CERT_ID,
  158. .img_type = IMG_CERT,
  159. .parent = &scp_fw_key_cert,
  160. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  161. [0] = {
  162. .type = AUTH_METHOD_SIG,
  163. .param.sig = {
  164. .pk = &scp_fw_content_pk,
  165. .sig = &sig,
  166. .alg = &sig_alg,
  167. .data = &raw_data
  168. }
  169. },
  170. [1] = {
  171. .type = AUTH_METHOD_NV_CTR,
  172. .param.nv_ctr = {
  173. .cert_nv_ctr = &trusted_nv_ctr,
  174. .plat_nv_ctr = &trusted_nv_ctr
  175. }
  176. }
  177. },
  178. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  179. [0] = {
  180. .type_desc = &scp_fw_hash,
  181. .data = {
  182. .ptr = (void *)scp_fw_hash_buf,
  183. .len = (unsigned int)HASH_DER_LEN
  184. }
  185. }
  186. }
  187. };
  188. static const auth_img_desc_t scp_bl2_image = {
  189. .img_id = SCP_BL2_IMAGE_ID,
  190. .img_type = IMG_RAW,
  191. .parent = &scp_fw_content_cert,
  192. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  193. [0] = {
  194. .type = AUTH_METHOD_HASH,
  195. .param.hash = {
  196. .data = &raw_data,
  197. .hash = &scp_fw_hash
  198. }
  199. }
  200. }
  201. };
  202. /*
  203. * SoC Firmware
  204. */
  205. static const auth_img_desc_t soc_fw_key_cert = {
  206. .img_id = SOC_FW_KEY_CERT_ID,
  207. .img_type = IMG_CERT,
  208. .parent = &trusted_key_cert,
  209. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  210. [0] = {
  211. .type = AUTH_METHOD_SIG,
  212. .param.sig = {
  213. .pk = &trusted_world_pk,
  214. .sig = &sig,
  215. .alg = &sig_alg,
  216. .data = &raw_data
  217. }
  218. },
  219. [1] = {
  220. .type = AUTH_METHOD_NV_CTR,
  221. .param.nv_ctr = {
  222. .cert_nv_ctr = &trusted_nv_ctr,
  223. .plat_nv_ctr = &trusted_nv_ctr
  224. }
  225. }
  226. },
  227. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  228. [0] = {
  229. .type_desc = &soc_fw_content_pk,
  230. .data = {
  231. .ptr = (void *)content_pk_buf,
  232. .len = (unsigned int)PK_DER_LEN
  233. }
  234. }
  235. }
  236. };
  237. static const auth_img_desc_t soc_fw_content_cert = {
  238. .img_id = SOC_FW_CONTENT_CERT_ID,
  239. .img_type = IMG_CERT,
  240. .parent = &soc_fw_key_cert,
  241. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  242. [0] = {
  243. .type = AUTH_METHOD_SIG,
  244. .param.sig = {
  245. .pk = &soc_fw_content_pk,
  246. .sig = &sig,
  247. .alg = &sig_alg,
  248. .data = &raw_data
  249. }
  250. },
  251. [1] = {
  252. .type = AUTH_METHOD_NV_CTR,
  253. .param.nv_ctr = {
  254. .cert_nv_ctr = &trusted_nv_ctr,
  255. .plat_nv_ctr = &trusted_nv_ctr
  256. }
  257. }
  258. },
  259. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  260. [0] = {
  261. .type_desc = &soc_fw_hash,
  262. .data = {
  263. .ptr = (void *)soc_fw_hash_buf,
  264. .len = (unsigned int)HASH_DER_LEN
  265. }
  266. },
  267. [1] = {
  268. .type_desc = &soc_fw_config_hash,
  269. .data = {
  270. .ptr = (void *)soc_fw_config_hash_buf,
  271. .len = (unsigned int)HASH_DER_LEN
  272. }
  273. }
  274. }
  275. };
  276. static const auth_img_desc_t bl31_image = {
  277. .img_id = BL31_IMAGE_ID,
  278. .img_type = IMG_RAW,
  279. .parent = &soc_fw_content_cert,
  280. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  281. [0] = {
  282. .type = AUTH_METHOD_HASH,
  283. .param.hash = {
  284. .data = &raw_data,
  285. .hash = &soc_fw_hash
  286. }
  287. }
  288. }
  289. };
  290. /* SOC FW Config */
  291. static const auth_img_desc_t soc_fw_config = {
  292. .img_id = SOC_FW_CONFIG_ID,
  293. .img_type = IMG_RAW,
  294. .parent = &soc_fw_content_cert,
  295. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  296. [0] = {
  297. .type = AUTH_METHOD_HASH,
  298. .param.hash = {
  299. .data = &raw_data,
  300. .hash = &soc_fw_config_hash
  301. }
  302. }
  303. }
  304. };
  305. /*
  306. * Trusted OS Firmware
  307. */
  308. static const auth_img_desc_t trusted_os_fw_key_cert = {
  309. .img_id = TRUSTED_OS_FW_KEY_CERT_ID,
  310. .img_type = IMG_CERT,
  311. .parent = &trusted_key_cert,
  312. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  313. [0] = {
  314. .type = AUTH_METHOD_SIG,
  315. .param.sig = {
  316. .pk = &trusted_world_pk,
  317. .sig = &sig,
  318. .alg = &sig_alg,
  319. .data = &raw_data
  320. }
  321. },
  322. [1] = {
  323. .type = AUTH_METHOD_NV_CTR,
  324. .param.nv_ctr = {
  325. .cert_nv_ctr = &trusted_nv_ctr,
  326. .plat_nv_ctr = &trusted_nv_ctr
  327. }
  328. }
  329. },
  330. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  331. [0] = {
  332. .type_desc = &tos_fw_content_pk,
  333. .data = {
  334. .ptr = (void *)content_pk_buf,
  335. .len = (unsigned int)PK_DER_LEN
  336. }
  337. }
  338. }
  339. };
  340. static const auth_img_desc_t trusted_os_fw_content_cert = {
  341. .img_id = TRUSTED_OS_FW_CONTENT_CERT_ID,
  342. .img_type = IMG_CERT,
  343. .parent = &trusted_os_fw_key_cert,
  344. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  345. [0] = {
  346. .type = AUTH_METHOD_SIG,
  347. .param.sig = {
  348. .pk = &tos_fw_content_pk,
  349. .sig = &sig,
  350. .alg = &sig_alg,
  351. .data = &raw_data
  352. }
  353. },
  354. [1] = {
  355. .type = AUTH_METHOD_NV_CTR,
  356. .param.nv_ctr = {
  357. .cert_nv_ctr = &trusted_nv_ctr,
  358. .plat_nv_ctr = &trusted_nv_ctr
  359. }
  360. }
  361. },
  362. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  363. [0] = {
  364. .type_desc = &tos_fw_hash,
  365. .data = {
  366. .ptr = (void *)tos_fw_hash_buf,
  367. .len = (unsigned int)HASH_DER_LEN
  368. }
  369. },
  370. [1] = {
  371. .type_desc = &tos_fw_extra1_hash,
  372. .data = {
  373. .ptr = (void *)tos_fw_extra1_hash_buf,
  374. .len = (unsigned int)HASH_DER_LEN
  375. }
  376. },
  377. [2] = {
  378. .type_desc = &tos_fw_extra2_hash,
  379. .data = {
  380. .ptr = (void *)tos_fw_extra2_hash_buf,
  381. .len = (unsigned int)HASH_DER_LEN
  382. }
  383. },
  384. [3] = {
  385. .type_desc = &tos_fw_config_hash,
  386. .data = {
  387. .ptr = (void *)tos_fw_config_hash_buf,
  388. .len = (unsigned int)HASH_DER_LEN
  389. }
  390. }
  391. }
  392. };
  393. static const auth_img_desc_t bl32_image = {
  394. .img_id = BL32_IMAGE_ID,
  395. .img_type = IMG_RAW,
  396. .parent = &trusted_os_fw_content_cert,
  397. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  398. [0] = {
  399. .type = AUTH_METHOD_HASH,
  400. .param.hash = {
  401. .data = &raw_data,
  402. .hash = &tos_fw_hash
  403. }
  404. }
  405. }
  406. };
  407. static const auth_img_desc_t bl32_extra1_image = {
  408. .img_id = BL32_EXTRA1_IMAGE_ID,
  409. .img_type = IMG_RAW,
  410. .parent = &trusted_os_fw_content_cert,
  411. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  412. [0] = {
  413. .type = AUTH_METHOD_HASH,
  414. .param.hash = {
  415. .data = &raw_data,
  416. .hash = &tos_fw_extra1_hash
  417. }
  418. }
  419. }
  420. };
  421. static const auth_img_desc_t bl32_extra2_image = {
  422. .img_id = BL32_EXTRA2_IMAGE_ID,
  423. .img_type = IMG_RAW,
  424. .parent = &trusted_os_fw_content_cert,
  425. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  426. [0] = {
  427. .type = AUTH_METHOD_HASH,
  428. .param.hash = {
  429. .data = &raw_data,
  430. .hash = &tos_fw_extra2_hash
  431. }
  432. }
  433. }
  434. };
  435. /* TOS FW Config */
  436. static const auth_img_desc_t tos_fw_config = {
  437. .img_id = TOS_FW_CONFIG_ID,
  438. .img_type = IMG_RAW,
  439. .parent = &trusted_os_fw_content_cert,
  440. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  441. [0] = {
  442. .type = AUTH_METHOD_HASH,
  443. .param.hash = {
  444. .data = &raw_data,
  445. .hash = &tos_fw_config_hash
  446. }
  447. }
  448. }
  449. };
  450. /*
  451. * Non-Trusted Firmware
  452. */
  453. static const auth_img_desc_t non_trusted_fw_key_cert = {
  454. .img_id = NON_TRUSTED_FW_KEY_CERT_ID,
  455. .img_type = IMG_CERT,
  456. .parent = &trusted_key_cert,
  457. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  458. [0] = {
  459. .type = AUTH_METHOD_SIG,
  460. .param.sig = {
  461. .pk = &non_trusted_world_pk,
  462. .sig = &sig,
  463. .alg = &sig_alg,
  464. .data = &raw_data
  465. }
  466. },
  467. [1] = {
  468. .type = AUTH_METHOD_NV_CTR,
  469. .param.nv_ctr = {
  470. .cert_nv_ctr = &non_trusted_nv_ctr,
  471. .plat_nv_ctr = &non_trusted_nv_ctr
  472. }
  473. }
  474. },
  475. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  476. [0] = {
  477. .type_desc = &nt_fw_content_pk,
  478. .data = {
  479. .ptr = (void *)content_pk_buf,
  480. .len = (unsigned int)PK_DER_LEN
  481. }
  482. }
  483. }
  484. };
  485. static const auth_img_desc_t non_trusted_fw_content_cert = {
  486. .img_id = NON_TRUSTED_FW_CONTENT_CERT_ID,
  487. .img_type = IMG_CERT,
  488. .parent = &non_trusted_fw_key_cert,
  489. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  490. [0] = {
  491. .type = AUTH_METHOD_SIG,
  492. .param.sig = {
  493. .pk = &nt_fw_content_pk,
  494. .sig = &sig,
  495. .alg = &sig_alg,
  496. .data = &raw_data
  497. }
  498. },
  499. [1] = {
  500. .type = AUTH_METHOD_NV_CTR,
  501. .param.nv_ctr = {
  502. .cert_nv_ctr = &non_trusted_nv_ctr,
  503. .plat_nv_ctr = &non_trusted_nv_ctr
  504. }
  505. }
  506. },
  507. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  508. [0] = {
  509. .type_desc = &nt_world_bl_hash,
  510. .data = {
  511. .ptr = (void *)nt_world_bl_hash_buf,
  512. .len = (unsigned int)HASH_DER_LEN
  513. }
  514. },
  515. [1] = {
  516. .type_desc = &nt_fw_config_hash,
  517. .data = {
  518. .ptr = (void *)nt_fw_config_hash_buf,
  519. .len = (unsigned int)HASH_DER_LEN
  520. }
  521. }
  522. }
  523. };
  524. static const auth_img_desc_t bl33_image = {
  525. .img_id = BL33_IMAGE_ID,
  526. .img_type = IMG_RAW,
  527. .parent = &non_trusted_fw_content_cert,
  528. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  529. [0] = {
  530. .type = AUTH_METHOD_HASH,
  531. .param.hash = {
  532. .data = &raw_data,
  533. .hash = &nt_world_bl_hash
  534. }
  535. }
  536. }
  537. };
  538. /* NT FW Config */
  539. static const auth_img_desc_t nt_fw_config = {
  540. .img_id = NT_FW_CONFIG_ID,
  541. .img_type = IMG_RAW,
  542. .parent = &non_trusted_fw_content_cert,
  543. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  544. [0] = {
  545. .type = AUTH_METHOD_HASH,
  546. .param.hash = {
  547. .data = &raw_data,
  548. .hash = &nt_fw_config_hash
  549. }
  550. }
  551. }
  552. };
  553. /* Secure Partitions */
  554. #if defined(SPD_spmd)
  555. static const auth_img_desc_t sip_sp_content_cert = {
  556. .img_id = SIP_SP_CONTENT_CERT_ID,
  557. .img_type = IMG_CERT,
  558. .parent = &trusted_key_cert,
  559. .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
  560. [0] = {
  561. .type = AUTH_METHOD_SIG,
  562. .param.sig = {
  563. .pk = &trusted_world_pk,
  564. .sig = &sig,
  565. .alg = &sig_alg,
  566. .data = &raw_data
  567. }
  568. },
  569. [1] = {
  570. .type = AUTH_METHOD_NV_CTR,
  571. .param.nv_ctr = {
  572. .cert_nv_ctr = &trusted_nv_ctr,
  573. .plat_nv_ctr = &trusted_nv_ctr
  574. }
  575. }
  576. },
  577. .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
  578. [0] = {
  579. .type_desc = &sp_pkg1_hash,
  580. .data = {
  581. .ptr = (void *)sp_pkg_hash_buf[0],
  582. .len = (unsigned int)HASH_DER_LEN
  583. }
  584. },
  585. [1] = {
  586. .type_desc = &sp_pkg2_hash,
  587. .data = {
  588. .ptr = (void *)sp_pkg_hash_buf[1],
  589. .len = (unsigned int)HASH_DER_LEN
  590. }
  591. },
  592. [2] = {
  593. .type_desc = &sp_pkg3_hash,
  594. .data = {
  595. .ptr = (void *)sp_pkg_hash_buf[2],
  596. .len = (unsigned int)HASH_DER_LEN
  597. }
  598. },
  599. [3] = {
  600. .type_desc = &sp_pkg4_hash,
  601. .data = {
  602. .ptr = (void *)sp_pkg_hash_buf[3],
  603. .len = (unsigned int)HASH_DER_LEN
  604. }
  605. },
  606. [4] = {
  607. .type_desc = &sp_pkg5_hash,
  608. .data = {
  609. .ptr = (void *)sp_pkg_hash_buf[4],
  610. .len = (unsigned int)HASH_DER_LEN
  611. }
  612. },
  613. [5] = {
  614. .type_desc = &sp_pkg6_hash,
  615. .data = {
  616. .ptr = (void *)sp_pkg_hash_buf[5],
  617. .len = (unsigned int)HASH_DER_LEN
  618. }
  619. },
  620. [6] = {
  621. .type_desc = &sp_pkg7_hash,
  622. .data = {
  623. .ptr = (void *)sp_pkg_hash_buf[6],
  624. .len = (unsigned int)HASH_DER_LEN
  625. }
  626. },
  627. [7] = {
  628. .type_desc = &sp_pkg8_hash,
  629. .data = {
  630. .ptr = (void *)sp_pkg_hash_buf[7],
  631. .len = (unsigned int)HASH_DER_LEN
  632. }
  633. }
  634. }
  635. };
  636. DEFINE_SIP_SP_PKG(1);
  637. DEFINE_SIP_SP_PKG(2);
  638. DEFINE_SIP_SP_PKG(3);
  639. DEFINE_SIP_SP_PKG(4);
  640. DEFINE_SIP_SP_PKG(5);
  641. DEFINE_SIP_SP_PKG(6);
  642. DEFINE_SIP_SP_PKG(7);
  643. DEFINE_SIP_SP_PKG(8);
  644. #endif /* SPD_spmd */
  645. static const auth_img_desc_t * const cot_desc[] = {
  646. [TRUSTED_BOOT_FW_CERT_ID] = &trusted_boot_fw_cert,
  647. [HW_CONFIG_ID] = &hw_config,
  648. [TRUSTED_KEY_CERT_ID] = &trusted_key_cert,
  649. [SCP_FW_KEY_CERT_ID] = &scp_fw_key_cert,
  650. [SCP_FW_CONTENT_CERT_ID] = &scp_fw_content_cert,
  651. [SCP_BL2_IMAGE_ID] = &scp_bl2_image,
  652. [SOC_FW_KEY_CERT_ID] = &soc_fw_key_cert,
  653. [SOC_FW_CONTENT_CERT_ID] = &soc_fw_content_cert,
  654. [BL31_IMAGE_ID] = &bl31_image,
  655. [SOC_FW_CONFIG_ID] = &soc_fw_config,
  656. [TRUSTED_OS_FW_KEY_CERT_ID] = &trusted_os_fw_key_cert,
  657. [TRUSTED_OS_FW_CONTENT_CERT_ID] = &trusted_os_fw_content_cert,
  658. [BL32_IMAGE_ID] = &bl32_image,
  659. [BL32_EXTRA1_IMAGE_ID] = &bl32_extra1_image,
  660. [BL32_EXTRA2_IMAGE_ID] = &bl32_extra2_image,
  661. [TOS_FW_CONFIG_ID] = &tos_fw_config,
  662. [NON_TRUSTED_FW_KEY_CERT_ID] = &non_trusted_fw_key_cert,
  663. [NON_TRUSTED_FW_CONTENT_CERT_ID] = &non_trusted_fw_content_cert,
  664. [BL33_IMAGE_ID] = &bl33_image,
  665. [NT_FW_CONFIG_ID] = &nt_fw_config,
  666. #if defined(SPD_spmd)
  667. [SIP_SP_CONTENT_CERT_ID] = &sip_sp_content_cert,
  668. [SP_PKG1_ID] = &sp_pkg1,
  669. [SP_PKG2_ID] = &sp_pkg2,
  670. [SP_PKG3_ID] = &sp_pkg3,
  671. [SP_PKG4_ID] = &sp_pkg4,
  672. [SP_PKG5_ID] = &sp_pkg5,
  673. [SP_PKG6_ID] = &sp_pkg6,
  674. [SP_PKG7_ID] = &sp_pkg7,
  675. [SP_PKG8_ID] = &sp_pkg8,
  676. #endif
  677. };
  678. /* Register the CoT in the authentication module */
  679. REGISTER_COT(cot_desc);