tbbr_cot_bl2.c 18 KB

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