2return_codes.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. /* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. */
  5. #ifndef VBOOT_2_RETURN_CODES_H_
  6. #define VBOOT_2_RETURN_CODES_H_
  7. /*
  8. * Return codes from verified boot functions.
  9. *
  10. * Note that other values may be passed through from vb2ex_*() calls; see
  11. * the comment for VB2_ERROR_EX below.
  12. */
  13. enum vb2_return_code {
  14. /* Success - no error */
  15. VB2_SUCCESS = 0,
  16. /*
  17. * All vboot2 error codes start at a large offset from zero, to reduce
  18. * the risk of overlap with other error codes (TPM, etc.).
  19. */
  20. VB2_ERROR_BASE = 0x10000000,
  21. /* Unknown / unspecified error */
  22. VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1,
  23. /* Mock error for testing */
  24. VB2_ERROR_MOCK,
  25. /**********************************************************************
  26. * SHA errors
  27. */
  28. VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000,
  29. /* Bad algorithm in vb2_digest_init() */
  30. VB2_ERROR_SHA_INIT_ALGORITHM,
  31. /* Bad algorithm in vb2_digest_extend() */
  32. VB2_ERROR_SHA_EXTEND_ALGORITHM,
  33. /* Bad algorithm in vb2_digest_finalize() */
  34. VB2_ERROR_SHA_FINALIZE_ALGORITHM,
  35. /* Digest size buffer too small in vb2_digest_finalize() */
  36. VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE,
  37. /**********************************************************************
  38. * RSA errors
  39. */
  40. VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000,
  41. /* Padding mismatch in vb2_check_padding() */
  42. VB2_ERROR_RSA_PADDING,
  43. /* Bad algorithm in vb2_check_padding() */
  44. VB2_ERROR_RSA_PADDING_ALGORITHM,
  45. /* Null param passed to vb2_verify_digest() */
  46. VB2_ERROR_RSA_VERIFY_PARAM,
  47. /* Bad algorithm in vb2_verify_digest() */
  48. VB2_ERROR_RSA_VERIFY_ALGORITHM,
  49. /* Bad signature length in vb2_verify_digest() */
  50. VB2_ERROR_RSA_VERIFY_SIG_LEN,
  51. /* Work buffer too small in vb2_verify_digest() */
  52. VB2_ERROR_RSA_VERIFY_WORKBUF,
  53. /* Digest mismatch in vb2_verify_digest() */
  54. VB2_ERROR_RSA_VERIFY_DIGEST,
  55. /* Bad size calculation in vb2_check_padding() */
  56. VB2_ERROR_RSA_PADDING_SIZE,
  57. /**********************************************************************
  58. * NV storage errors
  59. */
  60. VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000,
  61. /* Bad header in vb2_nv_check_crc() */
  62. VB2_ERROR_NV_HEADER,
  63. /* Bad CRC in vb2_nv_check_crc() */
  64. VB2_ERROR_NV_CRC,
  65. /**********************************************************************
  66. * Secure data storage errors
  67. */
  68. VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000,
  69. /* Bad CRC in vb2_secdata_check_crc() */
  70. VB2_ERROR_SECDATA_CRC,
  71. /* Secdata is all zeroes (uninitialized) in vb2_secdata_check_crc() */
  72. VB2_ERROR_SECDATA_ZERO,
  73. /* Invalid param in vb2_secdata_get() */
  74. VB2_ERROR_SECDATA_GET_PARAM,
  75. /* Invalid param in vb2_secdata_set() */
  76. VB2_ERROR_SECDATA_SET_PARAM,
  77. /* Invalid flags passed to vb2_secdata_set() */
  78. VB2_ERROR_SECDATA_SET_FLAGS,
  79. /* Called vb2_secdata_get() with uninitialized secdata */
  80. VB2_ERROR_SECDATA_GET_UNINITIALIZED,
  81. /* Called vb2_secdata_set() with uninitialized secdata */
  82. VB2_ERROR_SECDATA_SET_UNINITIALIZED,
  83. /* Bad CRC in vb2_secdatak_check_crc() */
  84. VB2_ERROR_SECDATAK_CRC,
  85. /* Bad struct version in vb2_secdatak_init() */
  86. VB2_ERROR_SECDATAK_VERSION,
  87. /* Bad uid in vb2_secdatak_init() */
  88. VB2_ERROR_SECDATAK_UID,
  89. /* Invalid param in vb2_secdatak_get() */
  90. VB2_ERROR_SECDATAK_GET_PARAM,
  91. /* Invalid param in vb2_secdatak_set() */
  92. VB2_ERROR_SECDATAK_SET_PARAM,
  93. /* Invalid flags passed to vb2_secdatak_set() */
  94. VB2_ERROR_SECDATAK_SET_FLAGS,
  95. /* Called vb2_secdatak_get() with uninitialized secdatak */
  96. VB2_ERROR_SECDATAK_GET_UNINITIALIZED,
  97. /* Called vb2_secdatak_set() with uninitialized secdatak */
  98. VB2_ERROR_SECDATAK_SET_UNINITIALIZED,
  99. /**********************************************************************
  100. * Common code errors
  101. */
  102. VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000,
  103. /* Buffer is smaller than alignment offset in vb2_align() */
  104. VB2_ERROR_ALIGN_BIGGER_THAN_SIZE,
  105. /* Buffer is smaller than request in vb2_align() */
  106. VB2_ERROR_ALIGN_SIZE,
  107. /* Parent wraps around in vb2_verify_member_inside() */
  108. VB2_ERROR_INSIDE_PARENT_WRAPS,
  109. /* Member wraps around in vb2_verify_member_inside() */
  110. VB2_ERROR_INSIDE_MEMBER_WRAPS,
  111. /* Member outside parent in vb2_verify_member_inside() */
  112. VB2_ERROR_INSIDE_MEMBER_OUTSIDE,
  113. /* Member data wraps around in vb2_verify_member_inside() */
  114. VB2_ERROR_INSIDE_DATA_WRAPS,
  115. /* Member data outside parent in vb2_verify_member_inside() */
  116. VB2_ERROR_INSIDE_DATA_OUTSIDE,
  117. /* Unsupported signature algorithm in vb2_unpack_key_buffer() */
  118. VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM, /* 0x150008 */
  119. /* Bad key size in vb2_unpack_key_buffer() */
  120. VB2_ERROR_UNPACK_KEY_SIZE,
  121. /* Bad key alignment in vb2_unpack_key_buffer() */
  122. VB2_ERROR_UNPACK_KEY_ALIGN,
  123. /* Bad key array size in vb2_unpack_key_buffer() */
  124. VB2_ERROR_UNPACK_KEY_ARRAY_SIZE,
  125. /* Bad algorithm in vb2_verify_data() */
  126. VB2_ERROR_VDATA_ALGORITHM,
  127. /* Incorrect signature size for algorithm in vb2_verify_data() */
  128. VB2_ERROR_VDATA_SIG_SIZE,
  129. /* Data smaller than length of signed data in vb2_verify_data() */
  130. VB2_ERROR_VDATA_NOT_ENOUGH_DATA,
  131. /* Not enough work buffer for digest in vb2_verify_data() */
  132. VB2_ERROR_VDATA_WORKBUF_DIGEST,
  133. /* Not enough work buffer for hash temp data in vb2_verify_data() */
  134. VB2_ERROR_VDATA_WORKBUF_HASHING, /* 0x150010 */
  135. /*
  136. * Bad digest size in vb2_verify_data() - probably because algorithm
  137. * is bad.
  138. */
  139. VB2_ERROR_VDATA_DIGEST_SIZE,
  140. /* Unsupported hash algorithm in vb2_unpack_key_buffer() */
  141. VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM,
  142. /* Member data overlaps member header */
  143. VB2_ERROR_INSIDE_DATA_OVERLAP,
  144. /* Unsupported packed key struct version */
  145. VB2_ERROR_UNPACK_KEY_STRUCT_VERSION,
  146. /*
  147. * Buffer too small for total, fixed size, or description reported in
  148. * common header, or member data checked via
  149. * vb21_verify_common_member().
  150. */
  151. VB2_ERROR_COMMON_TOTAL_SIZE,
  152. VB2_ERROR_COMMON_FIXED_SIZE,
  153. VB2_ERROR_COMMON_DESC_SIZE,
  154. VB2_ERROR_COMMON_MEMBER_SIZE, /* 0x150018 */
  155. /*
  156. * Total, fixed, description, or member offset/size not a multiple of
  157. * 32 bits.
  158. */
  159. VB2_ERROR_COMMON_TOTAL_UNALIGNED,
  160. VB2_ERROR_COMMON_FIXED_UNALIGNED,
  161. VB2_ERROR_COMMON_DESC_UNALIGNED,
  162. VB2_ERROR_COMMON_MEMBER_UNALIGNED,
  163. /* Common struct description or member data wraps address space */
  164. VB2_ERROR_COMMON_DESC_WRAPS,
  165. VB2_ERROR_COMMON_MEMBER_WRAPS,
  166. /* Common struct description is not null-terminated */
  167. VB2_ERROR_COMMON_DESC_TERMINATOR,
  168. /* Member data overlaps previous data */
  169. VB2_ERROR_COMMON_MEMBER_OVERLAP, /* 0x150020 */
  170. /* Signature bad magic number */
  171. VB2_ERROR_SIG_MAGIC,
  172. /* Signature incompatible version */
  173. VB2_ERROR_SIG_VERSION,
  174. /* Signature header doesn't fit */
  175. VB2_ERROR_SIG_HEADER_SIZE,
  176. /* Signature unsupported algorithm */
  177. VB2_ERROR_SIG_ALGORITHM,
  178. /* Signature bad size for algorithm */
  179. VB2_ERROR_SIG_SIZE,
  180. /* Wrong amount of data signed */
  181. VB2_ERROR_VDATA_SIZE,
  182. /* Digest mismatch */
  183. VB2_ERROR_VDATA_VERIFY_DIGEST,
  184. /* Key algorithm doesn't match signature algorithm */
  185. VB2_ERROR_VDATA_ALGORITHM_MISMATCH,
  186. /* Bad magic number in vb2_unpack_key_buffer() */
  187. VB2_ERROR_UNPACK_KEY_MAGIC,
  188. /* Null public key buffer passed to vb2_unpack_key_buffer() */
  189. VB2_ERROR_UNPACK_KEY_BUFFER,
  190. /**********************************************************************
  191. * Keyblock verification errors (all in vb2_verify_keyblock())
  192. */
  193. VB2_ERROR_KEYBLOCK = VB2_ERROR_BASE + 0x060000,
  194. /* Data buffer too small for header */
  195. VB2_ERROR_KEYBLOCK_TOO_SMALL_FOR_HEADER,
  196. /* Magic number not present */
  197. VB2_ERROR_KEYBLOCK_MAGIC,
  198. /* Header version incompatible */
  199. VB2_ERROR_KEYBLOCK_HEADER_VERSION,
  200. /* Data buffer too small for keyblock */
  201. VB2_ERROR_KEYBLOCK_SIZE,
  202. /* Signature data offset outside keyblock */
  203. VB2_ERROR_KEYBLOCK_SIG_OUTSIDE,
  204. /* Signature signed more data than size of keyblock */
  205. VB2_ERROR_KEYBLOCK_SIGNED_TOO_MUCH,
  206. /* Signature signed less data than size of keyblock header */
  207. VB2_ERROR_KEYBLOCK_SIGNED_TOO_LITTLE,
  208. /* Signature invalid */
  209. VB2_ERROR_KEYBLOCK_SIG_INVALID,
  210. /* Data key outside keyblock */
  211. VB2_ERROR_KEYBLOCK_DATA_KEY_OUTSIDE,
  212. /* Data key outside signed part of keyblock */
  213. VB2_ERROR_KEYBLOCK_DATA_KEY_UNSIGNED,
  214. /* Signature signed wrong amount of data */
  215. VB2_ERROR_KEYBLOCK_SIGNED_SIZE,
  216. /* No signature matching key ID */
  217. VB2_ERROR_KEYBLOCK_SIG_ID,
  218. /**********************************************************************
  219. * Preamble verification errors (all in vb2_verify_preamble())
  220. */
  221. VB2_ERROR_PREAMBLE = VB2_ERROR_BASE + 0x070000,
  222. /* Preamble data too small to contain header */
  223. VB2_ERROR_PREAMBLE_TOO_SMALL_FOR_HEADER,
  224. /* Header version incompatible */
  225. VB2_ERROR_PREAMBLE_HEADER_VERSION,
  226. /* Header version too old */
  227. VB2_ERROR_PREAMBLE_HEADER_OLD,
  228. /* Data buffer too small for preamble */
  229. VB2_ERROR_PREAMBLE_SIZE,
  230. /* Signature data offset outside preamble */
  231. VB2_ERROR_PREAMBLE_SIG_OUTSIDE,
  232. /* Signature signed more data than size of preamble */
  233. VB2_ERROR_PREAMBLE_SIGNED_TOO_MUCH,
  234. /* Signature signed less data than size of preamble header */
  235. VB2_ERROR_PREAMBLE_SIGNED_TOO_LITTLE,
  236. /* Signature invalid */
  237. VB2_ERROR_PREAMBLE_SIG_INVALID,
  238. /* Body signature outside preamble */
  239. VB2_ERROR_PREAMBLE_BODY_SIG_OUTSIDE,
  240. /* Kernel subkey outside preamble */
  241. VB2_ERROR_PREAMBLE_KERNEL_SUBKEY_OUTSIDE,
  242. /* Bad magic number */
  243. VB2_ERROR_PREAMBLE_MAGIC,
  244. /* Hash is signed */
  245. VB2_ERROR_PREAMBLE_HASH_SIGNED,
  246. /* Bootloader outside signed portion of body */
  247. VB2_ERROR_PREAMBLE_BOOTLOADER_OUTSIDE,
  248. /* Vmlinuz header outside signed portion of body */
  249. VB2_ERROR_PREAMBLE_VMLINUZ_HEADER_OUTSIDE,
  250. /**********************************************************************
  251. * Misc higher-level code errors
  252. */
  253. VB2_ERROR_MISC = VB2_ERROR_BASE + 0x080000,
  254. /* Work buffer too small in vb2_init_context() */
  255. VB2_ERROR_INITCTX_WORKBUF_SMALL,
  256. /* Work buffer unaligned in vb2_init_context() */
  257. VB2_ERROR_INITCTX_WORKBUF_ALIGN,
  258. /* Work buffer too small in vb2_fw_parse_gbb() */
  259. VB2_ERROR_GBB_WORKBUF,
  260. /* Bad magic number in vb2_read_gbb_header() */
  261. VB2_ERROR_GBB_MAGIC,
  262. /* Incompatible version in vb2_read_gbb_header() */
  263. VB2_ERROR_GBB_VERSION,
  264. /* Old version in vb2_read_gbb_header() */
  265. VB2_ERROR_GBB_TOO_OLD,
  266. /* Header size too small in vb2_read_gbb_header() */
  267. VB2_ERROR_GBB_HEADER_SIZE,
  268. /* Work buffer too small for root key in vb2_load_fw_keyblock() */
  269. VB2_ERROR_FW_KEYBLOCK_WORKBUF_ROOT_KEY,
  270. /* Work buffer too small for header in vb2_load_fw_keyblock() */
  271. VB2_ERROR_FW_KEYBLOCK_WORKBUF_HEADER,
  272. /* Work buffer too small for keyblock in vb2_load_fw_keyblock() */
  273. VB2_ERROR_FW_KEYBLOCK_WORKBUF,
  274. /* Keyblock version out of range in vb2_load_fw_keyblock() */
  275. VB2_ERROR_FW_KEYBLOCK_VERSION_RANGE,
  276. /* Keyblock version rollback in vb2_load_fw_keyblock() */
  277. VB2_ERROR_FW_KEYBLOCK_VERSION_ROLLBACK,
  278. /* Missing firmware data key in vb2_load_fw_preamble() */
  279. VB2_ERROR_FW_PREAMBLE2_DATA_KEY,
  280. /* Work buffer too small for header in vb2_load_fw_preamble() */
  281. VB2_ERROR_FW_PREAMBLE2_WORKBUF_HEADER,
  282. /* Work buffer too small for preamble in vb2_load_fw_preamble() */
  283. VB2_ERROR_FW_PREAMBLE2_WORKBUF,
  284. /* Firmware version out of range in vb2_load_fw_preamble() */
  285. VB2_ERROR_FW_PREAMBLE_VERSION_RANGE,
  286. /* Firmware version rollback in vb2_load_fw_preamble() */
  287. VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK,
  288. /* Not enough space in work buffer for resource object */
  289. VB2_ERROR_READ_RESOURCE_OBJECT_BUF,
  290. /* Work buffer too small for header in vb2_load_kernel_keyblock() */
  291. VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF_HEADER,
  292. /* Work buffer too small for keyblock in vb2_load_kernel_keyblock() */
  293. VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF,
  294. /* Keyblock version out of range in vb2_load_kernel_keyblock() */
  295. VB2_ERROR_KERNEL_KEYBLOCK_VERSION_RANGE,
  296. /* Keyblock version rollback in vb2_load_kernel_keyblock() */
  297. VB2_ERROR_KERNEL_KEYBLOCK_VERSION_ROLLBACK,
  298. /*
  299. * Keyblock flags don't match current mode in
  300. * vb2_load_kernel_keyblock().
  301. */
  302. VB2_ERROR_KERNEL_KEYBLOCK_DEV_FLAG,
  303. VB2_ERROR_KERNEL_KEYBLOCK_REC_FLAG,
  304. /* Missing firmware data key in vb2_load_kernel_preamble() */
  305. VB2_ERROR_KERNEL_PREAMBLE2_DATA_KEY,
  306. /* Work buffer too small for header in vb2_load_kernel_preamble() */
  307. VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF_HEADER,
  308. /* Work buffer too small for preamble in vb2_load_kernel_preamble() */
  309. VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF,
  310. /* Kernel version out of range in vb2_load_kernel_preamble() */
  311. VB2_ERROR_KERNEL_PREAMBLE_VERSION_RANGE,
  312. /* Kernel version rollback in vb2_load_kernel_preamble() */
  313. VB2_ERROR_KERNEL_PREAMBLE_VERSION_ROLLBACK,
  314. /* Kernel preamble not loaded before calling vb2api_get_kernel_size() */
  315. VB2_ERROR_API_GET_KERNEL_SIZE_PREAMBLE,
  316. /* Unable to unpack kernel subkey in vb2_verify_vblock() */
  317. VB2_ERROR_VBLOCK_KERNEL_SUBKEY,
  318. /*
  319. * Got a self-signed kernel in vb2_verify_vblock(), but need an
  320. * officially signed one.
  321. */
  322. VB2_ERROR_VBLOCK_SELF_SIGNED,
  323. /* Invalid keyblock hash in vb2_verify_vblock() */
  324. VB2_ERROR_VBLOCK_KEYBLOCK_HASH,
  325. /* Invalid keyblock in vb2_verify_vblock() */
  326. VB2_ERROR_VBLOCK_KEYBLOCK,
  327. /* Wrong developer key hash in vb2_verify_vblock() */
  328. VB2_ERROR_VBLOCK_DEV_KEY_HASH,
  329. /* Work buffer too small in vb2_load_partition() */
  330. VB2_ERROR_LOAD_PARTITION_WORKBUF,
  331. /* Unable to read vblock in vb2_load_partition() */
  332. VB2_ERROR_LOAD_PARTITION_READ_VBLOCK,
  333. /* Unable to verify vblock in vb2_load_partition() */
  334. VB2_ERROR_LOAD_PARTITION_VERIFY_VBLOCK,
  335. /* Kernel body offset too large in vb2_load_partition() */
  336. VB2_ERROR_LOAD_PARTITION_BODY_OFFSET,
  337. /* Kernel body too big in vb2_load_partition() */
  338. VB2_ERROR_LOAD_PARTITION_BODY_SIZE,
  339. /* Unable to read kernel body in vb2_load_partition() */
  340. VB2_ERROR_LOAD_PARTITION_READ_BODY,
  341. /* Unable to unpack data key in vb2_load_partition() */
  342. VB2_ERROR_LOAD_PARTITION_DATA_KEY,
  343. /* Unable to verify body in vb2_load_partition() */
  344. VB2_ERROR_LOAD_PARTITION_VERIFY_BODY,
  345. /* Unable to get EC image hash in ec_sync_phase1() */
  346. VB2_ERROR_EC_HASH_IMAGE,
  347. /* Unable to get expected EC image hash in ec_sync_phase1() */
  348. VB2_ERROR_EC_HASH_EXPECTED,
  349. /* Expected and image hashes are different size in ec_sync_phase1() */
  350. VB2_ERROR_EC_HASH_SIZE,
  351. /**********************************************************************
  352. * API-level errors
  353. */
  354. VB2_ERROR_API = VB2_ERROR_BASE + 0x090000,
  355. /* Bad tag in vb2api_init_hash() */
  356. VB2_ERROR_API_INIT_HASH_TAG,
  357. /* Preamble not present in vb2api_init_hash() */
  358. VB2_ERROR_API_INIT_HASH_PREAMBLE,
  359. /* Work buffer too small in vb2api_init_hash() */
  360. VB2_ERROR_API_INIT_HASH_WORKBUF,
  361. /* Missing firmware data key in vb2api_init_hash() */
  362. VB2_ERROR_API_INIT_HASH_DATA_KEY,
  363. /* Uninitialized work area in vb2api_extend_hash() */
  364. VB2_ERROR_API_EXTEND_HASH_WORKBUF,
  365. /* Too much data hashed in vb2api_extend_hash() */
  366. VB2_ERROR_API_EXTEND_HASH_SIZE,
  367. /* Preamble not present in vb2api_check_hash() */
  368. VB2_ERROR_API_CHECK_HASH_PREAMBLE,
  369. /* Uninitialized work area in vb2api_check_hash() */
  370. VB2_ERROR_API_CHECK_HASH_WORKBUF,
  371. /* Wrong amount of data hashed in vb2api_check_hash() */
  372. VB2_ERROR_API_CHECK_HASH_SIZE,
  373. /* Work buffer too small in vb2api_check_hash() */
  374. VB2_ERROR_API_CHECK_HASH_WORKBUF_DIGEST,
  375. /* Bad tag in vb2api_check_hash() */
  376. VB2_ERROR_API_CHECK_HASH_TAG,
  377. /* Missing firmware data key in vb2api_check_hash() */
  378. VB2_ERROR_API_CHECK_HASH_DATA_KEY,
  379. /* Signature size mismatch in vb2api_check_hash() */
  380. VB2_ERROR_API_CHECK_HASH_SIG_SIZE,
  381. /* Phase one needs recovery mode */
  382. VB2_ERROR_API_PHASE1_RECOVERY,
  383. /* Bad tag in vb2api_check_hash() */
  384. VB2_ERROR_API_INIT_HASH_ID,
  385. /* Signature mismatch in vb2api_check_hash() */
  386. VB2_ERROR_API_CHECK_HASH_SIG,
  387. /* Invalid enum vb2_pcr_digest requested to vb2api_get_pcr_digest */
  388. VB2_ERROR_API_PCR_DIGEST,
  389. /* Buffer size for the digest is too small for vb2api_get_pcr_digest */
  390. VB2_ERROR_API_PCR_DIGEST_BUF,
  391. /* Work buffer too small for recovery key in vb2api_kernel_phase1() */
  392. VB2_ERROR_API_KPHASE1_WORKBUF_REC_KEY,
  393. /* Firmware preamble not present for vb2api_kernel_phase1() */
  394. VB2_ERROR_API_KPHASE1_PREAMBLE,
  395. /* Wrong amount of kernel data in vb2api_verify_kernel_data() */
  396. VB2_ERROR_API_VERIFY_KDATA_SIZE,
  397. /* Kernel preamble not present for vb2api_verify_kernel_data() */
  398. VB2_ERROR_API_VERIFY_KDATA_PREAMBLE,
  399. /* Insufficient workbuf for hashing in vb2api_verify_kernel_data() */
  400. VB2_ERROR_API_VERIFY_KDATA_WORKBUF,
  401. /* Bad data key in vb2api_verify_kernel_data() */
  402. VB2_ERROR_API_VERIFY_KDATA_KEY,
  403. /* Phase one passing through secdata's request to reboot */
  404. VB2_ERROR_API_PHASE1_SECDATA_REBOOT,
  405. /* Digest buffer passed into vb2api_check_hash incorrect. */
  406. VB2_ERROR_API_CHECK_DIGEST_SIZE,
  407. /**********************************************************************
  408. * Errors which may be generated by implementations of vb2ex functions.
  409. * Implementation may also return its own specific errors, which should
  410. * NOT be in the range VB2_ERROR_BASE...VB2_ERROR_MAX to avoid
  411. * conflicting with future vboot2 error codes.
  412. */
  413. VB2_ERROR_EX = VB2_ERROR_BASE + 0x0a0000,
  414. /* Read resource not implemented */
  415. VB2_ERROR_EX_READ_RESOURCE_UNIMPLEMENTED,
  416. /* Resource index not found */
  417. VB2_ERROR_EX_READ_RESOURCE_INDEX,
  418. /* Size of resource not big enough for requested offset and/or size */
  419. VB2_ERROR_EX_READ_RESOURCE_SIZE,
  420. /* TPM clear owner failed */
  421. VB2_ERROR_EX_TPM_CLEAR_OWNER,
  422. /* TPM clear owner not implemented */
  423. VB2_ERROR_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED,
  424. /* Hardware crypto engine doesn't support this algorithm (non-fatal) */
  425. VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED,
  426. /**********************************************************************
  427. * Errors generated by host library (non-firmware) start here.
  428. */
  429. VB2_ERROR_HOST_BASE = 0x20000000,
  430. /**********************************************************************
  431. * Errors generated by host library misc functions
  432. */
  433. VB2_ERROR_HOST_MISC = VB2_ERROR_HOST_BASE + 0x010000,
  434. /* Unable to open file in read_file() */
  435. VB2_ERROR_READ_FILE_OPEN,
  436. /* Bad size in read_file() */
  437. VB2_ERROR_READ_FILE_SIZE,
  438. /* Unable to allocate buffer in read_file() */
  439. VB2_ERROR_READ_FILE_ALLOC,
  440. /* Unable to read data in read_file() */
  441. VB2_ERROR_READ_FILE_DATA,
  442. /* Unable to open file in write_file() */
  443. VB2_ERROR_WRITE_FILE_OPEN,
  444. /* Unable to write data in write_file() */
  445. VB2_ERROR_WRITE_FILE_DATA,
  446. /* Unable to convert string to struct vb_id */
  447. VB2_ERROR_STR_TO_ID,
  448. /**********************************************************************
  449. * Errors generated by host library key functions
  450. */
  451. VB2_ERROR_HOST_KEY = VB2_ERROR_HOST_BASE + 0x020000,
  452. /* Unable to allocate key in vb2_private_key_read_pem() */
  453. VB2_ERROR_READ_PEM_ALLOC,
  454. /* Unable to open .pem file in vb2_private_key_read_pem() */
  455. VB2_ERROR_READ_PEM_FILE_OPEN,
  456. /* Bad RSA data from .pem file in vb2_private_key_read_pem() */
  457. VB2_ERROR_READ_PEM_RSA,
  458. /* Unable to set private key description */
  459. VB2_ERROR_PRIVATE_KEY_SET_DESC,
  460. /* Bad magic number in vb2_private_key_unpack() */
  461. VB2_ERROR_UNPACK_PRIVATE_KEY_MAGIC,
  462. /* Bad common header in vb2_private_key_unpack() */
  463. VB2_ERROR_UNPACK_PRIVATE_KEY_HEADER,
  464. /* Bad key data in vb2_private_key_unpack() */
  465. VB2_ERROR_UNPACK_PRIVATE_KEY_DATA,
  466. /* Bad struct version in vb2_private_key_unpack() */
  467. VB2_ERROR_UNPACK_PRIVATE_KEY_STRUCT_VERSION,
  468. /* Unable to allocate buffer in vb2_private_key_unpack() */
  469. VB2_ERROR_UNPACK_PRIVATE_KEY_ALLOC,
  470. /* Unable to unpack RSA key in vb2_private_key_unpack() */
  471. VB2_ERROR_UNPACK_PRIVATE_KEY_RSA,
  472. /* Unable to set description in vb2_private_key_unpack() */
  473. VB2_ERROR_UNPACK_PRIVATE_KEY_DESC,
  474. /* Bad bare hash key in vb2_private_key_unpack() */
  475. VB2_ERROR_UNPACK_PRIVATE_KEY_HASH,
  476. /* Unable to create RSA data in vb2_private_key_write() */
  477. VB2_ERROR_PRIVATE_KEY_WRITE_RSA,
  478. /* Unable to allocate packed key buffer in vb2_private_key_write() */
  479. VB2_ERROR_PRIVATE_KEY_WRITE_ALLOC,
  480. /* Unable to write file in vb2_private_key_write() */
  481. VB2_ERROR_PRIVATE_KEY_WRITE_FILE,
  482. /* Bad algorithm in vb2_private_key_hash() */
  483. VB2_ERROR_PRIVATE_KEY_HASH,
  484. /* Unable to determine key size in vb2_public_key_alloc() */
  485. VB2_ERROR_PUBLIC_KEY_ALLOC_SIZE,
  486. /* Unable to allocate buffer in vb2_public_key_alloc() */
  487. VB2_ERROR_PUBLIC_KEY_ALLOC,
  488. /* Unable to set public key description */
  489. VB2_ERROR_PUBLIC_KEY_SET_DESC,
  490. /* Unable to read key data in vb2_public_key_read_keyb() */
  491. VB2_ERROR_READ_KEYB_DATA,
  492. /* Wrong amount of data read in vb2_public_key_read_keyb() */
  493. VB2_ERROR_READ_KEYB_SIZE,
  494. /* Unable to allocate key buffer in vb2_public_key_read_keyb() */
  495. VB2_ERROR_READ_KEYB_ALLOC,
  496. /* Error unpacking RSA arrays in vb2_public_key_read_keyb() */
  497. VB2_ERROR_READ_KEYB_UNPACK,
  498. /* Unable to read key data in vb2_packed_key_read() */
  499. VB2_ERROR_READ_PACKED_KEY_DATA,
  500. /* Bad key data in vb2_packed_key_read() */
  501. VB2_ERROR_READ_PACKED_KEY,
  502. /* Unable to determine key size in vb2_public_key_pack() */
  503. VB2_ERROR_PUBLIC_KEY_PACK_SIZE,
  504. /* Bad hash algorithm in vb2_public_key_hash() */
  505. VB2_ERROR_PUBLIC_KEY_HASH,
  506. /* Bad key size in vb2_copy_packed_key() */
  507. VB2_ERROR_COPY_KEY_SIZE,
  508. /* Unable to convert back to vb1 crypto algorithm */
  509. VB2_ERROR_VB1_CRYPTO_ALGORITHM,
  510. /* Unable to allocate packed key */
  511. VB2_ERROR_PACKED_KEY_ALLOC,
  512. /* Unable to copy packed key */
  513. VB2_ERROR_PACKED_KEY_COPY,
  514. /**********************************************************************
  515. * Errors generated by host library signature functions
  516. */
  517. VB2_ERROR_HOST_SIG = VB2_ERROR_HOST_BASE + 0x030000,
  518. /* Bad hash algorithm in vb2_digest_info() */
  519. VB2_ERROR_DIGEST_INFO,
  520. /*
  521. * Unable to determine signature size for key algorithm in
  522. * vb2_sig_size_for_key().
  523. */
  524. VB2_ERROR_SIG_SIZE_FOR_KEY,
  525. /* Bad signature size in vb2_sign_data() */
  526. VB2_SIGN_DATA_SIG_SIZE,
  527. /* Unable to get digest info in vb2_sign_data() */
  528. VB2_SIGN_DATA_DIGEST_INFO,
  529. /* Unable to get digest size in vb2_sign_data() */
  530. VB2_SIGN_DATA_DIGEST_SIZE,
  531. /* Unable to allocate digest buffer in vb2_sign_data() */
  532. VB2_SIGN_DATA_DIGEST_ALLOC,
  533. /* Unable to initialize digest in vb2_sign_data() */
  534. VB2_SIGN_DATA_DIGEST_INIT,
  535. /* Unable to extend digest in vb2_sign_data() */
  536. VB2_SIGN_DATA_DIGEST_EXTEND,
  537. /* Unable to finalize digest in vb2_sign_data() */
  538. VB2_SIGN_DATA_DIGEST_FINALIZE,
  539. /* RSA encrypt failed in vb2_sign_data() */
  540. VB2_SIGN_DATA_RSA_ENCRYPT,
  541. /* Not enough buffer space to hold signature in vb2_sign_object() */
  542. VB2_SIGN_OBJECT_OVERFLOW,
  543. /**********************************************************************
  544. * Errors generated by host library keyblock functions
  545. */
  546. VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000,
  547. /* Unable to determine signature sizes for vb2_create_keyblock() */
  548. VB2_KEYBLOCK_CREATE_SIG_SIZE,
  549. /* Unable to pack data key for vb2_create_keyblock() */
  550. VB2_KEYBLOCK_CREATE_DATA_KEY,
  551. /* Unable to allocate buffer in vb2_create_keyblock() */
  552. VB2_KEYBLOCK_CREATE_ALLOC,
  553. /* Unable to sign keyblock in vb2_create_keyblock() */
  554. VB2_KEYBLOCK_CREATE_SIGN,
  555. /**********************************************************************
  556. * Errors generated by host library firmware preamble functions
  557. */
  558. VB2_ERROR_HOST_FW_PREAMBLE = VB2_ERROR_HOST_BASE + 0x050000,
  559. /* Unable to determine signature sizes for vb2_create_fw_preamble() */
  560. VB2_FW_PREAMBLE_CREATE_SIG_SIZE,
  561. /* Unable to allocate buffer in vb2_create_fw_preamble() */
  562. VB2_FW_PREAMBLE_CREATE_ALLOC,
  563. /* Unable to sign preamble in vb2_create_fw_preamble() */
  564. VB2_FW_PREAMBLE_CREATE_SIGN,
  565. /**********************************************************************
  566. * Errors generated by unit test functions
  567. */
  568. VB2_ERROR_UNIT_TEST = VB2_ERROR_HOST_BASE + 0x060000,
  569. /* Unable to open an input file needed for a unit test */
  570. VB2_ERROR_TEST_INPUT_FILE,
  571. /**********************************************************************
  572. * Highest non-zero error generated inside vboot library. Note that
  573. * error codes passed through vboot when it calls external APIs may
  574. * still be outside this range.
  575. */
  576. VB2_ERROR_MAX = VB2_ERROR_BASE + 0x1fffffff,
  577. };
  578. #endif /* VBOOT_2_RETURN_CODES_H_ */