tme_hwkm_master_defs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef _TME_HWKM_MASTER_DEFS_H_
  6. #define _TME_HWKM_MASTER_DEFS_H_
  7. #include <linux/types.h>
  8. #define UINT32_C(x) (x ## U)
  9. /**
  10. * Key ID
  11. */
  12. /* L1 Key IDs that are Key Table slot numbers */
  13. /**< CUS, 512 bits, in fuses */
  14. #define TME_KID_CHIP_UNIQUE_SEED 8
  15. /**< CRBK, 512 bits, in fuses */
  16. #define TME_KID_CHIP_RAND_BASE 9
  17. /**< L1 Key derived from L0 slot numbers 0-3 or 4-7 */
  18. #define TME_KID_CHIP_FAM_L1 10
  19. /* Transport Key ID */
  20. #define TME_KID_TP 11/**< 528 bits, retained */
  21. /**
  22. * KeyPolicy
  23. */
  24. /** Key Policy: 64-bit integer with bit encoded values */
  25. struct tme_key_policy {
  26. uint32_t low;
  27. uint32_t high;
  28. } __packed;
  29. #define TME_KPHALFBITS 32
  30. #define TME_KPCOMBINE(lo32, hi32) (((uint64_t)(lo32)) | \
  31. (((uint64_t)(hi32)) << TME_KPHALFBITS))
  32. /**
  33. * Fields in Key Policy low word
  34. */
  35. /** Key Type: Fundamental crypto algorithm groups */
  36. /**< Position of Key Type bits */
  37. #define TME_KT_Shift 0
  38. /**< Mask for Key Type bits */
  39. #define TME_KT_Mask (UINT32_C(0x07) << TME_KT_Shift)
  40. /**< Symmetric algorithms */
  41. #define TME_KT_Symmetric (UINT32_C(0x00) << TME_KT_Shift)
  42. /**< Asymmetric algorithms: ECC */
  43. #define TME_KT_Asymmetric_ECC (UINT32_C(0x01) << TME_KT_Shift)
  44. /**< Asymmetric algorithms: RSA */
  45. #define TME_KT_Asymmetric_RSA (UINT32_C(0x05) << TME_KT_Shift)
  46. /** Key Length */
  47. /**< Position of Key Length bits */
  48. #define TME_KL_Shift 3
  49. /**< Mask for Key Length bits */
  50. #define TME_KL_Mask (UINT32_C(0x0F) << TME_KL_Shift)
  51. /**< 64 bits - AES/2TDES */
  52. #define TME_KL_64 (UINT32_C(0x00) << TME_KL_Shift)
  53. /**< 128 bits - AES/2TDES */
  54. #define TME_KL_128 (UINT32_C(0x01) << TME_KL_Shift)
  55. /**< 192 bits - AES/3TDES */
  56. #define TME_KL_192 (UINT32_C(0x02) << TME_KL_Shift)
  57. /**< 224 bits - ECDSA */
  58. #define TME_KL_224 (UINT32_C(0x03) << TME_KL_Shift)
  59. /**< 256 bits - ECDSA/AES */
  60. #define TME_KL_256 (UINT32_C(0x04) << TME_KL_Shift)
  61. /**< 384 bits - ECDSA */
  62. #define TME_KL_384 (UINT32_C(0x05) << TME_KL_Shift)
  63. /**< 448 bits - ECDSA */
  64. #define TME_KL_448 (UINT32_C(0x06) << TME_KL_Shift)
  65. /**< 512 bits - ECDSA/HMAC/KDF/AES-SIV/AES-XTS */
  66. #define TME_KL_512 (UINT32_C(0x07) << TME_KL_Shift)
  67. /**< 521 bits - ECDSA/HMAC/KDF */
  68. #define TME_KL_521 (UINT32_C(0x08) << TME_KL_Shift)
  69. /**< 2048 bits - RSA */
  70. #define TME_KL_2048 (UINT32_C(0x09) << TME_KL_Shift)
  71. /**< 3072 bits - RSA */
  72. #define TME_KL_3072 (UINT32_C(0x0A) << TME_KL_Shift)
  73. /**< 4096 bits - RSA */
  74. #define TME_KL_4096 (UINT32_C(0x0B) << TME_KL_Shift)
  75. /**< 456 bits - Ed448 */
  76. #define TME_KL_456 (UINT32_C(0x0C) << TME_KL_Shift)
  77. /**
  78. * Key Profile: Only applicable at present
  79. * if Key Type is #TME_KT_Symmetric
  80. */
  81. /**< Position of Key Profile bits */
  82. #define TME_KP_Shift 7
  83. /**< Mask for Key Class bits */
  84. #define TME_KP_Mask (UINT32_C(0x07) << TME_KP_Shift)
  85. /**< If Key Type is #TME_KT_Symmetric */
  86. #define TME_KP_Generic (UINT32_C(0x00) << TME_KP_Shift)
  87. /**< If Key Type is #TME_KT_Symmetric (aka KDK) */
  88. #define TME_KP_KeyDerivation (UINT32_C(0x01) << TME_KP_Shift)
  89. /**< If Key Type is #TME_KT_Symmetric (aka KWK) */
  90. #define TME_KP_KWK_STORAGE (UINT32_C(0x02) << TME_KP_Shift)
  91. /**< If Key Type is #TME_KT_Symmetric (aka KSK) */
  92. #define TME_KP_KWK_SESSION (UINT32_C(0x03) << TME_KP_Shift)
  93. /**< If Key Type is #TME_KT_Symmetric (aka TPK) */
  94. #define TME_KP_KWK_TRANSPORT (UINT32_C(0x04) << TME_KP_Shift)
  95. /**< If Key Type is #TME_KT_Symmetric */
  96. #define TME_KP_KWK_XPORT (UINT32_C(0x05) << TME_KP_Shift)
  97. /**< If Key Type is not #TME_KT_Symmetric */
  98. #define TME_KP_Unused (UINT32_C(0x00) << TME_KP_Shift)
  99. /** Key Operation: Crypto operations permitted for a key */
  100. /**< Position of Key Operation bits */
  101. #define TME_KOP_Shift 10
  102. /**< Mask for Key Operation bits */
  103. #define TME_KOP_Mask (UINT32_C(0x0F) << TME_KOP_Shift)
  104. /**< If Key Type is #TME_KT_Symmetric */
  105. #define TME_KOP_Encryption (UINT32_C(0x01) << TME_KOP_Shift)
  106. /**< If Key Type is #TME_KT_Symmetric */
  107. #define TME_KOP_Decryption (UINT32_C(0x02) << TME_KOP_Shift)
  108. /**< If Key Type is #TME_KT_Symmetric */
  109. #define TME_KOP_Digest (UINT32_C(0x04) << TME_KOP_Shift)
  110. /**< If Key Type is #TME_KT_Symmetric */
  111. #define TME_KOP_CMAC_Sign (UINT32_C(0x0D) << TME_KOP_Shift)
  112. /**< If Key Type is #TME_KT_Symmetric */
  113. #define TME_KOP_CMAC_Verify (UINT32_C(0x0E) << TME_KOP_Shift)
  114. /**< If Key Type is #TME_KT_Symmetric */
  115. #define TME_KOP_NISTDerive (UINT32_C(0x04) << TME_KOP_Shift)
  116. /**< If Key Type is #TME_KT_Symmetric */
  117. #define TME_KOP_HKDFExtract (UINT32_C(0x08) << TME_KOP_Shift)
  118. /**< If Key Type is #TME_KT_Symmetric */
  119. #define TME_KOP_HKDFExpand (UINT32_C(0x09) << TME_KOP_Shift)
  120. /**< If Key Type is #TME_KT_Asymmetric_ECC */
  121. #define TME_KOP_ECDSASign (UINT32_C(0x01) << TME_KOP_Shift)
  122. /**< If Key Type is #TME_KT_Asymmetric_ECC */
  123. #define TME_KOP_ECDHSharedSecret (UINT32_C(0x02) << TME_KOP_Shift)
  124. /**< If Key Type is #TME_KT_Asymmetric_RSA */
  125. #define TME_KOP_RSAASign (UINT32_C(0x01) << TME_KOP_Shift)
  126. /**< If Key Type is #TME_KT_Asymmetric_RSA */
  127. #define TME_KOP_RSAAVerify (UINT32_C(0x02) << TME_KOP_Shift)
  128. /**< If Key Type is #TME_KT_Asymmetric_RSA */
  129. #define TME_KOP_RSAEnc (UINT32_C(0x04) << TME_KOP_Shift)
  130. /**< If Key Type is #TME_KT_Asymmetric_RSA */
  131. #define TME_KOP_RSADec (UINT32_C(0x08) << TME_KOP_Shift)
  132. /**< If Key Type is #TME_KT_Asymmetric */
  133. #define TME_KOP_SM2Enc (UINT32_C(0x04) << TME_KOP_Shift)
  134. /**< If Key Type is #TME_KT_Asymmetric */
  135. #define TME_KOP_SM2Dec (UINT32_C(0x08) << TME_KOP_Shift)
  136. /** Key Algorithm */
  137. /**< Position of Key Algorithm bits */
  138. #define TME_KAL_Shift 14
  139. /**< Mask for Key Algorithm bits */
  140. #define TME_KAL_Mask (UINT32_C(0x3F) << TME_KAL_Shift)
  141. /**< If Key Type is #TME_KT_Symmetric */
  142. #define TME_KAL_AES128_ECB (UINT32_C(0x00) << TME_KAL_Shift)
  143. #define TME_KAL_AES256_ECB (UINT32_C(0x01) << TME_KAL_Shift)
  144. #define TME_KAL_DES_ECB (UINT32_C(0x02) << TME_KAL_Shift)
  145. #define TME_KAL_TDES_ECB (UINT32_C(0x03) << TME_KAL_Shift)
  146. #define TME_KAL_AES128_CBC (UINT32_C(0x04) << TME_KAL_Shift)
  147. #define TME_KAL_AES256_CBC (UINT32_C(0x05) << TME_KAL_Shift)
  148. #define TME_KAL_DES_CBC (UINT32_C(0x06) << TME_KAL_Shift)
  149. #define TME_KAL_TDES_CBC (UINT32_C(0x07) << TME_KAL_Shift)
  150. #define TME_KAL_AES128_CCM_TC (UINT32_C(0x08) << TME_KAL_Shift)
  151. #define TME_KAL_AES128_CCM_NTC (UINT32_C(0x09) << TME_KAL_Shift)
  152. #define TME_KAL_AES256_CCM_TC (UINT32_C(0x0A) << TME_KAL_Shift)
  153. #define TME_KAL_AES256_CCM_NTC (UINT32_C(0x0B) << TME_KAL_Shift)
  154. #define TME_KAL_AES256_SIV (UINT32_C(0x0C) << TME_KAL_Shift)
  155. #define TME_KAL_AES128_CTR (UINT32_C(0x0D) << TME_KAL_Shift)
  156. #define TME_KAL_AES256_CTR (UINT32_C(0x0E) << TME_KAL_Shift)
  157. #define TME_KAL_AES128_XTS (UINT32_C(0x0F) << TME_KAL_Shift)
  158. #define TME_KAL_AES256_XTS (UINT32_C(0x10) << TME_KAL_Shift)
  159. #define TME_KAL_SHA1_HMAC (UINT32_C(0x11) << TME_KAL_Shift)
  160. #define TME_KAL_SHA256_HMAC (UINT32_C(0x12) << TME_KAL_Shift)
  161. #define TME_KAL_AES128_CMAC (UINT32_C(0x13) << TME_KAL_Shift)
  162. #define TME_KAL_AES256_CMAC (UINT32_C(0x14) << TME_KAL_Shift)
  163. #define TME_KAL_SHA384_HMAC (UINT32_C(0x15) << TME_KAL_Shift)
  164. #define TME_KAL_SHA512_HMAC (UINT32_C(0x16) << TME_KAL_Shift)
  165. #define TME_KAL_AES128_GCM (UINT32_C(0x17) << TME_KAL_Shift)
  166. #define TME_KAL_AES256_GCM (UINT32_C(0x18) << TME_KAL_Shift)
  167. #define TME_KAL_KASUMI (UINT32_C(0x19) << TME_KAL_Shift)
  168. #define TME_KAL_SNOW3G (UINT32_C(0x1A) << TME_KAL_Shift)
  169. #define TME_KAL_ZUC (UINT32_C(0x1B) << TME_KAL_Shift)
  170. #define TME_KAL_PRINCE (UINT32_C(0x1C) << TME_KAL_Shift)
  171. #define TME_KAL_SIPHASH (UINT32_C(0x1D) << TME_KAL_Shift)
  172. #define TME_KAL_TDES_2KEY_CBC (UINT32_C(0x1E) << TME_KAL_Shift)
  173. #define TME_KAL_TDES_2KEY_ECB (UINT32_C(0x1F) << TME_KAL_Shift)
  174. #define TME_KAL_KDF_NIST (UINT32_C(0x20) << TME_KAL_Shift)
  175. #define TME_KAL_KDF_HKDF (UINT32_C(0x21) << TME_KAL_Shift)
  176. #define TME_KAL_SHA3224_HMAC (UINT32_C(0x28) << TME_KAL_Shift)
  177. #define TME_KAL_SHA3256_HMAC (UINT32_C(0x29) << TME_KAL_Shift)
  178. #define TME_KAL_SHA3384_HMAC (UINT32_C(0x2A) << TME_KAL_Shift)
  179. #define TME_KAL_SHA3512_HMAC (UINT32_C(0x2B) << TME_KAL_Shift)
  180. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  181. #define TME_KAL_ECC_ALGO_ECDSA (UINT32_C(0x00) << TME_KAL_Shift)
  182. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  183. #define TME_KAL_ECC_ALGO_ECDH (UINT32_C(0x01) << TME_KAL_Shift)
  184. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  185. #define TME_KAL_ECC_ALGO_EdDSA (UINT32_C(0x02) << TME_KAL_Shift)
  186. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  187. #define TME_KAL_ECC_ALGO_SM2DSA (UINT32_C(0x04) << TME_KAL_Shift)
  188. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  189. #define TME_KAL_ECC_CURVE_NIST (UINT32_C(0x00) << TME_KAL_Shift)
  190. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  191. #define TME_KAL_ECC_CURVE_BPOOL (UINT32_C(0x08) << TME_KAL_Shift)
  192. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  193. #define TME_KAL_ECC_CURVE_SM2 (UINT32_C(0x10) << TME_KAL_Shift)
  194. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is ECC */
  195. #define TME_KAL_ECC_CURVE_Ed25519 (UINT32_C(0x18) << TME_KAL_Shift)
  196. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is RSA */
  197. #define TME_KAL_DSA (UINT32_C(0x00) << TME_KAL_Shift)
  198. /**< If Key Type is #TME_KT_Asymmetric, Key Subtype is RSA */
  199. #define TME_KAL_DH (UINT32_C(0x01) << TME_KAL_Shift)
  200. /** Key Security Level */
  201. /**< Position of Key Security Level bits */
  202. #define TME_KSL_Shift 20
  203. /**< Mask for Key Security Level bits */
  204. #define TME_KSL_Mask (UINT32_C(0x03) << TME_KSL_Shift)
  205. /**< Software Key */
  206. #define TME_KSL_SWKey (UINT32_C(0x00) << TME_KSL_Shift)
  207. /**< Hardware Managed Key */
  208. #define TME_KSL_ImportKey (UINT32_C(0x01) << TME_KSL_Shift)
  209. /**< Hardware Key */
  210. #define TME_KSL_HWKey (UINT32_C(0x02) << TME_KSL_Shift)
  211. /** Key Destination */
  212. /**< Position of Key Destination bits */
  213. #define TME_KD_Shift_V3 22
  214. /**< Mask for Key Destination bits */
  215. #define TME_KD_Mask_V3 (UINT32_C(0x0F) << TME_KD_Shift_V3)
  216. /**< Master */
  217. #define TME_KD_TME_HW_V3 (UINT32_C(0x01) << TME_KD_Shift_V3)
  218. /**< ICE Slave */
  219. #define TME_KD_ICE_V3 (UINT32_C(0x02) << TME_KD_Shift_V3)
  220. /**< GPCE Slave */
  221. #define TME_KD_GPCE_V3 (UINT32_C(0x04) << TME_KD_Shift_V3)
  222. /**< Modem CE Slave */
  223. #define TME_KD_MDM_CE_V3 (UINT32_C(0x08) << TME_KD_Shift_V3)
  224. /** Key Owner */
  225. /**< Position of Key Owner bits */
  226. #define TME_KO_Shift 26
  227. /**< Mask for Key Owner bits */
  228. #define TME_KO_Mask (UINT32_C(0x0F) << TME_KO_Shift)
  229. /**< TME Hardware */
  230. #define TME_KO_TME_HW (UINT32_C(0x00) << TME_KO_Shift)
  231. /**< TME Firmware */
  232. #define TME_KO_TME_FW (UINT32_C(0x01) << TME_KO_Shift)
  233. /**< TZ (= APPS-S) */
  234. #define TME_KO_TZ (UINT32_C(0x02) << TME_KO_Shift)
  235. /**< HLOS / HYP (= APPS-NS) */
  236. #define TME_KO_HLOS_HYP (UINT32_C(0x03) << TME_KO_Shift)
  237. /**< Modem */
  238. #define TME_KO_MDM (UINT32_C(0x04) << TME_KO_Shift)
  239. /**< QSM */
  240. #define TME_KO_QSM (UINT32_C(0x05) << TME_KO_Shift)
  241. /** Key Lineage */
  242. /**< Position of Key Lineage bits */
  243. #define TME_KLI_Shift 30
  244. /**< Mask for Key Lineage bits */
  245. #define TME_KLI_Mask (UINT32_C(0x03) << TME_KLI_Shift)
  246. /**< Not applicable */
  247. #define TME_KLI_NA (UINT32_C(0x00) << TME_KLI_Shift)
  248. /**< Not provisioned, chip unique */
  249. #define TME_KLI_NP_CU (UINT32_C(0x01) << TME_KLI_Shift)
  250. /**< Provisioned, not chip unique */
  251. #define TME_KLI_P_NCU (UINT32_C(0x02) << TME_KLI_Shift)
  252. /**< Provisioned, chip unique */
  253. #define TME_KLI_P_CU (UINT32_C(0x03) << TME_KLI_Shift)
  254. /**
  255. * Fields in Key Policy high word *
  256. */
  257. /** Key Wrapping Constraints */
  258. /**< Position of Key Attribute bits */
  259. #define TME_KWC_Shift (33 - TME_KPHALFBITS)
  260. /**< Mask for Key Attribute bits */
  261. #define TME_KWC_Mask (UINT32_C(0x0F) << TME_KWC_Shift)
  262. /**< Key is wrappable with KWK_EXPORT */
  263. #define TME_KWC_Wrappable_KXP (UINT32_C(0x01) << TME_KWC_Shift)
  264. /**< Key is wrappable with KWK_STORAGE */
  265. #define TME_KWC_Wrappable_KWK (UINT32_C(0x02) << TME_KWC_Shift)
  266. /**< Key is wrappable with KWK_TRANSPORT */
  267. #define TME_KWC_Wrappable_KTP (UINT32_C(0x04) << TME_KWC_Shift)
  268. /**< Key is wrappable with KWK_SESSION */
  269. #define TME_KWC_Wrappable_KSK (UINT32_C(0x08) << TME_KWC_Shift)
  270. /** Throttling */
  271. /**< Position of Throttling bits */
  272. #define TME_KTH_Shift (37 - TME_KPHALFBITS)
  273. /**< Mask for Throttling bits */
  274. #define TME_KTH_Mask (UINT32_C(0x01) << TME_KTH_Shift)
  275. /**< Throttling enabled */
  276. #define TME_KTH_Enabled (UINT32_C(0x01) << TME_KTH_Shift)
  277. /** Key Destination */
  278. /**< Position of Key Destination bits */
  279. #define TME_KD_Shift_V4 (38 - TME_KPHALFBITS)
  280. /**< Mask for Key Destination bits */
  281. #define TME_KD_Mask_V4 (UINT32_C(0x3F) << TME_KD_Shift_V4)
  282. /**< Master */
  283. #define TME_KD_TME_HW_V4 (UINT32_C(0x01) << TME_KD_Shift_V4)
  284. /**< ICE Slave */
  285. #define TME_KD_ICE_V4 (UINT32_C(0x02) << TME_KD_Shift_V4)
  286. /**< GPCE Slave */
  287. #define TME_KD_GPCE_V4 (UINT32_C(0x04) << TME_KD_Shift_V4)
  288. /**< Modem CE Slave */
  289. #define TME_KD_MDM_CE_V4 (UINT32_C(0x08) << TME_KD_Shift_V4)
  290. /**< TICE Slave */
  291. #define TME_KD_TICE_V4 (UINT32_C(0x10) << TME_KD_Shift_V4)
  292. /**< PCIE Slave */
  293. #define TME_KD_PCIE_V4 (UINT32_C(0x20) << TME_KD_Shift_V4)
  294. /** Key Policy Version */
  295. /**< Position of Key Policy Version bits */
  296. #define TME_KPV_Shift (44 - TME_KPHALFBITS)
  297. /**< Mask for Key Policy Version bits */
  298. #define TME_KPV_Mask (UINT32_C(0x0F) << TME_KPV_Shift)
  299. /**< Mask for Key Policy Version bits */
  300. #define TME_KPV_Version (UINT32_C(0x03) << TME_KPV_Shift)
  301. /** Key Authorised Users */
  302. /**< Position of Authorised User bits */
  303. #define TME_KAU_Shift (48 - TME_KPHALFBITS)
  304. /**< Mask for Authorised User bits */
  305. #define TME_KAU_Mask (UINT32_C(0xFFF) << TME_KAU_Shift)
  306. /**< Key usable by TME Hardware */
  307. #define TME_KAU_TME_HW (UINT32_C(0x01) << TME_KAU_Shift)
  308. /**< Key usable by TME Firmware */
  309. #define TME_KAU_TME_FW (UINT32_C(0x02) << TME_KAU_Shift)
  310. /**< Key usable by TZ (= APPS_S) */
  311. #define TME_KAU_TZ (UINT32_C(0x04) << TME_KAU_Shift)
  312. /**< Key usable by HLOS / HYP (= APPS_NS) */
  313. #define TME_KAU_HLOS_HYP (UINT32_C(0x08) << TME_KAU_Shift)
  314. /**< Key usable by Modem */
  315. #define TME_KAU_MDM (UINT32_C(0x10) << TME_KAU_Shift)
  316. /**< Key usable by QSM */
  317. #define TME_KAU_QSM (UINT32_C(0x40) << TME_KAU_Shift)
  318. /**< Key usable by APPS_NS_VM1 */
  319. #define TME_KAU_APPS_NS_VM1 (UINT32_C(0x108) << TME_KAU_Shift)
  320. /**< Key usable by APPS_NS_VM2 */
  321. #define TME_KAU_APPS_NS_VM2 (UINT32_C(0x208) << TME_KAU_Shift)
  322. /**< Key usable by APPS_NS_VM3 */
  323. #define TME_KAU_APPS_NS_VM3 (UINT32_C(0x408) << TME_KAU_Shift)
  324. /**< Key usable by APPS_NS_VM4 */
  325. #define TME_KAU_APPS_NS_VM4 (UINT32_C(0x808) << TME_KAU_Shift)
  326. /**< Key usable by all EEs */
  327. #define TME_KAU_ALL TME_KAU_Mask
  328. /**
  329. * Credentials for throttling
  330. */
  331. #define TME_CRED_SLOT_ID_NONE 0 /**< No throttling */
  332. #define TME_CRED_SLOT_ID_1 1 /**< Credential slot 1 */
  333. #define TME_CRED_SLOT_ID_2 2 /**< Credential slot 2 */
  334. /**
  335. * KDFSpec and associated structures
  336. */
  337. /** Maximum context size that can be sent to the TME, in bytes */
  338. #define TME_KDF_SW_CONTEXT_BYTES_MAX 128
  339. #define TME_KDF_SALT_LABEL_BYTES_MAX 64
  340. /**
  341. * Security info to be appended to a KDF context by the Sequencer
  342. *
  343. * These fields allow keys to be tied to specific devices, states,
  344. * OEMs, subsystems, etc.
  345. * Values are obtained by the Sequencer from hardware, such as
  346. * fuses or internal registers.
  347. */
  348. #define TME_KSC_SOCTestSignState 0x00000001 /**< (32 bits) */
  349. #define TME_KSC_SOCSecBootState 0x00000002 /**< (8 bits) */
  350. #define TME_KSC_SOCDebugState 0x00000004 /**< (8 bits) */
  351. #define TME_KSC_TMELifecycleState 0x00000008 /**< (8 bits) */
  352. #define TME_KSC_BootStageOTP 0x00000010 /**< (8 bits) */
  353. #define TME_KSC_SWContext 0x00000020 /**< (variable) */
  354. #define TME_KSC_ChildKeyPolicy 0x00000040 /**< (64 bits) */
  355. #define TME_KSC_MixingKey 0x00000080 /**< (key len) */
  356. #define TME_KSC_ChipUniqueID 0x00000100 /**< (64 bits) */
  357. #define TME_KSC_ChipDeviceNumber 0x00000200 /**< (32 bits) */
  358. #define TME_KSC_TMEPatchVer 0x00000400 /**< (512 bits) */
  359. #define TME_KSC_SOCPatchVer 0x00000800 /**< (512 bits) */
  360. #define TME_KSC_OEMID 0x00001000 /**< (16 bits) */
  361. #define TME_KSC_OEMProductID 0x00002000 /**< (16 bits) */
  362. #define TME_KSC_TMEImgSecVer 0x00004000 /**< (512 bits) */
  363. #define TME_KSC_SOCInitImgSecVer 0x00008000 /**< (512 bits) */
  364. #define TME_KSC_OEMMRCHash 0x00010000 /**< (512 bits) */
  365. #define TME_KSC_OEMProductSeed 0x00020000 /**< (128 bits) */
  366. #define TME_KSC_SeqPatchVer 0x00040000 /**< (512 bits) */
  367. #define TME_KSC_HWMeasurement1 0x00080000 /**< (512 bits) */
  368. #define TME_KSC_HWMeasurement2 0x00100000 /**< (512 bits) */
  369. #define TME_KSC_Reserved 0xFFE00000 /**< RFU */
  370. /** KDF Specification: encompasses both HKDF and NIST KDF algorithms */
  371. struct tme_kdf_spec {
  372. /* Info common to HKDF and NIST algorithms */
  373. /**< @c TME_KAL_KDF_HKDF or @c TME_KAL_KDF_NIST */
  374. uint32_t kdfalgo;
  375. /**< IKM for HKDF; IKS for NIST */
  376. uint32_t inputkey;
  377. /**< If @c TME_KSC_MixingKey set in Security Context */
  378. uint32_t mixkey;
  379. /**< If deriving a L3 key */
  380. uint32_t l2key;
  381. /**< Derived key policy */
  382. struct tme_key_policy policy;
  383. /**< Software provided context */
  384. uint8_t swcontext[TME_KDF_SW_CONTEXT_BYTES_MAX];
  385. /**< Length of @c swContext in bytes */
  386. uint32_t swcontextLength;
  387. /**< Info to be appended to @c swContext */
  388. uint32_t security_context;
  389. /**< Salt for HKDF; Label for NIST */
  390. uint8_t salt_label[TME_KDF_SALT_LABEL_BYTES_MAX];
  391. /**< Length of @c saltLabel in bytes */
  392. uint32_t salt_labelLength;
  393. /* Additional info specific to HKDF: kdfAlgo == @c KAL_KDF_HKDF */
  394. /**< PRF Digest algorithm: @c KAL_SHA256_HMAC or @c KAL_SHA512_HMAC */
  395. uint32_t prf_digest_algo;
  396. } __packed;
  397. /**
  398. * WrappedKey and associated structures
  399. */
  400. /* Maximum wrapped key context size, in bytes */
  401. /**< Cipher Text 68B, MAC 16B, KeyPolicy 8B, Nonce 8B */
  402. #define TME_WK_CONTEXT_BYTES_MAX 100
  403. struct tme_wrapped_key {
  404. /**< Wrapped key context */
  405. uint8_t key[TME_WK_CONTEXT_BYTES_MAX];
  406. /**< Length of @c key in bytes*/
  407. uint32_t length;
  408. } __packed;
  409. /**
  410. * Plain text Key and associated structures
  411. */
  412. /* Maximum plain text key size, in bytes */
  413. #define TME_PT_KEY_BYTES_MAX 68
  414. /**
  415. * Key format for intrinsically word aligned key
  416. * lengths like 128/256/384/512... bits.
  417. *
  418. * Example: 256-bit key integer representation,
  419. * Key = 0xK31 K30 K29.......K0
  420. * Byte array, key[] = {0xK31, 0xK30, 0xK29, ...., 0xK0}
  421. *
  422. *
  423. * Key format for non-word aligned key lengths like 521 bits.
  424. * The key length is rounded off to next word ie, 544 bits.
  425. *
  426. * Example: 521-bit key, Key = 0xK65 K64 K63.......K2 K1 K0
  427. * [bits 1-7 of K0 is expected to be zeros]
  428. * 544 bit integer representation, Key = 0xK65 K64 K63.......K2 K1 K0 00 00
  429. * Byte array, key[] = {0xK65, 0xK64, 0xK63, ...., 0xK2, 0xK1, 0xK0, 0x00, 0x00}
  430. *
  431. */
  432. struct tme_plaintext_key {
  433. /**< Plain text key */
  434. uint8_t key[TME_PT_KEY_BYTES_MAX];
  435. /**< Length of @c key in bytes */
  436. uint32_t length;
  437. } __packed;
  438. /**
  439. * Extended Error Information structure
  440. */
  441. struct tme_ext_err_info {
  442. /* TME FW */
  443. /**< TME FW Response status. */
  444. uint32_t tme_err_status;
  445. /* SEQ FW */
  446. /**< Contents of CSR_CMD_ERROR_STATUS */
  447. uint32_t seq_err_status;
  448. /* SEQ HW Key Policy */
  449. /**< CRYPTO_ENGINE_CRYPTO_KEY_POLICY_ERROR_STATUS0 */
  450. uint32_t seq_kp_err_status0;
  451. /**< CRYPTO_ENGINE_CRYPTO_KEY_POLICY_ERROR_STATUS1 */
  452. uint32_t seq_kp_err_status1;
  453. /**
  454. * Debug information: log/print this information
  455. * if any of the above fields is non-zero
  456. */
  457. /**< Contents of CSR_CMD_RESPONSE_STATUS */
  458. uint32_t seq_rsp_status;
  459. } __packed;
  460. #endif /* _TME_HWKM_MASTER_DEFS_H_ */