Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 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 | |
| 6 | #ifndef VBOOT_2_RETURN_CODES_H_ |
| 7 | #define VBOOT_2_RETURN_CODES_H_ |
| 8 | |
| 9 | /* |
| 10 | * Return codes from verified boot functions. |
| 11 | * |
| 12 | * TODO: Go through code and replace VB2_ERROR_UNKNOWN with more specific |
| 13 | * error codes, and make the existing codes more consistent and useful. |
| 14 | */ |
| 15 | enum vb2_return_code { |
| 16 | /* Success - no error */ |
| 17 | VB2_SUCCESS = 0, |
| 18 | |
Randall Spangler | b9be536 | 2014-06-05 13:32:11 -0700 | [diff] [blame] | 19 | /* |
| 20 | * All vboot2 error codes start at a large offset from zero, to reduce |
| 21 | * the risk of overlap with other error codes (TPM, etc.). |
| 22 | */ |
| 23 | VB2_ERROR_BASE = 0x0100000, |
| 24 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 25 | /* Unknown / unspecified error */ |
Randall Spangler | b9be536 | 2014-06-05 13:32:11 -0700 | [diff] [blame] | 26 | VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1, |
| 27 | |
| 28 | /********************************************************************** |
| 29 | * SHA errors |
| 30 | */ |
| 31 | VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000, |
| 32 | |
| 33 | /* Bad algorithm in vb2_digest_init() */ |
| 34 | VB2_ERROR_SHA_INIT_ALGORITHM, |
| 35 | |
| 36 | /* Bad algorithm in vb2_digest_extend() */ |
| 37 | VB2_ERROR_SHA_EXTEND_ALGORITHM, |
| 38 | |
| 39 | /* Bad algorithm in vb2_digest_finalize() */ |
| 40 | VB2_ERROR_SHA_FINALIZE_ALGORITHM, |
| 41 | |
| 42 | /* Digest size buffer too small in vb2_digest_finalize() */ |
| 43 | VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE, |
| 44 | |
| 45 | /********************************************************************** |
| 46 | * RSA errors |
| 47 | */ |
| 48 | VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000, |
| 49 | |
| 50 | /* Padding mismatch in vb2_check_padding() */ |
| 51 | VB2_ERROR_RSA_PADDING, |
| 52 | |
| 53 | /* Bad algorithm in vb2_check_padding() */ |
| 54 | VB2_ERROR_RSA_PADDING_ALGORITHM, |
| 55 | |
| 56 | /* Null param passed to vb2_verify_digest() */ |
| 57 | VB2_ERROR_RSA_VERIFY_PARAM, |
| 58 | |
| 59 | /* Bad algorithm in vb2_verify_digest() */ |
| 60 | VB2_ERROR_RSA_VERIFY_ALGORITHM, |
| 61 | |
| 62 | /* Bad signature length in vb2_verify_digest() */ |
| 63 | VB2_ERROR_RSA_VERIFY_SIG_LEN, |
| 64 | |
| 65 | /* Work buffer too small in vb2_verify_digest() */ |
| 66 | VB2_ERROR_RSA_VERIFY_WORKBUF, |
| 67 | |
| 68 | /* Digest mismatch in vb2_verify_digest() */ |
| 69 | VB2_ERROR_RSA_VERIFY_DIGEST, |
| 70 | |
| 71 | /********************************************************************** |
| 72 | * NV storage errors |
| 73 | */ |
| 74 | VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000, |
| 75 | |
| 76 | /* Bad header in vb2_nv_check_crc() */ |
| 77 | VB2_ERROR_NV_HEADER, |
| 78 | |
| 79 | /* Bad CRC in vb2_nv_check_crc() */ |
| 80 | VB2_ERROR_NV_CRC, |
| 81 | |
| 82 | /********************************************************************** |
| 83 | * Secure data storage errors |
| 84 | */ |
| 85 | VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000, |
| 86 | |
| 87 | /* Bad CRC in vb2_secdata_check_crc() */ |
| 88 | VB2_ERROR_SECDATA_CRC, |
| 89 | |
| 90 | /* Bad struct version in vb2_secdata_init() */ |
| 91 | VB2_ERROR_SECDATA_VERSION, |
| 92 | |
| 93 | /* Invalid param in vb2_secdata_get() */ |
| 94 | VB2_ERROR_SECDATA_GET_PARAM, |
| 95 | |
| 96 | /* Invalid param in vb2_secdata_set() */ |
| 97 | VB2_ERROR_SECDATA_SET_PARAM, |
| 98 | |
| 99 | /* Invalid flags passed to vb2_secdata_set() */ |
| 100 | VB2_ERROR_SECDATA_SET_FLAGS, |
| 101 | |
| 102 | /********************************************************************** |
Randall Spangler | 2145721 | 2014-06-06 09:30:14 -0700 | [diff] [blame^] | 103 | * Common code errors |
| 104 | */ |
| 105 | VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000, |
| 106 | |
| 107 | /* Buffer is smaller than alignment offset in vb2_align() */ |
| 108 | VB2_ERROR_ALIGN_BIGGER_THAN_SIZE, |
| 109 | |
| 110 | /* Buffer is smaller than request in vb2_align() */ |
| 111 | VB2_ERROR_ALIGN_SIZE, |
| 112 | |
| 113 | /* Parent wraps around in vb2_verify_member_inside() */ |
| 114 | VB2_ERROR_INSIDE_PARENT_WRAPS, |
| 115 | |
| 116 | /* Member wraps around in vb2_verify_member_inside() */ |
| 117 | VB2_ERROR_INSIDE_MEMBER_WRAPS, |
| 118 | |
| 119 | /* Member outside parent in vb2_verify_member_inside() */ |
| 120 | VB2_ERROR_INSIDE_MEMBER_OUTSIDE, |
| 121 | |
| 122 | /* Member data wraps around in vb2_verify_member_inside() */ |
| 123 | VB2_ERROR_INSIDE_DATA_WRAPS, |
| 124 | |
| 125 | /* Member data outside parent in vb2_verify_member_inside() */ |
| 126 | VB2_ERROR_INSIDE_DATA_OUTSIDE, |
| 127 | |
| 128 | /********************************************************************** |
Randall Spangler | b9be536 | 2014-06-05 13:32:11 -0700 | [diff] [blame] | 129 | * TODO: errors which must still be made specific |
| 130 | */ |
| 131 | VB2_ERROR_TODO = VB2_ERROR_BASE + 0xff0000, |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 132 | |
| 133 | /* Work buffer too small */ |
| 134 | VB2_ERROR_WORKBUF_TOO_SMALL, |
| 135 | |
| 136 | /* Buffer too small (other than the work buffer) */ |
| 137 | VB2_ERROR_BUFFER_TOO_SMALL, |
| 138 | |
| 139 | /* Buffer unaligned */ |
| 140 | VB2_ERROR_BUFFER_UNALIGNED, |
| 141 | |
| 142 | /* Bad GBB header */ |
| 143 | VB2_ERROR_BAD_GBB_HEADER, |
| 144 | |
| 145 | /* Bad algorithm - unknown, or unsupported */ |
| 146 | VB2_ERROR_BAD_ALGORITHM, |
| 147 | |
| 148 | /* Signature check failed */ |
| 149 | VB2_ERROR_BAD_SIGNATURE, |
| 150 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 151 | /* Bad key */ |
| 152 | VB2_ERROR_BAD_KEY, |
| 153 | |
| 154 | /* Bad keyblock */ |
| 155 | VB2_ERROR_BAD_KEYBLOCK, |
| 156 | |
| 157 | /* Bad preamble */ |
| 158 | VB2_ERROR_BAD_PREAMBLE, |
| 159 | |
| 160 | /* Bad firmware keyblock version (out of range, or rollback) */ |
| 161 | VB2_ERROR_FW_KEYBLOCK_VERSION, |
| 162 | |
| 163 | /* Bad firmware version (out of range, or rollback) */ |
| 164 | VB2_ERROR_FW_VERSION, |
| 165 | |
| 166 | /* Bad hash tag */ |
| 167 | VB2_ERROR_BAD_TAG, |
Randall Spangler | b9be536 | 2014-06-05 13:32:11 -0700 | [diff] [blame] | 168 | |
| 169 | /********************************************************************** |
| 170 | * Highest non-zero error generated inside vboot library. Note that |
| 171 | * error codes passed through vboot when it calls external APIs may |
| 172 | * still be outside this range. |
| 173 | */ |
| 174 | VB2_ERROR_MAX = VB2_ERROR_BASE + 0xffffff, |
| 175 | |
Randall Spangler | 786acda | 2014-05-22 13:27:07 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | #endif /* VBOOT_2_RETURN_CODES_H_ */ |