juno_tbbr_cot_bl2.c 20 KB

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