blob: 27b80d1690f01054aca2280765a67b304e04d82a [file] [log] [blame]
Randall Spangler786acda2014-05-22 13:27:07 -07001/* 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 *
Randall Spanglerda2b49c2014-06-10 17:03:40 -070012 * Note that other values may be passed through from vb2ex_*() calls; see
13 * the comment for VB2_ERROR_EX below.
Randall Spangler786acda2014-05-22 13:27:07 -070014 */
15enum vb2_return_code {
16 /* Success - no error */
17 VB2_SUCCESS = 0,
18
Randall Spanglerb9be5362014-06-05 13:32:11 -070019 /*
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 */
Randall Spangler02e11b32014-11-19 12:48:36 -080023 VB2_ERROR_BASE = 0x10000000,
Randall Spanglerb9be5362014-06-05 13:32:11 -070024
Randall Spangler786acda2014-05-22 13:27:07 -070025 /* Unknown / unspecified error */
Randall Spanglerb9be5362014-06-05 13:32:11 -070026 VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1,
27
Randall Spanglera7ab8b52014-06-10 17:05:08 -070028 /* Mock error for testing */
29 VB2_ERROR_MOCK,
30
Randall Spanglerb9be5362014-06-05 13:32:11 -070031 /**********************************************************************
32 * SHA errors
33 */
34 VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000,
35
36 /* Bad algorithm in vb2_digest_init() */
37 VB2_ERROR_SHA_INIT_ALGORITHM,
38
39 /* Bad algorithm in vb2_digest_extend() */
40 VB2_ERROR_SHA_EXTEND_ALGORITHM,
41
42 /* Bad algorithm in vb2_digest_finalize() */
43 VB2_ERROR_SHA_FINALIZE_ALGORITHM,
44
45 /* Digest size buffer too small in vb2_digest_finalize() */
46 VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE,
47
48 /**********************************************************************
49 * RSA errors
50 */
51 VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000,
52
53 /* Padding mismatch in vb2_check_padding() */
54 VB2_ERROR_RSA_PADDING,
55
56 /* Bad algorithm in vb2_check_padding() */
57 VB2_ERROR_RSA_PADDING_ALGORITHM,
58
59 /* Null param passed to vb2_verify_digest() */
60 VB2_ERROR_RSA_VERIFY_PARAM,
61
62 /* Bad algorithm in vb2_verify_digest() */
63 VB2_ERROR_RSA_VERIFY_ALGORITHM,
64
65 /* Bad signature length in vb2_verify_digest() */
66 VB2_ERROR_RSA_VERIFY_SIG_LEN,
67
68 /* Work buffer too small in vb2_verify_digest() */
69 VB2_ERROR_RSA_VERIFY_WORKBUF,
70
71 /* Digest mismatch in vb2_verify_digest() */
72 VB2_ERROR_RSA_VERIFY_DIGEST,
73
Randall Spanglerc8c2f022014-10-23 09:48:20 -070074 /* Bad size calculation in vb2_check_padding() */
75 VB2_ERROR_RSA_PADDING_SIZE,
76
Randall Spanglerb9be5362014-06-05 13:32:11 -070077 /**********************************************************************
78 * NV storage errors
79 */
80 VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000,
81
82 /* Bad header in vb2_nv_check_crc() */
83 VB2_ERROR_NV_HEADER,
84
85 /* Bad CRC in vb2_nv_check_crc() */
86 VB2_ERROR_NV_CRC,
87
88 /**********************************************************************
89 * Secure data storage errors
90 */
91 VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000,
92
93 /* Bad CRC in vb2_secdata_check_crc() */
94 VB2_ERROR_SECDATA_CRC,
95
Julius Werner7e216982015-05-29 16:56:20 -070096 /* Secdata is all zeroes (uninitialized) in vb2_secdata_check_crc() */
97 VB2_ERROR_SECDATA_ZERO,
Randall Spanglerb9be5362014-06-05 13:32:11 -070098
99 /* Invalid param in vb2_secdata_get() */
100 VB2_ERROR_SECDATA_GET_PARAM,
101
102 /* Invalid param in vb2_secdata_set() */
103 VB2_ERROR_SECDATA_SET_PARAM,
104
105 /* Invalid flags passed to vb2_secdata_set() */
106 VB2_ERROR_SECDATA_SET_FLAGS,
107
Julius Wernerb550fb12015-01-30 14:27:54 -0800108 /* Called vb2_secdata_get() with uninitialized secdata */
109 VB2_ERROR_SECDATA_GET_UNINITIALIZED,
110
111 /* Called vb2_secdata_set() with uninitialized secdata */
112 VB2_ERROR_SECDATA_SET_UNINITIALIZED,
113
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700114 /* Bad CRC in vb2_secdatak_check_crc() */
115 VB2_ERROR_SECDATAK_CRC,
116
117 /* Bad struct version in vb2_secdatak_init() */
118 VB2_ERROR_SECDATAK_VERSION,
119
120 /* Bad uid in vb2_secdatak_init() */
121 VB2_ERROR_SECDATAK_UID,
122
123 /* Invalid param in vb2_secdatak_get() */
124 VB2_ERROR_SECDATAK_GET_PARAM,
125
126 /* Invalid param in vb2_secdatak_set() */
127 VB2_ERROR_SECDATAK_SET_PARAM,
128
129 /* Invalid flags passed to vb2_secdatak_set() */
130 VB2_ERROR_SECDATAK_SET_FLAGS,
131
132 /* Called vb2_secdatak_get() with uninitialized secdatak */
133 VB2_ERROR_SECDATAK_GET_UNINITIALIZED,
134
135 /* Called vb2_secdatak_set() with uninitialized secdatak */
136 VB2_ERROR_SECDATAK_SET_UNINITIALIZED,
137
Randall Spanglerb9be5362014-06-05 13:32:11 -0700138 /**********************************************************************
Randall Spangler21457212014-06-06 09:30:14 -0700139 * Common code errors
140 */
141 VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000,
142
143 /* Buffer is smaller than alignment offset in vb2_align() */
144 VB2_ERROR_ALIGN_BIGGER_THAN_SIZE,
145
146 /* Buffer is smaller than request in vb2_align() */
147 VB2_ERROR_ALIGN_SIZE,
148
149 /* Parent wraps around in vb2_verify_member_inside() */
150 VB2_ERROR_INSIDE_PARENT_WRAPS,
151
152 /* Member wraps around in vb2_verify_member_inside() */
153 VB2_ERROR_INSIDE_MEMBER_WRAPS,
154
155 /* Member outside parent in vb2_verify_member_inside() */
156 VB2_ERROR_INSIDE_MEMBER_OUTSIDE,
157
158 /* Member data wraps around in vb2_verify_member_inside() */
159 VB2_ERROR_INSIDE_DATA_WRAPS,
160
161 /* Member data outside parent in vb2_verify_member_inside() */
162 VB2_ERROR_INSIDE_DATA_OUTSIDE,
163
Randall Spanglerc8c2f022014-10-23 09:48:20 -0700164 /* Unsupported signature algorithm in vb2_unpack_key() */
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700165 VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM, /* 0x150008 */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700166
167 /* Bad key size in vb2_unpack_key() */
168 VB2_ERROR_UNPACK_KEY_SIZE,
169
170 /* Bad key alignment in vb2_unpack_key() */
171 VB2_ERROR_UNPACK_KEY_ALIGN,
172
173 /* Bad key array size in vb2_unpack_key() */
174 VB2_ERROR_UNPACK_KEY_ARRAY_SIZE,
175
176 /* Bad algorithm in vb2_verify_data() */
177 VB2_ERROR_VDATA_ALGORITHM,
178
179 /* Incorrect signature size for algorithm in vb2_verify_data() */
180 VB2_ERROR_VDATA_SIG_SIZE,
181
182 /* Data smaller than length of signed data in vb2_verify_data() */
183 VB2_ERROR_VDATA_NOT_ENOUGH_DATA,
184
185 /* Not enough work buffer for digest in vb2_verify_data() */
186 VB2_ERROR_VDATA_WORKBUF_DIGEST,
187
188 /* Not enough work buffer for hash temp data in vb2_verify_data() */
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700189 VB2_ERROR_VDATA_WORKBUF_HASHING, /* 0x150010 */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700190
Randall Spangler95047542014-10-17 16:41:46 -0700191 /*
192 * Bad digest size in vb2_verify_data() - probably because algorithm
193 * is bad.
194 */
195 VB2_ERROR_VDATA_DIGEST_SIZE,
196
Randall Spangler4eef8122014-10-23 10:07:54 -0700197 /* Unsupported hash algorithm in vb2_unpack_key() */
198 VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM,
199
Randall Spanglerf6cfb972014-10-23 17:04:03 -0700200 /* Member data overlaps member header */
201 VB2_ERROR_INSIDE_DATA_OVERLAP,
202
Randall Spanglerd274a2e2014-10-23 17:38:18 -0700203 /* Unsupported packed key struct version */
204 VB2_ERROR_UNPACK_KEY_STRUCT_VERSION,
205
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700206 /*
207 * Buffer too small for total, fixed size, or description reported in
208 * common header, or member data checked via
Randall Spanglerca725122016-05-25 16:42:44 -0700209 * vb21_verify_common_member().
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700210 */
211 VB2_ERROR_COMMON_TOTAL_SIZE,
212 VB2_ERROR_COMMON_FIXED_SIZE,
213 VB2_ERROR_COMMON_DESC_SIZE,
214 VB2_ERROR_COMMON_MEMBER_SIZE, /* 0x150018 */
215
216 /*
217 * Total, fixed, description, or member offset/size not a multiple of
218 * 32 bits.
219 */
220 VB2_ERROR_COMMON_TOTAL_UNALIGNED,
221 VB2_ERROR_COMMON_FIXED_UNALIGNED,
222 VB2_ERROR_COMMON_DESC_UNALIGNED,
223 VB2_ERROR_COMMON_MEMBER_UNALIGNED,
224
225 /* Common struct description or member data wraps address space */
226 VB2_ERROR_COMMON_DESC_WRAPS,
227 VB2_ERROR_COMMON_MEMBER_WRAPS,
228
229 /* Common struct description is not null-terminated */
230 VB2_ERROR_COMMON_DESC_TERMINATOR,
231
232 /* Member data overlaps previous data */
233 VB2_ERROR_COMMON_MEMBER_OVERLAP, /* 0x150020 */
234
235 /* Signature bad magic number */
236 VB2_ERROR_SIG_MAGIC,
237
238 /* Signature incompatible version */
239 VB2_ERROR_SIG_VERSION,
240
241 /* Signature header doesn't fit */
242 VB2_ERROR_SIG_HEADER_SIZE,
243
Randall Spanglerc0ce70b2014-10-31 11:19:14 -0700244 /* Signature unsupported algorithm */
245 VB2_ERROR_SIG_ALGORITHM,
246
247 /* Signature bad size for algorithm */
248 VB2_ERROR_SIG_SIZE,
249
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700250 /* Wrong amount of data signed */
251 VB2_ERROR_VDATA_SIZE,
252
253 /* Digest mismatch */
254 VB2_ERROR_VDATA_VERIFY_DIGEST,
255
256 /* Key algorithm doesn't match signature algorithm */
257 VB2_ERROR_VDATA_ALGORITHM_MISMATCH,
258
Randall Spangler308d2542014-12-04 09:54:37 -0800259 /* Bad magic number in vb2_unpack_key() */
ChromeOS Developer7aef90c2014-12-03 12:19:22 -0800260 VB2_ERROR_UNPACK_KEY_MAGIC,
261
Randall Spangler224f5ac2014-06-06 09:42:30 -0700262 /**********************************************************************
263 * Keyblock verification errors (all in vb2_verify_keyblock())
264 */
265 VB2_ERROR_KEYBLOCK = VB2_ERROR_BASE + 0x060000,
266
267 /* Data buffer too small for header */
268 VB2_ERROR_KEYBLOCK_TOO_SMALL_FOR_HEADER,
269
270 /* Magic number not present */
271 VB2_ERROR_KEYBLOCK_MAGIC,
272
273 /* Header version incompatible */
274 VB2_ERROR_KEYBLOCK_HEADER_VERSION,
275
276 /* Data buffer too small for keyblock */
277 VB2_ERROR_KEYBLOCK_SIZE,
278
279 /* Signature data offset outside keyblock */
280 VB2_ERROR_KEYBLOCK_SIG_OUTSIDE,
281
282 /* Signature signed more data than size of keyblock */
283 VB2_ERROR_KEYBLOCK_SIGNED_TOO_MUCH,
284
285 /* Signature signed less data than size of keyblock header */
286 VB2_ERROR_KEYBLOCK_SIGNED_TOO_LITTLE,
287
288 /* Signature invalid */
289 VB2_ERROR_KEYBLOCK_SIG_INVALID,
290
291 /* Data key outside keyblock */
292 VB2_ERROR_KEYBLOCK_DATA_KEY_OUTSIDE,
293
294 /* Data key outside signed part of keyblock */
295 VB2_ERROR_KEYBLOCK_DATA_KEY_UNSIGNED,
296
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700297 /* Signature signed wrong amount of data */
298 VB2_ERROR_KEYBLOCK_SIGNED_SIZE,
299
Bill Richardson36bc5912015-03-04 16:13:45 -0800300 /* No signature matching key ID */
301 VB2_ERROR_KEYBLOCK_SIG_ID,
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700302
Randall Spangler224f5ac2014-06-06 09:42:30 -0700303 /**********************************************************************
304 * Preamble verification errors (all in vb2_verify_preamble())
305 */
306 VB2_ERROR_PREAMBLE = VB2_ERROR_BASE + 0x070000,
307
308 /* Preamble data too small to contain header */
309 VB2_ERROR_PREAMBLE_TOO_SMALL_FOR_HEADER,
310
311 /* Header version incompatible */
312 VB2_ERROR_PREAMBLE_HEADER_VERSION,
313
314 /* Header version too old */
315 VB2_ERROR_PREAMBLE_HEADER_OLD,
316
317 /* Data buffer too small for preamble */
318 VB2_ERROR_PREAMBLE_SIZE,
319
320 /* Signature data offset outside preamble */
321 VB2_ERROR_PREAMBLE_SIG_OUTSIDE,
322
323 /* Signature signed more data than size of preamble */
324 VB2_ERROR_PREAMBLE_SIGNED_TOO_MUCH,
325
326 /* Signature signed less data than size of preamble header */
327 VB2_ERROR_PREAMBLE_SIGNED_TOO_LITTLE,
328
329 /* Signature invalid */
330 VB2_ERROR_PREAMBLE_SIG_INVALID,
331
332 /* Body signature outside preamble */
333 VB2_ERROR_PREAMBLE_BODY_SIG_OUTSIDE,
334
335 /* Kernel subkey outside preamble */
336 VB2_ERROR_PREAMBLE_KERNEL_SUBKEY_OUTSIDE,
337
Randall Spangler43e0a9e2014-11-04 17:50:32 -0800338 /* Bad magic number */
339 VB2_ERROR_PREAMBLE_MAGIC,
340
341 /* Hash is signed */
342 VB2_ERROR_PREAMBLE_HASH_SIGNED,
343
Randall Spangler2d25e832015-05-12 16:39:01 -0700344 /* Bootloader outside signed portion of body */
345 VB2_ERROR_PREAMBLE_BOOTLOADER_OUTSIDE,
346
347 /* Vmlinuz header outside signed portion of body */
348 VB2_ERROR_PREAMBLE_VMLINUZ_HEADER_OUTSIDE,
349
Randall Spangler224f5ac2014-06-06 09:42:30 -0700350 /**********************************************************************
351 * Misc higher-level code errors
352 */
353 VB2_ERROR_MISC = VB2_ERROR_BASE + 0x080000,
354
355 /* Work buffer too small in vb2_init_context() */
356 VB2_ERROR_INITCTX_WORKBUF_SMALL,
357
358 /* Work buffer unaligned in vb2_init_context() */
359 VB2_ERROR_INITCTX_WORKBUF_ALIGN,
360
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700361 /* Work buffer too small in vb2_fw_parse_gbb() */
362 VB2_ERROR_GBB_WORKBUF,
363
364 /* Bad magic number in vb2_read_gbb_header() */
365 VB2_ERROR_GBB_MAGIC,
366
367 /* Incompatible version in vb2_read_gbb_header() */
368 VB2_ERROR_GBB_VERSION,
369
370 /* Old version in vb2_read_gbb_header() */
371 VB2_ERROR_GBB_TOO_OLD,
372
373 /* Header size too small in vb2_read_gbb_header() */
374 VB2_ERROR_GBB_HEADER_SIZE,
375
Randall Spanglerf18038b2014-10-23 15:55:21 -0700376 /* Work buffer too small for root key in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700377 VB2_ERROR_FW_KEYBLOCK_WORKBUF_ROOT_KEY,
378
Randall Spanglerf18038b2014-10-23 15:55:21 -0700379 /* Work buffer too small for header in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700380 VB2_ERROR_FW_KEYBLOCK_WORKBUF_HEADER,
381
Randall Spanglerf18038b2014-10-23 15:55:21 -0700382 /* Work buffer too small for keyblock in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700383 VB2_ERROR_FW_KEYBLOCK_WORKBUF,
384
Randall Spanglerf18038b2014-10-23 15:55:21 -0700385 /* Keyblock version out of range in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700386 VB2_ERROR_FW_KEYBLOCK_VERSION_RANGE,
387
Randall Spanglerf18038b2014-10-23 15:55:21 -0700388 /* Keyblock version rollback in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700389 VB2_ERROR_FW_KEYBLOCK_VERSION_ROLLBACK,
390
Randall Spanglerf18038b2014-10-23 15:55:21 -0700391 /* Missing firmware data key in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700392 VB2_ERROR_FW_PREAMBLE2_DATA_KEY,
393
Randall Spanglerf18038b2014-10-23 15:55:21 -0700394 /* Work buffer too small for header in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700395 VB2_ERROR_FW_PREAMBLE2_WORKBUF_HEADER,
396
Randall Spanglerf18038b2014-10-23 15:55:21 -0700397 /* Work buffer too small for preamble in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700398 VB2_ERROR_FW_PREAMBLE2_WORKBUF,
399
Randall Spanglerf18038b2014-10-23 15:55:21 -0700400 /* Firmware version out of range in vb2_load_fw_preamble() */
Randall Spangler308d2542014-12-04 09:54:37 -0800401 VB2_ERROR_FW_PREAMBLE_VERSION_RANGE,
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700402
Randall Spanglerf18038b2014-10-23 15:55:21 -0700403 /* Firmware version rollback in vb2_load_fw_preamble() */
Randall Spangler308d2542014-12-04 09:54:37 -0800404 VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK,
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700405
Randall Spangler837b4082014-11-10 13:40:52 -0800406 /* Not enough space in work buffer for resource object */
407 VB2_ERROR_READ_RESOURCE_OBJECT_BUF,
408
Randall Spangler3d5cd882015-05-20 17:22:17 -0700409 /* Work buffer too small for header in vb2_load_kernel_keyblock() */
410 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF_HEADER,
411
412 /* Work buffer too small for keyblock in vb2_load_kernel_keyblock() */
413 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF,
414
415 /* Keyblock version out of range in vb2_load_kernel_keyblock() */
416 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_RANGE,
417
418 /* Keyblock version rollback in vb2_load_kernel_keyblock() */
419 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_ROLLBACK,
420
421 /*
422 * Keyblock flags don't match current mode in
423 * vb2_load_kernel_keyblock().
424 */
425 VB2_ERROR_KERNEL_KEYBLOCK_DEV_FLAG,
426 VB2_ERROR_KERNEL_KEYBLOCK_REC_FLAG,
427
Randall Spangler22da78c2015-05-29 10:53:11 -0700428 /* Missing firmware data key in vb2_load_kernel_preamble() */
429 VB2_ERROR_KERNEL_PREAMBLE2_DATA_KEY,
Randall Spangler3d5cd882015-05-20 17:22:17 -0700430
Randall Spangler22da78c2015-05-29 10:53:11 -0700431 /* Work buffer too small for header in vb2_load_kernel_preamble() */
432 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF_HEADER,
433
434 /* Work buffer too small for preamble in vb2_load_kernel_preamble() */
435 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF,
436
437 /* Kernel version out of range in vb2_load_kernel_preamble() */
438 VB2_ERROR_KERNEL_PREAMBLE_VERSION_RANGE,
439
440 /* Kernel version rollback in vb2_load_kernel_preamble() */
441 VB2_ERROR_KERNEL_PREAMBLE_VERSION_ROLLBACK,
442
443 /* Kernel preamble not loaded before calling vb2api_get_kernel_size() */
444 VB2_ERROR_API_GET_KERNEL_SIZE_PREAMBLE,
Randall Spangler3d5cd882015-05-20 17:22:17 -0700445
Randall Spangler21457212014-06-06 09:30:14 -0700446 /**********************************************************************
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700447 * API-level errors
Randall Spanglerb9be5362014-06-05 13:32:11 -0700448 */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700449 VB2_ERROR_API = VB2_ERROR_BASE + 0x090000,
Randall Spangler786acda2014-05-22 13:27:07 -0700450
Bill Richardson9c647ef2015-03-03 10:39:08 -0800451 /* Bad tag in vb2api_init_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700452 VB2_ERROR_API_INIT_HASH_TAG,
Randall Spangler786acda2014-05-22 13:27:07 -0700453
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700454 /* Preamble not present in vb2api_init_hash() */
455 VB2_ERROR_API_INIT_HASH_PREAMBLE,
Randall Spangler786acda2014-05-22 13:27:07 -0700456
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700457 /* Work buffer too small in vb2api_init_hash() */
458 VB2_ERROR_API_INIT_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700459
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700460 /* Missing firmware data key in vb2api_init_hash() */
461 VB2_ERROR_API_INIT_HASH_DATA_KEY,
Randall Spangler786acda2014-05-22 13:27:07 -0700462
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700463 /* Uninitialized work area in vb2api_extend_hash() */
464 VB2_ERROR_API_EXTEND_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700465
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700466 /* Too much data hashed in vb2api_extend_hash() */
467 VB2_ERROR_API_EXTEND_HASH_SIZE,
Randall Spangler786acda2014-05-22 13:27:07 -0700468
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700469 /* Preamble not present in vb2api_check_hash() */
470 VB2_ERROR_API_CHECK_HASH_PREAMBLE,
Randall Spangler786acda2014-05-22 13:27:07 -0700471
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700472 /* Uninitialized work area in vb2api_check_hash() */
473 VB2_ERROR_API_CHECK_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700474
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700475 /* Wrong amount of data hashed in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700476 VB2_ERROR_API_CHECK_HASH_SIZE,
Randall Spangler786acda2014-05-22 13:27:07 -0700477
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700478 /* Work buffer too small in vb2api_check_hash() */
479 VB2_ERROR_API_CHECK_HASH_WORKBUF_DIGEST,
480
Bill Richardson9c647ef2015-03-03 10:39:08 -0800481 /* Bad tag in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700482 VB2_ERROR_API_CHECK_HASH_TAG,
Randall Spangler786acda2014-05-22 13:27:07 -0700483
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700484 /* Missing firmware data key in vb2api_check_hash() */
485 VB2_ERROR_API_CHECK_HASH_DATA_KEY,
Randall Spangler786acda2014-05-22 13:27:07 -0700486
Bill Richardson9c647ef2015-03-03 10:39:08 -0800487 /* Signature size mismatch in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700488 VB2_ERROR_API_CHECK_HASH_SIG_SIZE,
489
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700490 /* Phase one needs recovery mode */
491 VB2_ERROR_API_PHASE1_RECOVERY,
492
Bill Richardson9c647ef2015-03-03 10:39:08 -0800493 /* Bad tag in vb2api_check_hash() */
Bill Richardson36bc5912015-03-04 16:13:45 -0800494 VB2_ERROR_API_INIT_HASH_ID,
Randall Spanglerefa37b82014-11-12 16:20:50 -0800495
Bill Richardson9c647ef2015-03-03 10:39:08 -0800496 /* Signature mismatch in vb2api_check_hash() */
Randall Spanglerefa37b82014-11-12 16:20:50 -0800497 VB2_ERROR_API_CHECK_HASH_SIG,
498
Daisuke Nojiri62d482e2015-01-29 14:37:25 -0800499 /* Invalid enum vb2_pcr_digest requested to vb2api_get_pcr_digest */
500 VB2_ERROR_API_PCR_DIGEST,
501
502 /* Buffer size for the digest is too small for vb2api_get_pcr_digest */
503 VB2_ERROR_API_PCR_DIGEST_BUF,
504
Randall Spanglerd7f0f932015-05-19 13:41:09 -0700505 /* Work buffer too small for recovery key in vb2api_kernel_phase1() */
506 VB2_ERROR_API_KPHASE1_WORKBUF_REC_KEY,
507
508 /* Firmware preamble not present for vb2api_kernel_phase1() */
509 VB2_ERROR_API_KPHASE1_PREAMBLE,
510
511 /* Wrong amount of kernel data in vb2api_verify_kernel_data() */
512 VB2_ERROR_API_VERIFY_KDATA_SIZE,
513
514 /* Kernel preamble not present for vb2api_verify_kernel_data() */
515 VB2_ERROR_API_VERIFY_KDATA_PREAMBLE,
516
517 /* Insufficient workbuf for hashing in vb2api_verify_kernel_data() */
518 VB2_ERROR_API_VERIFY_KDATA_WORKBUF,
519
520 /* Bad data key in vb2api_verify_kernel_data() */
521 VB2_ERROR_API_VERIFY_KDATA_KEY,
522
Randall Spanglerc8e48542015-09-17 12:54:51 -0700523 /* Phase one passing through secdata's request to reboot */
524 VB2_ERROR_API_PHASE1_SECDATA_REBOOT,
525
Aaron Durbin7cbd1ce2016-01-22 15:06:05 -0600526 /* Digest buffer passed into vb2api_check_hash incorrect. */
527 VB2_ERROR_API_CHECK_DIGEST_SIZE,
528
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700529 /**********************************************************************
530 * Errors which may be generated by implementations of vb2ex functions.
531 * Implementation may also return its own specific errors, which should
532 * NOT be in the range VB2_ERROR_BASE...VB2_ERROR_MAX to avoid
533 * conflicting with future vboot2 error codes.
534 */
535 VB2_ERROR_EX = VB2_ERROR_BASE + 0x0a0000,
536
Randall Spangler25c95d02014-06-20 13:57:12 -0700537 /* Read resource not implemented */
538 VB2_ERROR_EX_READ_RESOURCE_UNIMPLEMENTED,
539
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700540 /* Resource index not found */
541 VB2_ERROR_EX_READ_RESOURCE_INDEX,
542
543 /* Size of resource not big enough for requested offset and/or size */
544 VB2_ERROR_EX_READ_RESOURCE_SIZE,
545
546 /* TPM clear owner failed */
547 VB2_ERROR_EX_TPM_CLEAR_OWNER,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700548
Randall Spangler25c95d02014-06-20 13:57:12 -0700549 /* TPM clear owner not implemented */
550 VB2_ERROR_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED,
551
Julius Wernerf10e9092014-12-16 19:24:54 -0800552 /* Hardware crypto engine doesn't support this algorithm (non-fatal) */
553 VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED,
554
Randall Spangler02e11b32014-11-19 12:48:36 -0800555
556 /**********************************************************************
557 * Errors generated by host library (non-firmware) start here.
558 */
559 VB2_ERROR_HOST_BASE = 0x20000000,
560
561 /**********************************************************************
562 * Errors generated by host library misc functions
563 */
564 VB2_ERROR_HOST_MISC = VB2_ERROR_HOST_BASE + 0x010000,
565
566 /* Unable to open file in read_file() */
567 VB2_ERROR_READ_FILE_OPEN,
568
569 /* Bad size in read_file() */
570 VB2_ERROR_READ_FILE_SIZE,
571
572 /* Unable to allocate buffer in read_file() */
573 VB2_ERROR_READ_FILE_ALLOC,
574
575 /* Unable to read data in read_file() */
576 VB2_ERROR_READ_FILE_DATA,
577
578 /* Unable to open file in write_file() */
579 VB2_ERROR_WRITE_FILE_OPEN,
580
581 /* Unable to write data in write_file() */
582 VB2_ERROR_WRITE_FILE_DATA,
583
Bill Richardson36bc5912015-03-04 16:13:45 -0800584 /* Unable to convert string to struct vb_id */
585 VB2_ERROR_STR_TO_ID,
Bill Richardson4e4c1962015-02-03 17:07:15 -0800586
Randall Spanglerb9be5362014-06-05 13:32:11 -0700587 /**********************************************************************
Randall Spangler59c29202014-11-17 14:24:59 -0800588 * Errors generated by host library key functions
589 */
590 VB2_ERROR_HOST_KEY = VB2_ERROR_HOST_BASE + 0x020000,
591
592 /* Unable to allocate key in vb2_private_key_read_pem() */
593 VB2_ERROR_READ_PEM_ALLOC,
594
595 /* Unable to open .pem file in vb2_private_key_read_pem() */
596 VB2_ERROR_READ_PEM_FILE_OPEN,
597
598 /* Bad RSA data from .pem file in vb2_private_key_read_pem() */
599 VB2_ERROR_READ_PEM_RSA,
600
601 /* Unable to set private key description */
602 VB2_ERROR_PRIVATE_KEY_SET_DESC,
603
604 /* Bad magic number in vb2_private_key_unpack() */
605 VB2_ERROR_UNPACK_PRIVATE_KEY_MAGIC,
606
607 /* Bad common header in vb2_private_key_unpack() */
608 VB2_ERROR_UNPACK_PRIVATE_KEY_HEADER,
609
610 /* Bad key data in vb2_private_key_unpack() */
611 VB2_ERROR_UNPACK_PRIVATE_KEY_DATA,
612
613 /* Bad struct version in vb2_private_key_unpack() */
614 VB2_ERROR_UNPACK_PRIVATE_KEY_STRUCT_VERSION,
615
616 /* Unable to allocate buffer in vb2_private_key_unpack() */
617 VB2_ERROR_UNPACK_PRIVATE_KEY_ALLOC,
618
619 /* Unable to unpack RSA key in vb2_private_key_unpack() */
620 VB2_ERROR_UNPACK_PRIVATE_KEY_RSA,
621
622 /* Unable to set description in vb2_private_key_unpack() */
623 VB2_ERROR_UNPACK_PRIVATE_KEY_DESC,
624
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800625 /* Bad bare hash key in vb2_private_key_unpack() */
626 VB2_ERROR_UNPACK_PRIVATE_KEY_HASH,
627
Randall Spangler59c29202014-11-17 14:24:59 -0800628 /* Unable to create RSA data in vb2_private_key_write() */
629 VB2_ERROR_PRIVATE_KEY_WRITE_RSA,
630
631 /* Unable to allocate packed key buffer in vb2_private_key_write() */
632 VB2_ERROR_PRIVATE_KEY_WRITE_ALLOC,
633
634 /* Unable to write file in vb2_private_key_write() */
635 VB2_ERROR_PRIVATE_KEY_WRITE_FILE,
636
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800637 /* Bad algorithm in vb2_private_key_hash() */
638 VB2_ERROR_PRIVATE_KEY_HASH,
639
Randall Spangler59c29202014-11-17 14:24:59 -0800640 /* Unable to determine key size in vb2_public_key_alloc() */
641 VB2_ERROR_PUBLIC_KEY_ALLOC_SIZE,
642
643 /* Unable to allocate buffer in vb2_public_key_alloc() */
644 VB2_ERROR_PUBLIC_KEY_ALLOC,
645
646 /* Unable to set public key description */
647 VB2_ERROR_PUBLIC_KEY_SET_DESC,
648
649 /* Unable to read key data in vb2_public_key_read_keyb() */
650 VB2_ERROR_READ_KEYB_DATA,
651
652 /* Wrong amount of data read in vb2_public_key_read_keyb() */
653 VB2_ERROR_READ_KEYB_SIZE,
654
655 /* Unable to allocate key buffer in vb2_public_key_read_keyb() */
656 VB2_ERROR_READ_KEYB_ALLOC,
657
658 /* Error unpacking RSA arrays in vb2_public_key_read_keyb() */
659 VB2_ERROR_READ_KEYB_UNPACK,
660
661 /* Unable to read key data in vb2_packed_key_read() */
662 VB2_ERROR_READ_PACKED_KEY_DATA,
663
664 /* Bad key data in vb2_packed_key_read() */
665 VB2_ERROR_READ_PACKED_KEY,
666
667 /* Unable to determine key size in vb2_public_key_pack() */
668 VB2_ERROR_PUBLIC_KEY_PACK_SIZE,
669
Bill Richardson4e4c1962015-02-03 17:07:15 -0800670 /* Bad hash algorithm in vb2_public_key_hash() */
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800671 VB2_ERROR_PUBLIC_KEY_HASH,
672
Randall Spangler939cc3a2016-06-21 15:23:32 -0700673 /* Bad key size in vb2_copy_packed_key() */
674 VB2_ERROR_COPY_KEY_SIZE,
675
Randall Spanglerd46461c2016-06-22 16:46:23 -0700676 /* Unable to convert back to vb1 crypto algorithm */
677 VB2_ERROR_VB1_CRYPTO_ALGORITHM,
678
Randall Spanglerf7559e42016-06-23 13:45:59 -0700679 /* Unable to allocate packed key */
680 VB2_ERROR_PACKED_KEY_ALLOC,
681
682 /* Unable to copy packed key */
683 VB2_ERROR_PACKED_KEY_COPY,
684
Randall Spangler59c29202014-11-17 14:24:59 -0800685 /**********************************************************************
Randall Spanglerc644a8c2014-11-21 11:04:36 -0800686 * Errors generated by host library signature functions
687 */
688 VB2_ERROR_HOST_SIG = VB2_ERROR_HOST_BASE + 0x030000,
689
690 /* Bad hash algorithm in vb2_digest_info() */
691 VB2_ERROR_DIGEST_INFO,
692
693 /*
694 * Unable to determine signature size for key algorithm in
695 * vb2_sig_size_for_key().
696 */
697 VB2_ERROR_SIG_SIZE_FOR_KEY,
698
699 /* Bad signature size in vb2_sign_data() */
700 VB2_SIGN_DATA_SIG_SIZE,
701
702 /* Unable to get digest info in vb2_sign_data() */
703 VB2_SIGN_DATA_DIGEST_INFO,
704
705 /* Unable to get digest size in vb2_sign_data() */
706 VB2_SIGN_DATA_DIGEST_SIZE,
707
708 /* Unable to allocate digest buffer in vb2_sign_data() */
709 VB2_SIGN_DATA_DIGEST_ALLOC,
710
711 /* Unable to initialize digest in vb2_sign_data() */
712 VB2_SIGN_DATA_DIGEST_INIT,
713
714 /* Unable to extend digest in vb2_sign_data() */
715 VB2_SIGN_DATA_DIGEST_EXTEND,
716
717 /* Unable to finalize digest in vb2_sign_data() */
718 VB2_SIGN_DATA_DIGEST_FINALIZE,
719
720 /* RSA encrypt failed in vb2_sign_data() */
721 VB2_SIGN_DATA_RSA_ENCRYPT,
722
723 /* Not enough buffer space to hold signature in vb2_sign_object() */
724 VB2_SIGN_OBJECT_OVERFLOW,
725
726 /**********************************************************************
Randall Spangler9328bbf2014-11-24 12:55:29 -0800727 * Errors generated by host library keyblock functions
728 */
729 VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000,
730
731 /* Unable to determine signature sizes for vb2_create_keyblock() */
732 VB2_KEYBLOCK_CREATE_SIG_SIZE,
733
734 /* Unable to pack data key for vb2_create_keyblock() */
735 VB2_KEYBLOCK_CREATE_DATA_KEY,
736
737 /* Unable to allocate buffer in vb2_create_keyblock() */
738 VB2_KEYBLOCK_CREATE_ALLOC,
739
740 /* Unable to sign keyblock in vb2_create_keyblock() */
741 VB2_KEYBLOCK_CREATE_SIGN,
742
743 /**********************************************************************
Randall Spangler42a85002014-11-25 10:52:59 -0800744 * Errors generated by host library firmware preamble functions
745 */
746 VB2_ERROR_HOST_FW_PREAMBLE = VB2_ERROR_HOST_BASE + 0x050000,
747
748 /* Unable to determine signature sizes for vb2_create_fw_preamble() */
749 VB2_FW_PREAMBLE_CREATE_SIG_SIZE,
750
751 /* Unable to allocate buffer in vb2_create_fw_preamble() */
752 VB2_FW_PREAMBLE_CREATE_ALLOC,
753
754 /* Unable to sign preamble in vb2_create_fw_preamble() */
755 VB2_FW_PREAMBLE_CREATE_SIGN,
756
757 /**********************************************************************
Randall Spanglerf87aa722016-09-09 10:49:37 -0700758 * Errors generated by unit test functions
759 */
760 VB2_ERROR_UNIT_TEST = VB2_ERROR_HOST_BASE + 0x060000,
761
762 /* Unable to open an input file needed for a unit test */
763 VB2_ERROR_TEST_INPUT_FILE,
764
765 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700766 * Highest non-zero error generated inside vboot library. Note that
767 * error codes passed through vboot when it calls external APIs may
768 * still be outside this range.
769 */
Randall Spangler02e11b32014-11-19 12:48:36 -0800770 VB2_ERROR_MAX = VB2_ERROR_BASE + 0x1fffffff,
Randall Spangler786acda2014-05-22 13:27:07 -0700771};
772
773#endif /* VBOOT_2_RETURN_CODES_H_ */