1 /* Copyright 2014 The ChromiumOS Authors 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 #ifndef VBOOT_REFERENCE_2RETURN_CODES_H_ 7 #define VBOOT_REFERENCE_2RETURN_CODES_H_ 8 9 #include "2sysincludes.h" 10 11 /* 12 * Functions which return an error all return this type. This is a 32-bit 13 * value rather than an int so it's consistent across different architectures. 14 */ 15 typedef uint32_t vb2_error_t; 16 17 /* 18 * Return codes from verified boot functions. 19 * 20 * Note that other values may be passed through from vb2ex_*() calls; see 21 * the comment for VB2_ERROR_EX below. 22 */ 23 enum vb2_return_code { 24 /* Success - no error */ 25 VB2_SUCCESS = 0, 26 27 /********************************************************************** 28 * Requests to the caller that are not considered errors 29 */ 30 VB2_REQUEST = 0x1000, 31 32 /* Calling firmware requested shutdown */ 33 VB2_REQUEST_SHUTDOWN = 0x1001, 34 35 /* Calling firmware needs to perform a reboot */ 36 VB2_REQUEST_REBOOT = 0x1002, 37 38 /* Need EC to reboot to read-only code to switch RW slot */ 39 VB2_REQUEST_REBOOT_EC_SWITCH_RW = 0x1003, 40 41 /* Need EC to reboot to read-only code */ 42 VB2_REQUEST_REBOOT_EC_TO_RO = 0x1004, 43 44 /* Continue in the UI loop. This is used in UI internal functions. */ 45 VB2_REQUEST_UI_CONTINUE = 0x1005, 46 47 /* Break from the UI loop. This is used in UI internal functions. */ 48 VB2_REQUEST_UI_EXIT = 0x1006, 49 50 /* End of VB2_REQUEST_* */ 51 VB2_REQUEST_END = 0x5000, 52 53 /********************************************************************** 54 * All vboot2 error codes start at a large offset from zero, to reduce 55 * the risk of overlap with other error codes (TPM, etc.). 56 */ 57 VB2_ERROR_BASE = 0x10000000, 58 59 /* Unknown / unspecified error */ 60 VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1, 61 62 /* Mock error for testing */ 63 VB2_ERROR_MOCK, 64 65 /********************************************************************** 66 * SHA errors 67 */ 68 VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000, 69 70 /* Bad algorithm in vb2_digest_init() */ 71 VB2_ERROR_SHA_INIT_ALGORITHM, 72 73 /* Bad algorithm in vb2_digest_extend() */ 74 VB2_ERROR_SHA_EXTEND_ALGORITHM, 75 76 /* Bad algorithm in vb2_digest_finalize() */ 77 VB2_ERROR_SHA_FINALIZE_ALGORITHM, 78 79 /* Digest size buffer too small in vb2_digest_finalize() */ 80 VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE, 81 82 /* Hash mismatch in vb2_hash_verify() */ 83 VB2_ERROR_SHA_MISMATCH, 84 85 /********************************************************************** 86 * RSA errors 87 */ 88 VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000, 89 90 /* Padding mismatch in vb2_check_padding() */ 91 VB2_ERROR_RSA_PADDING, 92 93 /* Bad algorithm in vb2_check_padding() */ 94 VB2_ERROR_RSA_PADDING_ALGORITHM, 95 96 /* Null param passed to vb2_verify_digest() */ 97 VB2_ERROR_RSA_VERIFY_PARAM, 98 99 /* Bad algorithm in vb2_verify_digest() */ 100 VB2_ERROR_RSA_VERIFY_ALGORITHM, 101 102 /* Bad signature length in vb2_verify_digest() */ 103 VB2_ERROR_RSA_VERIFY_SIG_LEN, 104 105 /* Work buffer too small in vb2_verify_digest() */ 106 VB2_ERROR_RSA_VERIFY_WORKBUF, 107 108 /* Digest mismatch in vb2_verify_digest() */ 109 VB2_ERROR_RSA_VERIFY_DIGEST, 110 111 /* Bad size calculation in vb2_check_padding() */ 112 VB2_ERROR_RSA_PADDING_SIZE, 113 114 /********************************************************************** 115 * NV storage errors 116 */ 117 VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000, 118 119 /* Bad header in vb2_nv_check_crc() */ 120 VB2_ERROR_NV_HEADER, 121 122 /* Bad CRC in vb2_nv_check_crc() */ 123 VB2_ERROR_NV_CRC, 124 125 /* Read error in nvdata backend */ 126 VB2_ERROR_NV_READ, 127 128 /* Write error in nvdata backend */ 129 VB2_ERROR_NV_WRITE, 130 131 /********************************************************************** 132 * Secure data storage errors 133 */ 134 VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000, 135 136 /* Bad CRC in vb2api_secdata_firmware_check() */ 137 VB2_ERROR_SECDATA_FIRMWARE_CRC, 138 139 /* Bad struct version in vb2api_secdata_firmware_check() */ 140 VB2_ERROR_SECDATA_FIRMWARE_VERSION, 141 142 /* Invalid param in vb2_secdata_firmware_get(); 143 Deprecated with chromium:972956. */ 144 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_GET_PARAM, 145 146 /* Invalid param in vb2_secdata_firmware_set(); 147 Deprecated with chromium:972956. */ 148 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_PARAM, 149 150 /* Invalid flags passed to vb2_secdata_firmware_set(); 151 Deprecated with chromium:972956. */ 152 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_FLAGS, 153 154 /* Called vb2_secdata_firmware_get() with uninitialized secdata; 155 Deprecated with chromium:972956. */ 156 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_GET_UNINITIALIZED, 157 158 /* Called vb2_secdata_firmware_set() with uninitialized secdata; 159 Deprecated with chromium:972956. */ 160 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_UNINITIALIZED, 161 162 /* Bad CRC in vb2api_secdata_kernel_check() */ 163 VB2_ERROR_SECDATA_KERNEL_CRC, 164 165 /* Bad struct version in vb2_secdata_kernel_init() */ 166 VB2_ERROR_SECDATA_KERNEL_VERSION, 167 168 /* Bad uid in vb2_secdata_kernel_init() */ 169 VB2_ERROR_SECDATA_KERNEL_UID, 170 171 /* Invalid param in vb2_secdata_kernel_get(); 172 Deprecated with chromium:972956. */ 173 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_GET_PARAM, 174 175 /* Invalid param in vb2_secdata_kernel_set(); 176 Deprecated with chromium:972956. */ 177 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_PARAM, 178 179 /* Invalid flags passed to vb2_secdata_kernel_set(); 180 Deprecated with chromium:972956. */ 181 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_FLAGS, 182 183 /* Called vb2_secdata_kernel_get() with uninitialized secdata_kernel; 184 Deprecated with chromium:972956. */ 185 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_GET_UNINITIALIZED, 186 187 /* Called vb2_secdata_kernel_set() with uninitialized secdata_kernel; 188 Deprecated with chromium:972956. */ 189 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_UNINITIALIZED, 190 191 /* Bad size in vb2api_secdata_fwmp_check() */ 192 VB2_ERROR_SECDATA_FWMP_SIZE, 193 194 /* Incomplete structure in vb2api_secdata_fwmp_check() */ 195 VB2_ERROR_SECDATA_FWMP_INCOMPLETE, 196 197 /* Bad CRC in vb2api_secdata_fwmp_check() */ 198 VB2_ERROR_SECDATA_FWMP_CRC, 199 200 /* Bad struct version in vb2_secdata_fwmp_check() */ 201 VB2_ERROR_SECDATA_FWMP_VERSION, 202 203 /* Error reading secdata_firmware from storage backend */ 204 VB2_ERROR_SECDATA_FIRMWARE_READ, 205 206 /* Error writing secdata_firmware to storage backend */ 207 VB2_ERROR_SECDATA_FIRMWARE_WRITE, 208 209 /* Error locking secdata_firmware in storage backend */ 210 VB2_ERROR_SECDATA_FIRMWARE_LOCK, 211 212 /* Error reading secdata_kernel from storage backend */ 213 VB2_ERROR_SECDATA_KERNEL_READ, 214 215 /* Error writing secdata_kernel to storage backend */ 216 VB2_ERROR_SECDATA_KERNEL_WRITE, 217 218 /* Error locking secdata_kernel in storage backend */ 219 VB2_ERROR_SECDATA_KERNEL_LOCK, 220 221 /* Error reading secdata_fwmp from storage backend */ 222 VB2_ERROR_SECDATA_FWMP_READ, 223 224 /* Bad buffer size to read vb2_secdata_kernel */ 225 VB2_ERROR_SECDATA_KERNEL_BUFFER_SIZE, 226 227 /* Incomplete structure in vb2api_secdata_kernel_check() */ 228 VB2_ERROR_SECDATA_KERNEL_INCOMPLETE, 229 230 /* Bad struct size in vb2_secdata_kernel */ 231 VB2_ERROR_SECDATA_KERNEL_STRUCT_SIZE, 232 233 /********************************************************************** 234 * Common code errors 235 */ 236 VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000, 237 238 /* Buffer is smaller than alignment offset in vb2_align() */ 239 VB2_ERROR_ALIGN_BIGGER_THAN_SIZE, 240 241 /* Buffer is smaller than request in vb2_align() */ 242 VB2_ERROR_ALIGN_SIZE, 243 244 /* Parent wraps around in vb2_verify_member_inside() */ 245 VB2_ERROR_INSIDE_PARENT_WRAPS, 246 247 /* Member wraps around in vb2_verify_member_inside() */ 248 VB2_ERROR_INSIDE_MEMBER_WRAPS, 249 250 /* Member outside parent in vb2_verify_member_inside() */ 251 VB2_ERROR_INSIDE_MEMBER_OUTSIDE, 252 253 /* Member data wraps around in vb2_verify_member_inside() */ 254 VB2_ERROR_INSIDE_DATA_WRAPS, 255 256 /* Member data outside parent in vb2_verify_member_inside() */ 257 VB2_ERROR_INSIDE_DATA_OUTSIDE, 258 259 /* Unsupported signature algorithm in vb2_unpack_key_buffer() */ 260 VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM, /* 0x150008 */ 261 262 /* Bad key size in vb2_unpack_key_buffer() */ 263 VB2_ERROR_UNPACK_KEY_SIZE, 264 265 /* Bad key alignment in vb2_unpack_key_buffer() */ 266 VB2_ERROR_UNPACK_KEY_ALIGN, 267 268 /* Bad key array size in vb2_unpack_key_buffer() */ 269 VB2_ERROR_UNPACK_KEY_ARRAY_SIZE, 270 271 /* Bad algorithm in vb2_verify_data() */ 272 VB2_ERROR_VDATA_ALGORITHM, 273 274 /* Incorrect signature size for algorithm in vb2_verify_data() */ 275 VB2_ERROR_VDATA_SIG_SIZE, 276 277 /* Data smaller than length of signed data in vb2_verify_data() */ 278 VB2_ERROR_VDATA_NOT_ENOUGH_DATA, 279 280 /* Not enough work buffer for digest in vb2_verify_data() */ 281 VB2_ERROR_VDATA_WORKBUF_DIGEST, 282 283 /* Not enough work buffer for hash temp data in vb2_verify_data() */ 284 VB2_ERROR_VDATA_WORKBUF_HASHING, /* 0x150010 */ 285 286 /* 287 * Bad digest size in vb2_verify_data() - probably because algorithm 288 * is bad. 289 */ 290 VB2_ERROR_VDATA_DIGEST_SIZE, 291 292 /* Unsupported hash algorithm in vb2_unpack_key_buffer() */ 293 VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM, 294 295 /* Member data overlaps member header */ 296 VB2_ERROR_INSIDE_DATA_OVERLAP, 297 298 /* Unsupported packed key struct version */ 299 VB2_ERROR_UNPACK_KEY_STRUCT_VERSION, 300 301 /* 302 * Buffer too small for total, fixed size, or description reported in 303 * common header, or member data checked via 304 * vb21_verify_common_member(). 305 */ 306 VB2_ERROR_COMMON_TOTAL_SIZE, 307 VB2_ERROR_COMMON_FIXED_SIZE, 308 VB2_ERROR_COMMON_DESC_SIZE, 309 VB2_ERROR_COMMON_MEMBER_SIZE, /* 0x150018 */ 310 311 /* 312 * Total, fixed, description, or member offset/size not a multiple of 313 * 32 bits. 314 */ 315 VB2_ERROR_COMMON_TOTAL_UNALIGNED, 316 VB2_ERROR_COMMON_FIXED_UNALIGNED, 317 VB2_ERROR_COMMON_DESC_UNALIGNED, 318 VB2_ERROR_COMMON_MEMBER_UNALIGNED, 319 320 /* Common struct description or member data wraps address space */ 321 VB2_ERROR_COMMON_DESC_WRAPS, 322 VB2_ERROR_COMMON_MEMBER_WRAPS, 323 324 /* Common struct description is not null-terminated */ 325 VB2_ERROR_COMMON_DESC_TERMINATOR, 326 327 /* Member data overlaps previous data */ 328 VB2_ERROR_COMMON_MEMBER_OVERLAP, /* 0x150020 */ 329 330 /* Signature bad magic number */ 331 VB2_ERROR_SIG_MAGIC, 332 333 /* Signature incompatible version */ 334 VB2_ERROR_SIG_VERSION, 335 336 /* Signature header doesn't fit */ 337 VB2_ERROR_SIG_HEADER_SIZE, 338 339 /* Signature unsupported algorithm */ 340 VB2_ERROR_SIG_ALGORITHM, 341 342 /* Signature bad size for algorithm */ 343 VB2_ERROR_SIG_SIZE, 344 345 /* Wrong amount of data signed */ 346 VB2_ERROR_VDATA_SIZE, 347 348 /* Digest mismatch */ 349 VB2_ERROR_VDATA_VERIFY_DIGEST, 350 351 /* Key algorithm doesn't match signature algorithm */ 352 VB2_ERROR_VDATA_ALGORITHM_MISMATCH, 353 354 /* Bad magic number in vb2_unpack_key_buffer() */ 355 VB2_ERROR_UNPACK_KEY_MAGIC, 356 357 /* Null public key buffer passed to vb2_unpack_key_buffer() */ 358 VB2_ERROR_UNPACK_KEY_BUFFER, 359 360 /********************************************************************** 361 * Keyblock verification errors (all in vb2_verify_keyblock()) 362 */ 363 VB2_ERROR_KEYBLOCK = VB2_ERROR_BASE + 0x060000, 364 365 /* Data buffer too small for header */ 366 VB2_ERROR_KEYBLOCK_TOO_SMALL_FOR_HEADER, 367 368 /* Magic number not present */ 369 VB2_ERROR_KEYBLOCK_MAGIC, 370 371 /* Header version incompatible */ 372 VB2_ERROR_KEYBLOCK_HEADER_VERSION, 373 374 /* Data buffer too small for keyblock */ 375 VB2_ERROR_KEYBLOCK_SIZE, 376 377 /* Signature data offset outside keyblock */ 378 VB2_ERROR_KEYBLOCK_SIG_OUTSIDE, 379 380 /* Signature signed more data than size of keyblock */ 381 VB2_ERROR_KEYBLOCK_SIGNED_TOO_MUCH, 382 383 /* Signature signed less data than size of keyblock header */ 384 VB2_ERROR_KEYBLOCK_SIGNED_TOO_LITTLE, 385 386 /* Signature invalid */ 387 VB2_ERROR_KEYBLOCK_SIG_INVALID, 388 389 /* Data key outside keyblock */ 390 VB2_ERROR_KEYBLOCK_DATA_KEY_OUTSIDE, 391 392 /* Data key outside signed part of keyblock */ 393 VB2_ERROR_KEYBLOCK_DATA_KEY_UNSIGNED, 394 395 /* Signature signed wrong amount of data */ 396 VB2_ERROR_KEYBLOCK_SIGNED_SIZE, 397 398 /* No signature matching key ID */ 399 VB2_ERROR_KEYBLOCK_SIG_ID, 400 401 /* Invalid keyblock hash in dev mode (self-signed kernel) */ 402 VB2_ERROR_KEYBLOCK_HASH_INVALID_IN_DEV_MODE, 403 404 /********************************************************************** 405 * Preamble verification errors (all in vb2_verify_preamble()) 406 */ 407 VB2_ERROR_PREAMBLE = VB2_ERROR_BASE + 0x070000, 408 409 /* Preamble data too small to contain header */ 410 VB2_ERROR_PREAMBLE_TOO_SMALL_FOR_HEADER, 411 412 /* Header version incompatible */ 413 VB2_ERROR_PREAMBLE_HEADER_VERSION, 414 415 /* Header version too old */ 416 VB2_ERROR_PREAMBLE_HEADER_OLD, 417 418 /* Data buffer too small for preamble */ 419 VB2_ERROR_PREAMBLE_SIZE, 420 421 /* Signature data offset outside preamble */ 422 VB2_ERROR_PREAMBLE_SIG_OUTSIDE, 423 424 /* Signature signed more data than size of preamble */ 425 VB2_ERROR_PREAMBLE_SIGNED_TOO_MUCH, 426 427 /* Signature signed less data than size of preamble header */ 428 VB2_ERROR_PREAMBLE_SIGNED_TOO_LITTLE, 429 430 /* Signature invalid */ 431 VB2_ERROR_PREAMBLE_SIG_INVALID, 432 433 /* Body signature outside preamble */ 434 VB2_ERROR_PREAMBLE_BODY_SIG_OUTSIDE, 435 436 /* Kernel subkey outside preamble */ 437 VB2_ERROR_PREAMBLE_KERNEL_SUBKEY_OUTSIDE, 438 439 /* Bad magic number */ 440 VB2_ERROR_PREAMBLE_MAGIC, 441 442 /* Hash is signed */ 443 VB2_ERROR_PREAMBLE_HASH_SIGNED, 444 445 /* Bootloader outside signed portion of body */ 446 VB2_ERROR_PREAMBLE_BOOTLOADER_OUTSIDE, 447 448 /* Vmlinuz header outside signed portion of body */ 449 VB2_ERROR_PREAMBLE_VMLINUZ_HEADER_OUTSIDE, 450 451 /********************************************************************** 452 * Misc higher-level code errors 453 */ 454 VB2_ERROR_MISC = VB2_ERROR_BASE + 0x080000, 455 456 /* Work buffer too small (see vb2api_init and vb2api_reinit) */ 457 VB2_ERROR_WORKBUF_SMALL = 0x10080001, 458 459 /* Work buffer unaligned (see vb2api_init and vb2api_reinit) */ 460 VB2_ERROR_WORKBUF_ALIGN = 0x10080002, 461 462 /* Work buffer too small in GBB-related function */ 463 VB2_ERROR_GBB_WORKBUF = 0x10080003, 464 465 /* Bad magic number in vb2_read_gbb_header() */ 466 VB2_ERROR_GBB_MAGIC = 0x10080004, 467 468 /* Incompatible version in vb2_read_gbb_header() */ 469 VB2_ERROR_GBB_VERSION = 0x10080005, 470 471 /* Old version in vb2_read_gbb_header() */ 472 VB2_ERROR_GBB_TOO_OLD = 0x10080006, 473 474 /* Header size too small in vb2_read_gbb_header() */ 475 VB2_ERROR_GBB_HEADER_SIZE = 0x10080007, 476 477 /* Work buffer too small for root key in vb2_load_fw_keyblock() */ 478 VB2_ERROR_FW_KEYBLOCK_WORKBUF_ROOT_KEY = 0x10080008, 479 480 /* Work buffer too small for header in vb2_load_fw_keyblock() */ 481 VB2_ERROR_FW_KEYBLOCK_WORKBUF_HEADER = 0x10080009, 482 483 /* Work buffer too small for keyblock in vb2_load_fw_keyblock() */ 484 VB2_ERROR_FW_KEYBLOCK_WORKBUF = 0x1008000a, 485 486 /* Keyblock version out of range in vb2_load_fw_keyblock() */ 487 VB2_ERROR_FW_KEYBLOCK_VERSION_RANGE = 0x1008000b, 488 489 /* Keyblock version rollback in vb2_load_fw_keyblock() */ 490 VB2_ERROR_FW_KEYBLOCK_VERSION_ROLLBACK = 0x1008000c, 491 492 /* Missing firmware data key in vb2_load_fw_preamble() */ 493 VB2_ERROR_FW_PREAMBLE2_DATA_KEY = 0x1008000d, 494 495 /* Work buffer too small for header in vb2_load_fw_preamble() */ 496 VB2_ERROR_FW_PREAMBLE2_WORKBUF_HEADER = 0x1008000e, 497 498 /* Work buffer too small for preamble in vb2_load_fw_preamble() */ 499 VB2_ERROR_FW_PREAMBLE2_WORKBUF = 0x1008000f, 500 501 /* Firmware version out of range in vb2_load_fw_preamble() */ 502 VB2_ERROR_FW_PREAMBLE_VERSION_RANGE = 0x10080010, 503 504 /* Firmware version rollback in vb2_load_fw_preamble() */ 505 VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK = 0x10080011, 506 507 /* Not enough space in work buffer for resource object */ 508 VB2_ERROR_READ_RESOURCE_OBJECT_BUF = 0x10080012, 509 510 /* Work buffer too small for header in vb2_load_kernel_keyblock() */ 511 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF_HEADER = 0x10080013, 512 513 /* Work buffer too small for keyblock in vb2_load_kernel_keyblock() */ 514 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF = 0x10080014, 515 516 /* Keyblock version out of range in vb2_load_kernel_keyblock() */ 517 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_RANGE = 0x10080015, 518 519 /* Keyblock version rollback in vb2_load_kernel_keyblock() */ 520 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_ROLLBACK = 0x10080016, 521 522 /* 523 * Keyblock flags don't match current mode in 524 * vb2_load_kernel_keyblock(). 525 */ 526 VB2_ERROR_KERNEL_KEYBLOCK_DEV_FLAG = 0x10080017, 527 VB2_ERROR_KERNEL_KEYBLOCK_REC_FLAG = 0x10080018, 528 529 /* Missing firmware data key in vb2_load_kernel_preamble() */ 530 VB2_ERROR_KERNEL_PREAMBLE2_DATA_KEY = 0x10080019, 531 532 /* Work buffer too small for header in vb2_load_kernel_preamble() */ 533 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF_HEADER = 0x1008001a, 534 535 /* Work buffer too small for preamble in vb2_load_kernel_preamble() */ 536 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF = 0x1008001b, 537 538 /* Kernel version out of range in vb2_load_kernel_preamble() */ 539 VB2_ERROR_KERNEL_PREAMBLE_VERSION_RANGE = 0x1008001c, 540 541 /* Kernel version rollback in vb2_load_kernel_preamble() */ 542 VB2_ERROR_KERNEL_PREAMBLE_VERSION_ROLLBACK = 0x1008001d, 543 544 /* Kernel preamble not loaded before calling vb2api_get_kernel_size() */ 545 VB2_ERROR_API_GET_KERNEL_SIZE_PREAMBLE = 0x1008001e, 546 547 /* Unable to unpack kernel subkey in vb2_verify_vblock(); 548 * deprecated and replaced with VB2_ERROR_UNPACK_KEY_* */ 549 VB2_ERROR_DEPRECATED_VBLOCK_KERNEL_SUBKEY = 0x1008001f, 550 551 /* 552 * Got a self-signed kernel in vb2_verify_vblock(), but need an 553 * officially signed one; deprecated and replaced with 554 * VB2_ERROR_KERNEL_KEYBLOCK_*. 555 */ 556 VB2_ERROR_DEPRECATED_VBLOCK_SELF_SIGNED = 0x10080020, 557 558 /* Invalid keyblock hash in vb2_verify_vblock(); 559 * deprecated and replaced with VB2_ERROR_KERNEL_KEYBLOCK_* */ 560 VB2_ERROR_DEPRECATED_VBLOCK_KEYBLOCK_HASH = 0x10080021, 561 562 /* Invalid keyblock in vb2_verify_vblock(); 563 * deprecated and replaced with VB2_ERROR_KERNEL_KEYBLOCK_* */ 564 VB2_ERROR_DEPRECATED_VBLOCK_KEYBLOCK = 0x10080022, 565 566 /* Wrong dev key hash in vb2_verify_kernel_vblock_dev_key_hash() */ 567 VB2_ERROR_KERNEL_KEYBLOCK_DEV_KEY_HASH = 0x10080023, 568 569 /* Work buffer too small in vb2_load_partition() */ 570 VB2_ERROR_LOAD_PARTITION_WORKBUF = 0x10080024, 571 572 /* Unable to read vblock in vb2_load_partition() */ 573 VB2_ERROR_LOAD_PARTITION_READ_VBLOCK = 0x10080025, 574 575 /* Unable to verify vblock in vb2_load_partition() */ 576 VB2_ERROR_LOAD_PARTITION_VERIFY_VBLOCK = 0x10080026, 577 578 /* Kernel body offset too large in vb2_load_partition() */ 579 VB2_ERROR_LOAD_PARTITION_BODY_OFFSET = 0x10080027, 580 581 /* Kernel body too big in vb2_load_partition() */ 582 VB2_ERROR_LOAD_PARTITION_BODY_SIZE = 0x10080028, 583 584 /* Unable to read kernel body in vb2_load_partition() */ 585 VB2_ERROR_LOAD_PARTITION_READ_BODY = 0x10080029, 586 587 /* Unable to unpack data key in vb2_load_partition() */ 588 VB2_ERROR_LOAD_PARTITION_DATA_KEY = 0x1008002a, 589 590 /* Unable to verify body in vb2_load_partition() */ 591 VB2_ERROR_LOAD_PARTITION_VERIFY_BODY = 0x1008002b, 592 593 /* Unable to get EC image hash in ec_sync_phase1() */ 594 VB2_ERROR_EC_HASH_IMAGE = 0x1008002c, 595 596 /* Unable to get expected EC image hash in ec_sync_phase1() */ 597 VB2_ERROR_EC_HASH_EXPECTED = 0x1008002d, 598 599 /* Expected and image hashes are different size in ec_sync_phase1() */ 600 VB2_ERROR_EC_HASH_SIZE = 0x1008002e, 601 602 /* Incompatible version for vb2_shared_data structure being loaded */ 603 VB2_ERROR_SHARED_DATA_VERSION = 0x1008002f, 604 605 /* Bad magic number in vb2_shared_data structure */ 606 VB2_ERROR_SHARED_DATA_MAGIC = 0x10080030, 607 608 /* Some part of GBB data is invalid */ 609 VB2_ERROR_GBB_INVALID = 0x10080031, 610 611 /* Invalid parameter */ 612 VB2_ERROR_INVALID_PARAMETER = 0x10080032, 613 614 /* Problem with workbuf validity (see vb2api_init and vb2api_reinit) */ 615 VB2_ERROR_WORKBUF_INVALID = 0x10080033, 616 617 /* Escape from NO_BOOT mode is detected */ 618 VB2_ERROR_ESCAPE_NO_BOOT = 0x10080034, 619 620 /* 621 * Keyblock flags don't match current mode in 622 * vb2_load_kernel_keyblock(). 623 */ 624 VB2_ERROR_KERNEL_KEYBLOCK_MINIOS_FLAG = 0x10080035, 625 626 /********************************************************************** 627 * API-level errors 628 */ 629 VB2_ERROR_API = VB2_ERROR_BASE + 0x090000, 630 631 /* Bad tag in vb2api_init_hash() */ 632 VB2_ERROR_API_INIT_HASH_TAG, 633 634 /* Preamble not present in vb2api_init_hash() */ 635 VB2_ERROR_API_INIT_HASH_PREAMBLE, 636 637 /* Work buffer too small in vb2api_init_hash() */ 638 VB2_ERROR_API_INIT_HASH_WORKBUF, 639 640 /* Missing firmware data key in vb2api_init_hash() */ 641 VB2_ERROR_API_INIT_HASH_DATA_KEY, 642 643 /* Uninitialized work area in vb2api_extend_hash() */ 644 VB2_ERROR_API_EXTEND_HASH_WORKBUF, 645 646 /* Too much data hashed in vb2api_extend_hash() */ 647 VB2_ERROR_API_EXTEND_HASH_SIZE, 648 649 /* Preamble not present in vb2api_check_hash() */ 650 VB2_ERROR_API_CHECK_HASH_PREAMBLE, 651 652 /* Uninitialized work area in vb2api_check_hash() */ 653 VB2_ERROR_API_CHECK_HASH_WORKBUF, 654 655 /* Wrong amount of data hashed in vb2api_check_hash() */ 656 VB2_ERROR_API_CHECK_HASH_SIZE, 657 658 /* Work buffer too small in vb2api_check_hash() */ 659 VB2_ERROR_API_CHECK_HASH_WORKBUF_DIGEST, 660 661 /* Bad tag in vb2api_check_hash() */ 662 VB2_ERROR_API_CHECK_HASH_TAG, 663 664 /* Missing firmware data key in vb2api_check_hash() */ 665 VB2_ERROR_API_CHECK_HASH_DATA_KEY, 666 667 /* Signature size mismatch in vb2api_check_hash() */ 668 VB2_ERROR_API_CHECK_HASH_SIG_SIZE, 669 670 /* Phase one needs recovery mode */ 671 VB2_ERROR_API_PHASE1_RECOVERY, 672 673 /* Bad tag in vb2api_check_hash() */ 674 VB2_ERROR_API_INIT_HASH_ID, 675 676 /* Signature mismatch in vb2api_check_hash() */ 677 VB2_ERROR_API_CHECK_HASH_SIG, 678 679 /* Invalid enum vb2_pcr_digest requested to vb2api_get_pcr_digest */ 680 VB2_ERROR_API_PCR_DIGEST, 681 682 /* Buffer size for the digest is too small for vb2api_get_pcr_digest */ 683 VB2_ERROR_API_PCR_DIGEST_BUF, 684 685 /* Work buffer too small for recovery key in vb2api_kernel_phase1(); 686 * Deprecated: use vb2_gbb_read_recovery_key return values */ 687 VB2_ERROR_DEPRECATED_API_KPHASE1_WORKBUF_REC_KEY, 688 689 /* Firmware preamble not present for vb2api_kernel_phase1() */ 690 VB2_ERROR_API_KPHASE1_PREAMBLE, 691 692 /* Wrong amount of kernel data in vb2api_verify_kernel_data() */ 693 VB2_ERROR_API_VERIFY_KDATA_SIZE, 694 695 /* Kernel preamble not present for vb2api_verify_kernel_data() */ 696 VB2_ERROR_API_VERIFY_KDATA_PREAMBLE, 697 698 /* Insufficient workbuf for hashing in vb2api_verify_kernel_data() */ 699 VB2_ERROR_API_VERIFY_KDATA_WORKBUF, 700 701 /* Bad data key in vb2api_verify_kernel_data() */ 702 VB2_ERROR_API_VERIFY_KDATA_KEY, 703 704 /* Phase one passing through secdata's request to reboot */ 705 VB2_ERROR_API_PHASE1_SECDATA_REBOOT, 706 707 /* Digest buffer passed into vb2api_check_hash incorrect. */ 708 VB2_ERROR_API_CHECK_DIGEST_SIZE, 709 710 /* Disabling developer mode is not allowed by GBB flags */ 711 VB2_ERROR_API_DISABLE_DEV_NOT_ALLOWED, 712 713 /* Enabling developer mode is not allowed in non-recovery mode */ 714 VB2_ERROR_API_ENABLE_DEV_NOT_ALLOWED, 715 716 /* Failed to select next slot in vb2_select_fw_slot() */ 717 VB2_ERROR_API_NEXT_SLOT_UNAVAILABLE, 718 719 /********************************************************************** 720 * Errors which may be generated by implementations of vb2ex functions. 721 * Implementation may also return its own specific errors, which should 722 * NOT be in the range VB2_ERROR_BASE...VB2_ERROR_MAX to avoid 723 * conflicting with future vboot2 error codes. 724 */ 725 VB2_ERROR_EX = VB2_ERROR_BASE + 0x0a0000, 726 727 /* Read resource not implemented 728 * Deprecated: use VB2_ERROR_EX_UNIMPLEMENTED (chromium:944804) */ 729 VB2_ERROR_EX_DEPRECATED_READ_RESOURCE_UNIMPLEMENTED, 730 731 /* Resource index not found */ 732 VB2_ERROR_EX_READ_RESOURCE_INDEX, 733 734 /* Size of resource not big enough for requested offset and/or size */ 735 VB2_ERROR_EX_READ_RESOURCE_SIZE, 736 737 /* TPM clear owner failed */ 738 VB2_ERROR_EX_TPM_CLEAR_OWNER, 739 740 /* TPM clear owner not implemented 741 * Deprecated: use VB2_ERROR_EX_UNIMPLEMENTED (chromium:944804) */ 742 VB2_ERROR_DEPRECATED_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED, 743 744 /* Hardware crypto engine doesn't support this algorithm (non-fatal) */ 745 VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED, 746 747 /* TPM does not understand this command */ 748 VB2_ERROR_EX_TPM_NO_SUCH_COMMAND, 749 750 /* vb2ex function is unimplemented (stubbed in 2lib/2stub.c) */ 751 VB2_ERROR_EX_UNIMPLEMENTED, 752 753 /* AUXFW peripheral busy. Cannot upgrade firmware at present. */ 754 VB2_ERROR_EX_AUXFW_PERIPHERAL_BUSY, 755 756 /* Error setting vendor data (see: VbExSetVendorData). 757 * Deprecated: functionality removed with legacy UI (b/167643628) */ 758 VB2_ERROR_DEPRECATED_EX_SET_VENDOR_DATA, 759 760 /* The memory test is running but the output buffer was unchanged. 761 Deprecated with b/172339016. */ 762 VB2_ERROR_DEPRECATED_EX_DIAG_TEST_RUNNING, 763 764 /* The memory test is running and the output buffer was updated. 765 Deprecated with b/172339016. */ 766 VB2_ERROR_DEPRECATED_EX_DIAG_TEST_UPDATED, 767 768 /* The memory test initialization failed. 769 Deprecated with b/172339016. */ 770 VB2_ERROR_DEPRECATED_EX_DIAG_TEST_INIT_FAILED, 771 772 /********************************************************************** 773 * Kernel loading errors 774 * 775 * Should be ordered by specificity -- lower number means more specific. 776 */ 777 VB2_ERROR_LK = 0x100b0000, 778 779 /* Only an invalid kernel was found in vb2api_load_kernel() */ 780 VB2_ERROR_LK_INVALID_KERNEL_FOUND = 0x100b1000, 781 782 /* No kernel partitions were found in vb2api_load_kernel() */ 783 VB2_ERROR_LK_NO_KERNEL_FOUND = 0x100b2000, 784 785 /* No working block devices were found */ 786 VB2_ERROR_LK_NO_DISK_FOUND = 0x100b3000, 787 788 /********************************************************************** 789 * UI errors 790 */ 791 VB2_ERROR_UI = 0x100c0000, 792 793 /* Display initialization failed */ 794 VB2_ERROR_UI_DISPLAY_INIT = 0x100c0001, 795 796 /* Problem finding screen entry or its draw function */ 797 VB2_ERROR_UI_INVALID_SCREEN = 0x100c0002, 798 799 /* Screen drawing failed, including all CBGFX_ERROR_* errors returned 800 from libpayload */ 801 VB2_ERROR_UI_DRAW_FAILURE = 0x100c0003, 802 803 /* Problem loading archive from CBFS */ 804 VB2_ERROR_UI_INVALID_ARCHIVE = 0x100c0004, 805 806 /* Image not found in the archive */ 807 VB2_ERROR_UI_MISSING_IMAGE = 0x100c0005, 808 809 /* Requested locale not available */ 810 VB2_ERROR_UI_INVALID_LOCALE = 0x100c0006, 811 812 /* Memory allocation failure */ 813 VB2_ERROR_UI_MEMORY_ALLOC = 0x100c0007, 814 815 /* Log screen initialization failed */ 816 VB2_ERROR_UI_LOG_INIT = 0x100c0008, 817 818 /********************************************************************** 819 * Errors generated by host library (non-firmware) start here. 820 */ 821 VB2_ERROR_HOST_BASE = 0x20000000, 822 823 /********************************************************************** 824 * Errors generated by host library misc functions 825 */ 826 VB2_ERROR_HOST_MISC = VB2_ERROR_HOST_BASE + 0x010000, 827 828 /* Unable to open file in read_file() */ 829 VB2_ERROR_READ_FILE_OPEN, 830 831 /* Bad size in read_file() */ 832 VB2_ERROR_READ_FILE_SIZE, 833 834 /* Unable to allocate buffer in read_file() */ 835 VB2_ERROR_READ_FILE_ALLOC, 836 837 /* Unable to read data in read_file() */ 838 VB2_ERROR_READ_FILE_DATA, 839 840 /* Unable to open file in write_file() */ 841 VB2_ERROR_WRITE_FILE_OPEN, 842 843 /* Unable to write data in write_file() */ 844 VB2_ERROR_WRITE_FILE_DATA, 845 846 /* Unable to convert string to struct vb_id */ 847 VB2_ERROR_STR_TO_ID, 848 849 /* Flashrom exited with failure status */ 850 VB2_ERROR_FLASHROM, 851 852 /* cbfstool exited with failure status */ 853 VB2_ERROR_CBFSTOOL, 854 855 /********************************************************************** 856 * Errors generated by host library key functions 857 */ 858 VB2_ERROR_HOST_KEY = VB2_ERROR_HOST_BASE + 0x020000, 859 860 /* Unable to allocate key in vb2_private_key_read_pem() */ 861 VB2_ERROR_READ_PEM_ALLOC, 862 863 /* Unable to open .pem file in vb2_private_key_read_pem() */ 864 VB2_ERROR_READ_PEM_FILE_OPEN, 865 866 /* Bad RSA data from .pem file in vb2_private_key_read_pem() */ 867 VB2_ERROR_READ_PEM_RSA, 868 869 /* Unable to set private key description */ 870 VB2_ERROR_PRIVATE_KEY_SET_DESC, 871 872 /* Bad magic number in vb2_private_key_unpack() */ 873 VB2_ERROR_UNPACK_PRIVATE_KEY_MAGIC, 874 875 /* Bad common header in vb2_private_key_unpack() */ 876 VB2_ERROR_UNPACK_PRIVATE_KEY_HEADER, 877 878 /* Bad key data in vb2_private_key_unpack() */ 879 VB2_ERROR_UNPACK_PRIVATE_KEY_DATA, 880 881 /* Bad struct version in vb2_private_key_unpack() */ 882 VB2_ERROR_UNPACK_PRIVATE_KEY_STRUCT_VERSION, 883 884 /* Unable to allocate buffer in vb2_private_key_unpack() */ 885 VB2_ERROR_UNPACK_PRIVATE_KEY_ALLOC, 886 887 /* Unable to unpack RSA key in vb2_private_key_unpack() */ 888 VB2_ERROR_UNPACK_PRIVATE_KEY_RSA, 889 890 /* Unable to set description in vb2_private_key_unpack() */ 891 VB2_ERROR_UNPACK_PRIVATE_KEY_DESC, 892 893 /* Bad bare hash key in vb2_private_key_unpack() */ 894 VB2_ERROR_UNPACK_PRIVATE_KEY_HASH, 895 896 /* Unable to create RSA data in vb2_private_key_write() */ 897 VB2_ERROR_PRIVATE_KEY_WRITE_RSA, 898 899 /* Unable to allocate packed key buffer in vb2_private_key_write() */ 900 VB2_ERROR_PRIVATE_KEY_WRITE_ALLOC, 901 902 /* Unable to write file in vb2_private_key_write() */ 903 VB2_ERROR_PRIVATE_KEY_WRITE_FILE, 904 905 /* Bad algorithm in vb2_private_key_hash() */ 906 VB2_ERROR_PRIVATE_KEY_HASH, 907 908 /* Unable to determine key size in vb2_public_key_alloc() */ 909 VB2_ERROR_PUBLIC_KEY_ALLOC_SIZE, 910 911 /* Unable to allocate buffer in vb2_public_key_alloc() */ 912 VB2_ERROR_PUBLIC_KEY_ALLOC, 913 914 /* Unable to set public key description */ 915 VB2_ERROR_PUBLIC_KEY_SET_DESC, 916 917 /* Unable to read key data in vb2_public_key_read_keyb() */ 918 VB2_ERROR_READ_KEYB_DATA, 919 920 /* Wrong amount of data read in vb2_public_key_read_keyb() */ 921 VB2_ERROR_READ_KEYB_SIZE, 922 923 /* Unable to allocate key buffer in vb2_public_key_read_keyb() */ 924 VB2_ERROR_READ_KEYB_ALLOC, 925 926 /* Error unpacking RSA arrays in vb2_public_key_read_keyb() */ 927 VB2_ERROR_READ_KEYB_UNPACK, 928 929 /* Unable to read key data in vb2_packed_key_read() */ 930 VB2_ERROR_READ_PACKED_KEY_DATA, 931 932 /* Bad key data in vb2_packed_key_read() */ 933 VB2_ERROR_READ_PACKED_KEY, 934 935 /* Unable to determine key size in vb2_public_key_pack() */ 936 VB2_ERROR_PUBLIC_KEY_PACK_SIZE, 937 938 /* Bad hash algorithm in vb2_public_key_hash() */ 939 VB2_ERROR_PUBLIC_KEY_HASH, 940 941 /* Bad key size in vb2_copy_packed_key() */ 942 VB2_ERROR_COPY_KEY_SIZE, 943 944 /* Unable to convert back to vb1 crypto algorithm */ 945 VB2_ERROR_VB1_CRYPTO_ALGORITHM, 946 947 /* Unable to allocate packed key */ 948 VB2_ERROR_PACKED_KEY_ALLOC, 949 950 /* Unable to copy packed key */ 951 VB2_ERROR_PACKED_KEY_COPY, 952 953 /* Packed key with invalid version */ 954 VB2_ERROR_PACKED_KEY_VERSION, 955 956 /********************************************************************** 957 * Errors generated by host library signature functions 958 */ 959 VB2_ERROR_HOST_SIG = VB2_ERROR_HOST_BASE + 0x030000, 960 961 /* Bad hash algorithm in vb2_digest_info() */ 962 VB2_ERROR_DIGEST_INFO, 963 964 /* 965 * Unable to determine signature size for key algorithm in 966 * vb2_sig_size_for_key(). 967 */ 968 VB2_ERROR_SIG_SIZE_FOR_KEY, 969 970 /* Bad signature size in vb2_sign_data() */ 971 VB2_SIGN_DATA_SIG_SIZE, 972 973 /* Unable to get digest info in vb2_sign_data() */ 974 VB2_SIGN_DATA_DIGEST_INFO, 975 976 /* Unable to get digest size in vb2_sign_data() */ 977 VB2_SIGN_DATA_DIGEST_SIZE, 978 979 /* Unable to allocate digest buffer in vb2_sign_data() */ 980 VB2_SIGN_DATA_DIGEST_ALLOC, 981 982 /* Unable to initialize digest in vb2_sign_data() */ 983 VB2_SIGN_DATA_DIGEST_INIT, 984 985 /* Unable to extend digest in vb2_sign_data() */ 986 VB2_SIGN_DATA_DIGEST_EXTEND, 987 988 /* Unable to finalize digest in vb2_sign_data() */ 989 VB2_SIGN_DATA_DIGEST_FINALIZE, 990 991 /* RSA encrypt failed in vb2_sign_data() */ 992 VB2_SIGN_DATA_RSA_ENCRYPT, 993 994 /* Not enough buffer space to hold signature in vb2_sign_object() */ 995 VB2_SIGN_OBJECT_OVERFLOW, 996 997 /********************************************************************** 998 * Errors generated by host library keyblock functions 999 */ 1000 VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000, 1001 1002 /* Unable to determine signature sizes for vb2_create_keyblock() */ 1003 VB2_KEYBLOCK_CREATE_SIG_SIZE, 1004 1005 /* Unable to pack data key for vb2_create_keyblock() */ 1006 VB2_KEYBLOCK_CREATE_DATA_KEY, 1007 1008 /* Unable to allocate buffer in vb2_create_keyblock() */ 1009 VB2_KEYBLOCK_CREATE_ALLOC, 1010 1011 /* Unable to sign keyblock in vb2_create_keyblock() */ 1012 VB2_KEYBLOCK_CREATE_SIGN, 1013 1014 /********************************************************************** 1015 * Errors generated by host library firmware preamble functions 1016 */ 1017 VB2_ERROR_HOST_FW_PREAMBLE = VB2_ERROR_HOST_BASE + 0x050000, 1018 1019 /* Unable to determine signature sizes for vb2_create_fw_preamble() */ 1020 VB2_FW_PREAMBLE_CREATE_SIG_SIZE, 1021 1022 /* Unable to allocate buffer in vb2_create_fw_preamble() */ 1023 VB2_FW_PREAMBLE_CREATE_ALLOC, 1024 1025 /* Unable to sign preamble in vb2_create_fw_preamble() */ 1026 VB2_FW_PREAMBLE_CREATE_SIGN, 1027 1028 /********************************************************************** 1029 * Errors generated by unit test functions 1030 */ 1031 VB2_ERROR_UNIT_TEST = VB2_ERROR_HOST_BASE + 0x060000, 1032 1033 /* Unable to open an input file needed for a unit test */ 1034 VB2_ERROR_TEST_INPUT_FILE, 1035 1036 /********************************************************************** 1037 * Highest non-zero error generated inside vboot library. Note that 1038 * error codes passed through vboot when it calls external APIs may 1039 * still be outside this range. 1040 */ 1041 VB2_ERROR_MAX = VB2_ERROR_BASE + 0x1fffffff, 1042 }; 1043 1044 #endif /* VBOOT_REFERENCE_2RETURN_CODES_H_ */ 1045