blob: 0ab9e750a046554d30789e2c22cb63f07762ecb2 [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
Joel Kitching9adf2aa2019-08-20 17:43:50 +08006#ifndef VBOOT_REFERENCE_2RETURN_CODES_H_
7#define VBOOT_REFERENCE_2RETURN_CODES_H_
Randall Spangler786acda2014-05-22 13:27:07 -07008
Joel Kitchingffd42a82019-08-29 13:58:52 +08009#include "2sysincludes.h"
10
Randall Spangler786acda2014-05-22 13:27:07 -070011/*
Joel Kitching90671fa2019-07-31 13:17:08 +080012 * 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 */
15typedef uint32_t vb2_error_t;
16
17/*
Randall Spangler786acda2014-05-22 13:27:07 -070018 * Return codes from verified boot functions.
19 *
Randall Spanglerda2b49c2014-06-10 17:03:40 -070020 * Note that other values may be passed through from vb2ex_*() calls; see
21 * the comment for VB2_ERROR_EX below.
Randall Spangler786acda2014-05-22 13:27:07 -070022 */
23enum vb2_return_code {
24 /* Success - no error */
25 VB2_SUCCESS = 0,
26
Randall Spanglerb9be5362014-06-05 13:32:11 -070027 /*
28 * All vboot2 error codes start at a large offset from zero, to reduce
29 * the risk of overlap with other error codes (TPM, etc.).
30 */
Randall Spangler02e11b32014-11-19 12:48:36 -080031 VB2_ERROR_BASE = 0x10000000,
Randall Spanglerb9be5362014-06-05 13:32:11 -070032
Randall Spangler786acda2014-05-22 13:27:07 -070033 /* Unknown / unspecified error */
Randall Spanglerb9be5362014-06-05 13:32:11 -070034 VB2_ERROR_UNKNOWN = VB2_ERROR_BASE + 1,
35
Randall Spanglera7ab8b52014-06-10 17:05:08 -070036 /* Mock error for testing */
37 VB2_ERROR_MOCK,
38
Joel Kitching9ad8a412018-08-02 16:21:17 +080039 /**********************************************************************
Joel Kitching1ed2dff2019-08-30 16:19:35 +080040 * ancient pre-vboot1 errors
41 * TODO: deprecate these once they have all moved over to vboot2 style
42 */
43 /* Invalid public key passed to a signature verficiation function. */
44 VBOOT_PUBLIC_KEY_INVALID = 4,
45 /* Preamble internal structure is invalid */
46 VBOOT_PREAMBLE_INVALID = 5,
47 /* Shared data is invalid. */
48 VBOOT_SHARED_DATA_INVALID = 7,
49 /* Kernel Preamble does not contain flags */
50 VBOOT_KERNEL_PREAMBLE_NO_FLAGS = 8,
51
52 /**********************************************************************
Joel Kitching1db2f382019-07-29 18:35:08 +080053 * vboot1-style errors
54 * TODO: deprecate these once they have all moved over to vboot2 style
55 */
Joel Kitching1db2f382019-07-29 18:35:08 +080056 /* Unable to initialize shared data */
57 VBERROR_INIT_SHARED_DATA = 0x10001,
Joel Kitching1db2f382019-07-29 18:35:08 +080058 /* Unable to set boot mode state in TPM */
59 VBERROR_TPM_SET_BOOT_MODE_STATE = 0x10006,
60 /* Calling firmware needs to perform a reboot. */
61 VBERROR_REBOOT_REQUIRED = 0x10007,
62 /* Unable to set up TPM */
63 VBERROR_TPM_FIRMWARE_SETUP = 0x10008,
64 /* Unable to read kernel versions from TPM */
65 VBERROR_TPM_READ_KERNEL = 0x10009,
Joel Kitching1db2f382019-07-29 18:35:08 +080066 /* Unable to write kernel versions to TPM */
67 VBERROR_TPM_WRITE_KERNEL = 0x1000B,
68 /* Unable to lock kernel versions in TPM */
69 VBERROR_TPM_LOCK_KERNEL = 0x1000C,
70 /* Calling firmware requested shutdown via VbExIsShutdownRequested() */
71 VBERROR_SHUTDOWN_REQUESTED = 0x1000D,
72 /* Unable to find a boot device on which to look for a kernel */
73 VBERROR_NO_DISK_FOUND = 0x1000E,
74 /* No OS kernel found on any boot device */
75 VBERROR_NO_KERNEL_FOUND = 0x1000F,
76 /* All OS kernels found were invalid (corrupt, improperly signed...) */
77 VBERROR_INVALID_KERNEL_FOUND = 0x10010,
78 /* VbSelectAndLoadKernel() requested recovery mode */
79 VBERROR_LOAD_KERNEL_RECOVERY = 0x10011,
80 /* Other error inside VbSelectAndLoadKernel() */
81 VBERROR_LOAD_KERNEL = 0x10012,
82 /* Invalid Google binary block */
83 VBERROR_INVALID_GBB = 0x10013,
84 /* Invalid bitmap volume */
85 VBERROR_INVALID_BMPFV = 0x10014,
86 /* Invalid screen index */
87 VBERROR_INVALID_SCREEN_INDEX = 0x10015,
Joel Kitching1db2f382019-07-29 18:35:08 +080088 /* VbExBeep() can't make sound in the background */
89 VBERROR_NO_BACKGROUND_SOUND = 0x10019,
90 /* Need EC to reboot to read-only code to switch RW slot */
91 VBERROR_EC_REBOOT_TO_SWITCH_RW = 0x1001A,
Joel Kitching1db2f382019-07-29 18:35:08 +080092 /* Need EC to reboot to read-only code */
93 VBERROR_EC_REBOOT_TO_RO_REQUIRED = 0x10022,
Joel Kitchingf2415142019-07-30 10:02:44 +080094 /* No image present */
Joel Kitching1db2f382019-07-29 18:35:08 +080095 VBERROR_NO_IMAGE_PRESENT = 0x10026,
96 /* failed to draw screen */
97 VBERROR_SCREEN_DRAW = 0x10027,
Joel Kitching1db2f382019-07-29 18:35:08 +080098 /* Error reading FWMP from TPM (note: not present is not an error) */
99 VBERROR_TPM_READ_FWMP = 0x10029,
100 /* Peripheral busy. Cannot upgrade firmware at present. */
101 VBERROR_PERIPHERAL_BUSY = 0x10030,
Joel Kitching1db2f382019-07-29 18:35:08 +0800102 /* Error writing VPD */
103 VBERROR_VPD_WRITE = 0x10032,
Joel Kitching1db2f382019-07-29 18:35:08 +0800104 /* Detachable UI internal functions may return the following codes */
105 /* No error; return to UI loop */
106 VBERROR_KEEP_LOOPING = 0x30000,
107
108 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700109 * SHA errors
110 */
111 VB2_ERROR_SHA = VB2_ERROR_BASE + 0x010000,
112
113 /* Bad algorithm in vb2_digest_init() */
114 VB2_ERROR_SHA_INIT_ALGORITHM,
115
116 /* Bad algorithm in vb2_digest_extend() */
117 VB2_ERROR_SHA_EXTEND_ALGORITHM,
118
119 /* Bad algorithm in vb2_digest_finalize() */
120 VB2_ERROR_SHA_FINALIZE_ALGORITHM,
121
122 /* Digest size buffer too small in vb2_digest_finalize() */
123 VB2_ERROR_SHA_FINALIZE_DIGEST_SIZE,
124
Joel Kitching9ad8a412018-08-02 16:21:17 +0800125 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700126 * RSA errors
127 */
128 VB2_ERROR_RSA = VB2_ERROR_BASE + 0x020000,
129
130 /* Padding mismatch in vb2_check_padding() */
131 VB2_ERROR_RSA_PADDING,
132
133 /* Bad algorithm in vb2_check_padding() */
134 VB2_ERROR_RSA_PADDING_ALGORITHM,
135
136 /* Null param passed to vb2_verify_digest() */
137 VB2_ERROR_RSA_VERIFY_PARAM,
138
139 /* Bad algorithm in vb2_verify_digest() */
140 VB2_ERROR_RSA_VERIFY_ALGORITHM,
141
142 /* Bad signature length in vb2_verify_digest() */
143 VB2_ERROR_RSA_VERIFY_SIG_LEN,
144
145 /* Work buffer too small in vb2_verify_digest() */
146 VB2_ERROR_RSA_VERIFY_WORKBUF,
147
148 /* Digest mismatch in vb2_verify_digest() */
149 VB2_ERROR_RSA_VERIFY_DIGEST,
150
Randall Spanglerc8c2f022014-10-23 09:48:20 -0700151 /* Bad size calculation in vb2_check_padding() */
152 VB2_ERROR_RSA_PADDING_SIZE,
153
Joel Kitching9ad8a412018-08-02 16:21:17 +0800154 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700155 * NV storage errors
156 */
157 VB2_ERROR_NV = VB2_ERROR_BASE + 0x030000,
158
159 /* Bad header in vb2_nv_check_crc() */
160 VB2_ERROR_NV_HEADER,
161
162 /* Bad CRC in vb2_nv_check_crc() */
163 VB2_ERROR_NV_CRC,
164
Joel Kitchinga93aa4a2019-11-18 21:13:29 +0800165 /* Read error in nvdata backend */
166 VB2_ERROR_NV_READ,
167
168 /* Write error in nvdata backend */
169 VB2_ERROR_NV_WRITE,
170
Joel Kitching9ad8a412018-08-02 16:21:17 +0800171 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700172 * Secure data storage errors
173 */
174 VB2_ERROR_SECDATA = VB2_ERROR_BASE + 0x040000,
175
Joel Kitchingfbde3aa2019-08-27 17:13:55 +0800176 /* Bad CRC in vb2api_secdata_firmware_check() */
177 VB2_ERROR_SECDATA_FIRMWARE_CRC,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700178
Joel Kitchingfbde3aa2019-08-27 17:13:55 +0800179 /* Bad struct version in vb2api_secdata_firmware_check() */
180 VB2_ERROR_SECDATA_FIRMWARE_VERSION,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700181
Joel Kitching2abf0e72019-10-02 00:06:29 +0800182 /* Invalid param in vb2_secdata_firmware_get();
183 Deprecated with chromium:972956. */
184 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_GET_PARAM,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700185
Joel Kitching2abf0e72019-10-02 00:06:29 +0800186 /* Invalid param in vb2_secdata_firmware_set();
187 Deprecated with chromium:972956. */
188 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_PARAM,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700189
Joel Kitching2abf0e72019-10-02 00:06:29 +0800190 /* Invalid flags passed to vb2_secdata_firmware_set();
191 Deprecated with chromium:972956. */
192 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_FLAGS,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700193
Joel Kitching2abf0e72019-10-02 00:06:29 +0800194 /* Called vb2_secdata_firmware_get() with uninitialized secdata;
195 Deprecated with chromium:972956. */
196 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_GET_UNINITIALIZED,
Julius Wernerb550fb12015-01-30 14:27:54 -0800197
Joel Kitching2abf0e72019-10-02 00:06:29 +0800198 /* Called vb2_secdata_firmware_set() with uninitialized secdata;
199 Deprecated with chromium:972956. */
200 VB2_ERROR_DEPRECATED_SECDATA_FIRMWARE_SET_UNINITIALIZED,
Julius Wernerb550fb12015-01-30 14:27:54 -0800201
Joel Kitchingfbde3aa2019-08-27 17:13:55 +0800202 /* Bad CRC in vb2api_secdata_kernel_check() */
203 VB2_ERROR_SECDATA_KERNEL_CRC,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700204
Joel Kitchingfbde3aa2019-08-27 17:13:55 +0800205 /* Bad struct version in vb2_secdata_kernel_init() */
206 VB2_ERROR_SECDATA_KERNEL_VERSION,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700207
Joel Kitchingfbde3aa2019-08-27 17:13:55 +0800208 /* Bad uid in vb2_secdata_kernel_init() */
209 VB2_ERROR_SECDATA_KERNEL_UID,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700210
Joel Kitching2abf0e72019-10-02 00:06:29 +0800211 /* Invalid param in vb2_secdata_kernel_get();
212 Deprecated with chromium:972956. */
213 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_GET_PARAM,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700214
Joel Kitching2abf0e72019-10-02 00:06:29 +0800215 /* Invalid param in vb2_secdata_kernel_set();
216 Deprecated with chromium:972956. */
217 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_PARAM,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700218
Joel Kitching2abf0e72019-10-02 00:06:29 +0800219 /* Invalid flags passed to vb2_secdata_kernel_set();
220 Deprecated with chromium:972956. */
221 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_FLAGS,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700222
Joel Kitching2abf0e72019-10-02 00:06:29 +0800223 /* Called vb2_secdata_kernel_get() with uninitialized secdata_kernel;
224 Deprecated with chromium:972956. */
225 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_GET_UNINITIALIZED,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700226
Joel Kitching2abf0e72019-10-02 00:06:29 +0800227 /* Called vb2_secdata_kernel_set() with uninitialized secdata_kernel;
228 Deprecated with chromium:972956. */
229 VB2_ERROR_DEPRECATED_SECDATA_KERNEL_SET_UNINITIALIZED,
Randall Spanglerbf9c2762015-05-12 13:44:30 -0700230
Joel Kitching967ba852019-08-28 17:45:05 +0800231 /* Bad size in vb2api_secdata_fwmp_check() */
232 VB2_ERROR_SECDATA_FWMP_SIZE,
233
234 /* Incomplete structure in vb2api_secdata_fwmp_check() */
235 VB2_ERROR_SECDATA_FWMP_INCOMPLETE,
236
237 /* Bad CRC in vb2api_secdata_fwmp_check() */
238 VB2_ERROR_SECDATA_FWMP_CRC,
239
240 /* Bad struct version in vb2_secdata_fwmp_check() */
241 VB2_ERROR_SECDATA_FWMP_VERSION,
242
Joel Kitchingadb41832019-09-23 22:53:49 +0800243 /* Error reading secdata_firmware from storage backend */
244 VB2_ERROR_SECDATA_FIRMWARE_READ,
245
246 /* Error writing secdata_firmware to storage backend */
247 VB2_ERROR_SECDATA_FIRMWARE_WRITE,
248
249 /* Error locking secdata_firmware in storage backend */
250 VB2_ERROR_SECDATA_FIRMWARE_LOCK,
251
252 /* Error reading secdata_kernel from storage backend */
253 VB2_ERROR_SECDATA_KERNEL_READ,
254
255 /* Error writing secdata_kernel to storage backend */
256 VB2_ERROR_SECDATA_KERNEL_WRITE,
257
258 /* Error locking secdata_kernel in storage backend */
259 VB2_ERROR_SECDATA_KERNEL_LOCK,
260
261 /* Error reading secdata_fwmp from storage backend */
262 VB2_ERROR_SECDATA_FWMP_READ,
263
Joel Kitching9ad8a412018-08-02 16:21:17 +0800264 /**********************************************************************
Randall Spangler21457212014-06-06 09:30:14 -0700265 * Common code errors
266 */
267 VB2_ERROR_COMMON = VB2_ERROR_BASE + 0x050000,
268
269 /* Buffer is smaller than alignment offset in vb2_align() */
270 VB2_ERROR_ALIGN_BIGGER_THAN_SIZE,
271
272 /* Buffer is smaller than request in vb2_align() */
273 VB2_ERROR_ALIGN_SIZE,
274
275 /* Parent wraps around in vb2_verify_member_inside() */
276 VB2_ERROR_INSIDE_PARENT_WRAPS,
277
278 /* Member wraps around in vb2_verify_member_inside() */
279 VB2_ERROR_INSIDE_MEMBER_WRAPS,
280
281 /* Member outside parent in vb2_verify_member_inside() */
282 VB2_ERROR_INSIDE_MEMBER_OUTSIDE,
283
284 /* Member data wraps around in vb2_verify_member_inside() */
285 VB2_ERROR_INSIDE_DATA_WRAPS,
286
287 /* Member data outside parent in vb2_verify_member_inside() */
288 VB2_ERROR_INSIDE_DATA_OUTSIDE,
289
Randall Spangler6e3931d2016-10-18 15:09:21 -0700290 /* Unsupported signature algorithm in vb2_unpack_key_buffer() */
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700291 VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM, /* 0x150008 */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700292
Randall Spangler6e3931d2016-10-18 15:09:21 -0700293 /* Bad key size in vb2_unpack_key_buffer() */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700294 VB2_ERROR_UNPACK_KEY_SIZE,
295
Randall Spangler6e3931d2016-10-18 15:09:21 -0700296 /* Bad key alignment in vb2_unpack_key_buffer() */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700297 VB2_ERROR_UNPACK_KEY_ALIGN,
298
Randall Spangler6e3931d2016-10-18 15:09:21 -0700299 /* Bad key array size in vb2_unpack_key_buffer() */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700300 VB2_ERROR_UNPACK_KEY_ARRAY_SIZE,
301
302 /* Bad algorithm in vb2_verify_data() */
303 VB2_ERROR_VDATA_ALGORITHM,
304
305 /* Incorrect signature size for algorithm in vb2_verify_data() */
306 VB2_ERROR_VDATA_SIG_SIZE,
307
308 /* Data smaller than length of signed data in vb2_verify_data() */
309 VB2_ERROR_VDATA_NOT_ENOUGH_DATA,
310
311 /* Not enough work buffer for digest in vb2_verify_data() */
312 VB2_ERROR_VDATA_WORKBUF_DIGEST,
313
314 /* Not enough work buffer for hash temp data in vb2_verify_data() */
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700315 VB2_ERROR_VDATA_WORKBUF_HASHING, /* 0x150010 */
Randall Spangler224f5ac2014-06-06 09:42:30 -0700316
Randall Spangler95047542014-10-17 16:41:46 -0700317 /*
318 * Bad digest size in vb2_verify_data() - probably because algorithm
319 * is bad.
320 */
321 VB2_ERROR_VDATA_DIGEST_SIZE,
322
Randall Spangler6e3931d2016-10-18 15:09:21 -0700323 /* Unsupported hash algorithm in vb2_unpack_key_buffer() */
Randall Spangler4eef8122014-10-23 10:07:54 -0700324 VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM,
325
Randall Spanglerf6cfb972014-10-23 17:04:03 -0700326 /* Member data overlaps member header */
327 VB2_ERROR_INSIDE_DATA_OVERLAP,
328
Randall Spanglerd274a2e2014-10-23 17:38:18 -0700329 /* Unsupported packed key struct version */
330 VB2_ERROR_UNPACK_KEY_STRUCT_VERSION,
331
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700332 /*
333 * Buffer too small for total, fixed size, or description reported in
334 * common header, or member data checked via
Randall Spanglerca725122016-05-25 16:42:44 -0700335 * vb21_verify_common_member().
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700336 */
337 VB2_ERROR_COMMON_TOTAL_SIZE,
338 VB2_ERROR_COMMON_FIXED_SIZE,
339 VB2_ERROR_COMMON_DESC_SIZE,
340 VB2_ERROR_COMMON_MEMBER_SIZE, /* 0x150018 */
341
342 /*
343 * Total, fixed, description, or member offset/size not a multiple of
344 * 32 bits.
345 */
346 VB2_ERROR_COMMON_TOTAL_UNALIGNED,
347 VB2_ERROR_COMMON_FIXED_UNALIGNED,
348 VB2_ERROR_COMMON_DESC_UNALIGNED,
349 VB2_ERROR_COMMON_MEMBER_UNALIGNED,
350
351 /* Common struct description or member data wraps address space */
352 VB2_ERROR_COMMON_DESC_WRAPS,
353 VB2_ERROR_COMMON_MEMBER_WRAPS,
354
355 /* Common struct description is not null-terminated */
356 VB2_ERROR_COMMON_DESC_TERMINATOR,
357
358 /* Member data overlaps previous data */
359 VB2_ERROR_COMMON_MEMBER_OVERLAP, /* 0x150020 */
360
361 /* Signature bad magic number */
362 VB2_ERROR_SIG_MAGIC,
363
364 /* Signature incompatible version */
365 VB2_ERROR_SIG_VERSION,
366
367 /* Signature header doesn't fit */
368 VB2_ERROR_SIG_HEADER_SIZE,
369
Randall Spanglerc0ce70b2014-10-31 11:19:14 -0700370 /* Signature unsupported algorithm */
371 VB2_ERROR_SIG_ALGORITHM,
372
373 /* Signature bad size for algorithm */
374 VB2_ERROR_SIG_SIZE,
375
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700376 /* Wrong amount of data signed */
377 VB2_ERROR_VDATA_SIZE,
378
379 /* Digest mismatch */
380 VB2_ERROR_VDATA_VERIFY_DIGEST,
381
382 /* Key algorithm doesn't match signature algorithm */
383 VB2_ERROR_VDATA_ALGORITHM_MISMATCH,
384
Randall Spangler6e3931d2016-10-18 15:09:21 -0700385 /* Bad magic number in vb2_unpack_key_buffer() */
ChromeOS Developer7aef90c2014-12-03 12:19:22 -0800386 VB2_ERROR_UNPACK_KEY_MAGIC,
387
Randall Spangler6e3931d2016-10-18 15:09:21 -0700388 /* Null public key buffer passed to vb2_unpack_key_buffer() */
389 VB2_ERROR_UNPACK_KEY_BUFFER,
390
Joel Kitching9ad8a412018-08-02 16:21:17 +0800391 /**********************************************************************
Randall Spangler224f5ac2014-06-06 09:42:30 -0700392 * Keyblock verification errors (all in vb2_verify_keyblock())
393 */
394 VB2_ERROR_KEYBLOCK = VB2_ERROR_BASE + 0x060000,
395
396 /* Data buffer too small for header */
397 VB2_ERROR_KEYBLOCK_TOO_SMALL_FOR_HEADER,
398
399 /* Magic number not present */
400 VB2_ERROR_KEYBLOCK_MAGIC,
401
402 /* Header version incompatible */
403 VB2_ERROR_KEYBLOCK_HEADER_VERSION,
404
405 /* Data buffer too small for keyblock */
406 VB2_ERROR_KEYBLOCK_SIZE,
407
408 /* Signature data offset outside keyblock */
409 VB2_ERROR_KEYBLOCK_SIG_OUTSIDE,
410
411 /* Signature signed more data than size of keyblock */
412 VB2_ERROR_KEYBLOCK_SIGNED_TOO_MUCH,
413
414 /* Signature signed less data than size of keyblock header */
415 VB2_ERROR_KEYBLOCK_SIGNED_TOO_LITTLE,
416
417 /* Signature invalid */
418 VB2_ERROR_KEYBLOCK_SIG_INVALID,
419
420 /* Data key outside keyblock */
421 VB2_ERROR_KEYBLOCK_DATA_KEY_OUTSIDE,
422
423 /* Data key outside signed part of keyblock */
424 VB2_ERROR_KEYBLOCK_DATA_KEY_UNSIGNED,
425
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700426 /* Signature signed wrong amount of data */
427 VB2_ERROR_KEYBLOCK_SIGNED_SIZE,
428
Bill Richardson36bc5912015-03-04 16:13:45 -0800429 /* No signature matching key ID */
430 VB2_ERROR_KEYBLOCK_SIG_ID,
Randall Spangler6b5b8f62014-10-31 15:18:48 -0700431
Joel Kitching9ad8a412018-08-02 16:21:17 +0800432 /**********************************************************************
Randall Spangler224f5ac2014-06-06 09:42:30 -0700433 * Preamble verification errors (all in vb2_verify_preamble())
434 */
435 VB2_ERROR_PREAMBLE = VB2_ERROR_BASE + 0x070000,
436
437 /* Preamble data too small to contain header */
438 VB2_ERROR_PREAMBLE_TOO_SMALL_FOR_HEADER,
439
440 /* Header version incompatible */
441 VB2_ERROR_PREAMBLE_HEADER_VERSION,
442
443 /* Header version too old */
444 VB2_ERROR_PREAMBLE_HEADER_OLD,
445
446 /* Data buffer too small for preamble */
447 VB2_ERROR_PREAMBLE_SIZE,
448
449 /* Signature data offset outside preamble */
450 VB2_ERROR_PREAMBLE_SIG_OUTSIDE,
451
452 /* Signature signed more data than size of preamble */
453 VB2_ERROR_PREAMBLE_SIGNED_TOO_MUCH,
454
455 /* Signature signed less data than size of preamble header */
456 VB2_ERROR_PREAMBLE_SIGNED_TOO_LITTLE,
457
458 /* Signature invalid */
459 VB2_ERROR_PREAMBLE_SIG_INVALID,
460
461 /* Body signature outside preamble */
462 VB2_ERROR_PREAMBLE_BODY_SIG_OUTSIDE,
463
464 /* Kernel subkey outside preamble */
465 VB2_ERROR_PREAMBLE_KERNEL_SUBKEY_OUTSIDE,
466
Randall Spangler43e0a9e2014-11-04 17:50:32 -0800467 /* Bad magic number */
468 VB2_ERROR_PREAMBLE_MAGIC,
469
470 /* Hash is signed */
471 VB2_ERROR_PREAMBLE_HASH_SIGNED,
472
Randall Spangler2d25e832015-05-12 16:39:01 -0700473 /* Bootloader outside signed portion of body */
474 VB2_ERROR_PREAMBLE_BOOTLOADER_OUTSIDE,
475
476 /* Vmlinuz header outside signed portion of body */
477 VB2_ERROR_PREAMBLE_VMLINUZ_HEADER_OUTSIDE,
478
Joel Kitching9ad8a412018-08-02 16:21:17 +0800479 /**********************************************************************
Randall Spangler224f5ac2014-06-06 09:42:30 -0700480 * Misc higher-level code errors
481 */
482 VB2_ERROR_MISC = VB2_ERROR_BASE + 0x080000,
483
Joel Kitchingecdca932019-07-25 18:26:18 +0800484 /* Work buffer too small (see vb2api_init and vb2api_reinit) */
485 VB2_ERROR_WORKBUF_SMALL,
Randall Spangler224f5ac2014-06-06 09:42:30 -0700486
Joel Kitchingecdca932019-07-25 18:26:18 +0800487 /* Work buffer unaligned (see vb2api_init and vb2api_reinit) */
488 VB2_ERROR_WORKBUF_ALIGN,
Randall Spangler224f5ac2014-06-06 09:42:30 -0700489
Joel Kitching3eb00ef2019-05-23 15:33:54 +0800490 /* Work buffer too small in GBB-related function */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700491 VB2_ERROR_GBB_WORKBUF,
492
493 /* Bad magic number in vb2_read_gbb_header() */
494 VB2_ERROR_GBB_MAGIC,
495
496 /* Incompatible version in vb2_read_gbb_header() */
497 VB2_ERROR_GBB_VERSION,
498
499 /* Old version in vb2_read_gbb_header() */
500 VB2_ERROR_GBB_TOO_OLD,
501
502 /* Header size too small in vb2_read_gbb_header() */
503 VB2_ERROR_GBB_HEADER_SIZE,
504
Randall Spanglerf18038b2014-10-23 15:55:21 -0700505 /* Work buffer too small for root key in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700506 VB2_ERROR_FW_KEYBLOCK_WORKBUF_ROOT_KEY,
507
Randall Spanglerf18038b2014-10-23 15:55:21 -0700508 /* Work buffer too small for header in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700509 VB2_ERROR_FW_KEYBLOCK_WORKBUF_HEADER,
510
Randall Spanglerf18038b2014-10-23 15:55:21 -0700511 /* Work buffer too small for keyblock in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700512 VB2_ERROR_FW_KEYBLOCK_WORKBUF,
513
Randall Spanglerf18038b2014-10-23 15:55:21 -0700514 /* Keyblock version out of range in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700515 VB2_ERROR_FW_KEYBLOCK_VERSION_RANGE,
516
Randall Spanglerf18038b2014-10-23 15:55:21 -0700517 /* Keyblock version rollback in vb2_load_fw_keyblock() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700518 VB2_ERROR_FW_KEYBLOCK_VERSION_ROLLBACK,
519
Randall Spanglerf18038b2014-10-23 15:55:21 -0700520 /* Missing firmware data key in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700521 VB2_ERROR_FW_PREAMBLE2_DATA_KEY,
522
Randall Spanglerf18038b2014-10-23 15:55:21 -0700523 /* Work buffer too small for header in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700524 VB2_ERROR_FW_PREAMBLE2_WORKBUF_HEADER,
525
Randall Spanglerf18038b2014-10-23 15:55:21 -0700526 /* Work buffer too small for preamble in vb2_load_fw_preamble() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700527 VB2_ERROR_FW_PREAMBLE2_WORKBUF,
528
Randall Spanglerf18038b2014-10-23 15:55:21 -0700529 /* Firmware version out of range in vb2_load_fw_preamble() */
Randall Spangler308d2542014-12-04 09:54:37 -0800530 VB2_ERROR_FW_PREAMBLE_VERSION_RANGE,
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700531
Randall Spanglerf18038b2014-10-23 15:55:21 -0700532 /* Firmware version rollback in vb2_load_fw_preamble() */
Randall Spangler308d2542014-12-04 09:54:37 -0800533 VB2_ERROR_FW_PREAMBLE_VERSION_ROLLBACK,
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700534
Randall Spangler837b4082014-11-10 13:40:52 -0800535 /* Not enough space in work buffer for resource object */
536 VB2_ERROR_READ_RESOURCE_OBJECT_BUF,
537
Randall Spangler3d5cd882015-05-20 17:22:17 -0700538 /* Work buffer too small for header in vb2_load_kernel_keyblock() */
539 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF_HEADER,
540
541 /* Work buffer too small for keyblock in vb2_load_kernel_keyblock() */
542 VB2_ERROR_KERNEL_KEYBLOCK_WORKBUF,
543
544 /* Keyblock version out of range in vb2_load_kernel_keyblock() */
545 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_RANGE,
546
547 /* Keyblock version rollback in vb2_load_kernel_keyblock() */
548 VB2_ERROR_KERNEL_KEYBLOCK_VERSION_ROLLBACK,
549
550 /*
551 * Keyblock flags don't match current mode in
552 * vb2_load_kernel_keyblock().
553 */
554 VB2_ERROR_KERNEL_KEYBLOCK_DEV_FLAG,
555 VB2_ERROR_KERNEL_KEYBLOCK_REC_FLAG,
556
Randall Spangler22da78c2015-05-29 10:53:11 -0700557 /* Missing firmware data key in vb2_load_kernel_preamble() */
558 VB2_ERROR_KERNEL_PREAMBLE2_DATA_KEY,
Randall Spangler3d5cd882015-05-20 17:22:17 -0700559
Randall Spangler22da78c2015-05-29 10:53:11 -0700560 /* Work buffer too small for header in vb2_load_kernel_preamble() */
561 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF_HEADER,
562
563 /* Work buffer too small for preamble in vb2_load_kernel_preamble() */
564 VB2_ERROR_KERNEL_PREAMBLE2_WORKBUF,
565
566 /* Kernel version out of range in vb2_load_kernel_preamble() */
567 VB2_ERROR_KERNEL_PREAMBLE_VERSION_RANGE,
568
569 /* Kernel version rollback in vb2_load_kernel_preamble() */
570 VB2_ERROR_KERNEL_PREAMBLE_VERSION_ROLLBACK,
571
572 /* Kernel preamble not loaded before calling vb2api_get_kernel_size() */
573 VB2_ERROR_API_GET_KERNEL_SIZE_PREAMBLE,
Randall Spangler3d5cd882015-05-20 17:22:17 -0700574
Randall Spanglerf1824012016-10-25 10:00:27 -0700575 /* Unable to unpack kernel subkey in vb2_verify_vblock() */
576 VB2_ERROR_VBLOCK_KERNEL_SUBKEY,
577
578 /*
579 * Got a self-signed kernel in vb2_verify_vblock(), but need an
580 * officially signed one.
581 */
582 VB2_ERROR_VBLOCK_SELF_SIGNED,
583
584 /* Invalid keyblock hash in vb2_verify_vblock() */
585 VB2_ERROR_VBLOCK_KEYBLOCK_HASH,
586
587 /* Invalid keyblock in vb2_verify_vblock() */
588 VB2_ERROR_VBLOCK_KEYBLOCK,
589
590 /* Wrong developer key hash in vb2_verify_vblock() */
591 VB2_ERROR_VBLOCK_DEV_KEY_HASH,
592
593 /* Work buffer too small in vb2_load_partition() */
594 VB2_ERROR_LOAD_PARTITION_WORKBUF,
595
596 /* Unable to read vblock in vb2_load_partition() */
597 VB2_ERROR_LOAD_PARTITION_READ_VBLOCK,
598
599 /* Unable to verify vblock in vb2_load_partition() */
600 VB2_ERROR_LOAD_PARTITION_VERIFY_VBLOCK,
601
602 /* Kernel body offset too large in vb2_load_partition() */
603 VB2_ERROR_LOAD_PARTITION_BODY_OFFSET,
604
605 /* Kernel body too big in vb2_load_partition() */
606 VB2_ERROR_LOAD_PARTITION_BODY_SIZE,
607
608 /* Unable to read kernel body in vb2_load_partition() */
609 VB2_ERROR_LOAD_PARTITION_READ_BODY,
610
611 /* Unable to unpack data key in vb2_load_partition() */
612 VB2_ERROR_LOAD_PARTITION_DATA_KEY,
613
614 /* Unable to verify body in vb2_load_partition() */
615 VB2_ERROR_LOAD_PARTITION_VERIFY_BODY,
616
ChromeOS Developer284bf552016-10-31 16:19:20 -0700617 /* Unable to get EC image hash in ec_sync_phase1() */
618 VB2_ERROR_EC_HASH_IMAGE,
619
620 /* Unable to get expected EC image hash in ec_sync_phase1() */
621 VB2_ERROR_EC_HASH_EXPECTED,
622
623 /* Expected and image hashes are different size in ec_sync_phase1() */
624 VB2_ERROR_EC_HASH_SIZE,
625
Joel Kitchingdccea9a2019-01-11 19:16:18 +0800626 /* Incompatible version for vb2_shared_data structure being loaded */
627 VB2_ERROR_SHARED_DATA_VERSION,
628
629 /* Bad magic number in vb2_shared_data structure */
630 VB2_ERROR_SHARED_DATA_MAGIC,
631
Joel Kitching3eb00ef2019-05-23 15:33:54 +0800632 /* Some part of GBB data is invalid */
633 VB2_ERROR_GBB_INVALID,
634
635 /* Invalid parameter */
636 VB2_ERROR_INVALID_PARAMETER,
637
Joel Kitchingecdca932019-07-25 18:26:18 +0800638 /* Problem with workbuf validity (see vb2api_init and vb2api_reinit) */
639 VB2_ERROR_WORKBUF_INVALID,
640
Joel Kitching9ad8a412018-08-02 16:21:17 +0800641 /**********************************************************************
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700642 * API-level errors
Randall Spanglerb9be5362014-06-05 13:32:11 -0700643 */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700644 VB2_ERROR_API = VB2_ERROR_BASE + 0x090000,
Randall Spangler786acda2014-05-22 13:27:07 -0700645
Bill Richardson9c647ef2015-03-03 10:39:08 -0800646 /* Bad tag in vb2api_init_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700647 VB2_ERROR_API_INIT_HASH_TAG,
Randall Spangler786acda2014-05-22 13:27:07 -0700648
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700649 /* Preamble not present in vb2api_init_hash() */
650 VB2_ERROR_API_INIT_HASH_PREAMBLE,
Randall Spangler786acda2014-05-22 13:27:07 -0700651
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700652 /* Work buffer too small in vb2api_init_hash() */
653 VB2_ERROR_API_INIT_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700654
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700655 /* Missing firmware data key in vb2api_init_hash() */
656 VB2_ERROR_API_INIT_HASH_DATA_KEY,
Randall Spangler786acda2014-05-22 13:27:07 -0700657
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700658 /* Uninitialized work area in vb2api_extend_hash() */
659 VB2_ERROR_API_EXTEND_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700660
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700661 /* Too much data hashed in vb2api_extend_hash() */
662 VB2_ERROR_API_EXTEND_HASH_SIZE,
Randall Spangler786acda2014-05-22 13:27:07 -0700663
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700664 /* Preamble not present in vb2api_check_hash() */
665 VB2_ERROR_API_CHECK_HASH_PREAMBLE,
Randall Spangler786acda2014-05-22 13:27:07 -0700666
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700667 /* Uninitialized work area in vb2api_check_hash() */
668 VB2_ERROR_API_CHECK_HASH_WORKBUF,
Randall Spangler786acda2014-05-22 13:27:07 -0700669
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700670 /* Wrong amount of data hashed in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700671 VB2_ERROR_API_CHECK_HASH_SIZE,
Randall Spangler786acda2014-05-22 13:27:07 -0700672
Randall Spanglera7ab8b52014-06-10 17:05:08 -0700673 /* Work buffer too small in vb2api_check_hash() */
674 VB2_ERROR_API_CHECK_HASH_WORKBUF_DIGEST,
675
Bill Richardson9c647ef2015-03-03 10:39:08 -0800676 /* Bad tag in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700677 VB2_ERROR_API_CHECK_HASH_TAG,
Randall Spangler786acda2014-05-22 13:27:07 -0700678
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700679 /* Missing firmware data key in vb2api_check_hash() */
680 VB2_ERROR_API_CHECK_HASH_DATA_KEY,
Randall Spangler786acda2014-05-22 13:27:07 -0700681
Bill Richardson9c647ef2015-03-03 10:39:08 -0800682 /* Signature size mismatch in vb2api_check_hash() */
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700683 VB2_ERROR_API_CHECK_HASH_SIG_SIZE,
684
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700685 /* Phase one needs recovery mode */
686 VB2_ERROR_API_PHASE1_RECOVERY,
687
Bill Richardson9c647ef2015-03-03 10:39:08 -0800688 /* Bad tag in vb2api_check_hash() */
Bill Richardson36bc5912015-03-04 16:13:45 -0800689 VB2_ERROR_API_INIT_HASH_ID,
Randall Spanglerefa37b82014-11-12 16:20:50 -0800690
Bill Richardson9c647ef2015-03-03 10:39:08 -0800691 /* Signature mismatch in vb2api_check_hash() */
Randall Spanglerefa37b82014-11-12 16:20:50 -0800692 VB2_ERROR_API_CHECK_HASH_SIG,
693
Daisuke Nojiri62d482e2015-01-29 14:37:25 -0800694 /* Invalid enum vb2_pcr_digest requested to vb2api_get_pcr_digest */
695 VB2_ERROR_API_PCR_DIGEST,
696
697 /* Buffer size for the digest is too small for vb2api_get_pcr_digest */
698 VB2_ERROR_API_PCR_DIGEST_BUF,
699
Randall Spanglerd7f0f932015-05-19 13:41:09 -0700700 /* Work buffer too small for recovery key in vb2api_kernel_phase1() */
701 VB2_ERROR_API_KPHASE1_WORKBUF_REC_KEY,
702
703 /* Firmware preamble not present for vb2api_kernel_phase1() */
704 VB2_ERROR_API_KPHASE1_PREAMBLE,
705
706 /* Wrong amount of kernel data in vb2api_verify_kernel_data() */
707 VB2_ERROR_API_VERIFY_KDATA_SIZE,
708
709 /* Kernel preamble not present for vb2api_verify_kernel_data() */
710 VB2_ERROR_API_VERIFY_KDATA_PREAMBLE,
711
712 /* Insufficient workbuf for hashing in vb2api_verify_kernel_data() */
713 VB2_ERROR_API_VERIFY_KDATA_WORKBUF,
714
715 /* Bad data key in vb2api_verify_kernel_data() */
716 VB2_ERROR_API_VERIFY_KDATA_KEY,
717
Randall Spanglerc8e48542015-09-17 12:54:51 -0700718 /* Phase one passing through secdata's request to reboot */
719 VB2_ERROR_API_PHASE1_SECDATA_REBOOT,
720
Aaron Durbin7cbd1ce2016-01-22 15:06:05 -0600721 /* Digest buffer passed into vb2api_check_hash incorrect. */
722 VB2_ERROR_API_CHECK_DIGEST_SIZE,
723
Joel Kitching9ad8a412018-08-02 16:21:17 +0800724 /**********************************************************************
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700725 * Errors which may be generated by implementations of vb2ex functions.
726 * Implementation may also return its own specific errors, which should
727 * NOT be in the range VB2_ERROR_BASE...VB2_ERROR_MAX to avoid
728 * conflicting with future vboot2 error codes.
729 */
730 VB2_ERROR_EX = VB2_ERROR_BASE + 0x0a0000,
731
Joel Kitchinga1df89d2018-12-03 14:39:57 +0800732 /* Read resource not implemented
733 * Deprecated: use VB2_ERROR_EX_UNIMPLEMENTED (chromium:944804) */
734 VB2_ERROR_EX_DEPRECATED_READ_RESOURCE_UNIMPLEMENTED,
Randall Spangler25c95d02014-06-20 13:57:12 -0700735
Randall Spanglerda2b49c2014-06-10 17:03:40 -0700736 /* Resource index not found */
737 VB2_ERROR_EX_READ_RESOURCE_INDEX,
738
739 /* Size of resource not big enough for requested offset and/or size */
740 VB2_ERROR_EX_READ_RESOURCE_SIZE,
741
742 /* TPM clear owner failed */
743 VB2_ERROR_EX_TPM_CLEAR_OWNER,
Randall Spanglerb9be5362014-06-05 13:32:11 -0700744
Joel Kitchinga1df89d2018-12-03 14:39:57 +0800745 /* TPM clear owner not implemented
746 * Deprecated: use VB2_ERROR_EX_UNIMPLEMENTED (chromium:944804) */
747 VB2_ERROR_DEPRECATED_EX_TPM_CLEAR_OWNER_UNIMPLEMENTED,
Randall Spangler25c95d02014-06-20 13:57:12 -0700748
Julius Wernerf10e9092014-12-16 19:24:54 -0800749 /* Hardware crypto engine doesn't support this algorithm (non-fatal) */
750 VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED,
751
Matt Delco08bf6802019-02-13 15:54:24 -0800752 /* TPM does not understand this command */
753 VB2_ERROR_EX_TPM_NO_SUCH_COMMAND,
Randall Spangler02e11b32014-11-19 12:48:36 -0800754
Joel Kitchinga1df89d2018-12-03 14:39:57 +0800755 /* vb2ex function is unimplemented (stubbed in 2lib/2stub.c) */
756 VB2_ERROR_EX_UNIMPLEMENTED,
757
Joel Kitching9ad8a412018-08-02 16:21:17 +0800758 /**********************************************************************
Randall Spangler02e11b32014-11-19 12:48:36 -0800759 * Errors generated by host library (non-firmware) start here.
760 */
761 VB2_ERROR_HOST_BASE = 0x20000000,
762
Joel Kitching9ad8a412018-08-02 16:21:17 +0800763 /**********************************************************************
Randall Spangler02e11b32014-11-19 12:48:36 -0800764 * Errors generated by host library misc functions
765 */
766 VB2_ERROR_HOST_MISC = VB2_ERROR_HOST_BASE + 0x010000,
767
768 /* Unable to open file in read_file() */
769 VB2_ERROR_READ_FILE_OPEN,
770
771 /* Bad size in read_file() */
772 VB2_ERROR_READ_FILE_SIZE,
773
774 /* Unable to allocate buffer in read_file() */
775 VB2_ERROR_READ_FILE_ALLOC,
776
777 /* Unable to read data in read_file() */
778 VB2_ERROR_READ_FILE_DATA,
779
780 /* Unable to open file in write_file() */
781 VB2_ERROR_WRITE_FILE_OPEN,
782
783 /* Unable to write data in write_file() */
784 VB2_ERROR_WRITE_FILE_DATA,
785
Bill Richardson36bc5912015-03-04 16:13:45 -0800786 /* Unable to convert string to struct vb_id */
787 VB2_ERROR_STR_TO_ID,
Bill Richardson4e4c1962015-02-03 17:07:15 -0800788
Joel Kitching9ad8a412018-08-02 16:21:17 +0800789 /**********************************************************************
Randall Spangler59c29202014-11-17 14:24:59 -0800790 * Errors generated by host library key functions
791 */
792 VB2_ERROR_HOST_KEY = VB2_ERROR_HOST_BASE + 0x020000,
793
794 /* Unable to allocate key in vb2_private_key_read_pem() */
795 VB2_ERROR_READ_PEM_ALLOC,
796
797 /* Unable to open .pem file in vb2_private_key_read_pem() */
798 VB2_ERROR_READ_PEM_FILE_OPEN,
799
800 /* Bad RSA data from .pem file in vb2_private_key_read_pem() */
801 VB2_ERROR_READ_PEM_RSA,
802
803 /* Unable to set private key description */
804 VB2_ERROR_PRIVATE_KEY_SET_DESC,
805
806 /* Bad magic number in vb2_private_key_unpack() */
807 VB2_ERROR_UNPACK_PRIVATE_KEY_MAGIC,
808
809 /* Bad common header in vb2_private_key_unpack() */
810 VB2_ERROR_UNPACK_PRIVATE_KEY_HEADER,
811
812 /* Bad key data in vb2_private_key_unpack() */
813 VB2_ERROR_UNPACK_PRIVATE_KEY_DATA,
814
815 /* Bad struct version in vb2_private_key_unpack() */
816 VB2_ERROR_UNPACK_PRIVATE_KEY_STRUCT_VERSION,
817
818 /* Unable to allocate buffer in vb2_private_key_unpack() */
819 VB2_ERROR_UNPACK_PRIVATE_KEY_ALLOC,
820
821 /* Unable to unpack RSA key in vb2_private_key_unpack() */
822 VB2_ERROR_UNPACK_PRIVATE_KEY_RSA,
823
824 /* Unable to set description in vb2_private_key_unpack() */
825 VB2_ERROR_UNPACK_PRIVATE_KEY_DESC,
826
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800827 /* Bad bare hash key in vb2_private_key_unpack() */
828 VB2_ERROR_UNPACK_PRIVATE_KEY_HASH,
829
Randall Spangler59c29202014-11-17 14:24:59 -0800830 /* Unable to create RSA data in vb2_private_key_write() */
831 VB2_ERROR_PRIVATE_KEY_WRITE_RSA,
832
833 /* Unable to allocate packed key buffer in vb2_private_key_write() */
834 VB2_ERROR_PRIVATE_KEY_WRITE_ALLOC,
835
836 /* Unable to write file in vb2_private_key_write() */
837 VB2_ERROR_PRIVATE_KEY_WRITE_FILE,
838
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800839 /* Bad algorithm in vb2_private_key_hash() */
840 VB2_ERROR_PRIVATE_KEY_HASH,
841
Randall Spangler59c29202014-11-17 14:24:59 -0800842 /* Unable to determine key size in vb2_public_key_alloc() */
843 VB2_ERROR_PUBLIC_KEY_ALLOC_SIZE,
844
845 /* Unable to allocate buffer in vb2_public_key_alloc() */
846 VB2_ERROR_PUBLIC_KEY_ALLOC,
847
848 /* Unable to set public key description */
849 VB2_ERROR_PUBLIC_KEY_SET_DESC,
850
851 /* Unable to read key data in vb2_public_key_read_keyb() */
852 VB2_ERROR_READ_KEYB_DATA,
853
854 /* Wrong amount of data read in vb2_public_key_read_keyb() */
855 VB2_ERROR_READ_KEYB_SIZE,
856
857 /* Unable to allocate key buffer in vb2_public_key_read_keyb() */
858 VB2_ERROR_READ_KEYB_ALLOC,
859
860 /* Error unpacking RSA arrays in vb2_public_key_read_keyb() */
861 VB2_ERROR_READ_KEYB_UNPACK,
862
863 /* Unable to read key data in vb2_packed_key_read() */
864 VB2_ERROR_READ_PACKED_KEY_DATA,
865
866 /* Bad key data in vb2_packed_key_read() */
867 VB2_ERROR_READ_PACKED_KEY,
868
869 /* Unable to determine key size in vb2_public_key_pack() */
870 VB2_ERROR_PUBLIC_KEY_PACK_SIZE,
871
Bill Richardson4e4c1962015-02-03 17:07:15 -0800872 /* Bad hash algorithm in vb2_public_key_hash() */
Randall Spanglerfb9a2162014-11-20 11:27:38 -0800873 VB2_ERROR_PUBLIC_KEY_HASH,
874
Randall Spangler939cc3a2016-06-21 15:23:32 -0700875 /* Bad key size in vb2_copy_packed_key() */
876 VB2_ERROR_COPY_KEY_SIZE,
877
Randall Spanglerd46461c2016-06-22 16:46:23 -0700878 /* Unable to convert back to vb1 crypto algorithm */
879 VB2_ERROR_VB1_CRYPTO_ALGORITHM,
880
Randall Spanglerf7559e42016-06-23 13:45:59 -0700881 /* Unable to allocate packed key */
882 VB2_ERROR_PACKED_KEY_ALLOC,
883
884 /* Unable to copy packed key */
885 VB2_ERROR_PACKED_KEY_COPY,
886
Joel Kitching9ad8a412018-08-02 16:21:17 +0800887 /**********************************************************************
Randall Spanglerc644a8c2014-11-21 11:04:36 -0800888 * Errors generated by host library signature functions
889 */
890 VB2_ERROR_HOST_SIG = VB2_ERROR_HOST_BASE + 0x030000,
891
892 /* Bad hash algorithm in vb2_digest_info() */
893 VB2_ERROR_DIGEST_INFO,
894
895 /*
896 * Unable to determine signature size for key algorithm in
897 * vb2_sig_size_for_key().
898 */
899 VB2_ERROR_SIG_SIZE_FOR_KEY,
900
901 /* Bad signature size in vb2_sign_data() */
902 VB2_SIGN_DATA_SIG_SIZE,
903
904 /* Unable to get digest info in vb2_sign_data() */
905 VB2_SIGN_DATA_DIGEST_INFO,
906
907 /* Unable to get digest size in vb2_sign_data() */
908 VB2_SIGN_DATA_DIGEST_SIZE,
909
910 /* Unable to allocate digest buffer in vb2_sign_data() */
911 VB2_SIGN_DATA_DIGEST_ALLOC,
912
913 /* Unable to initialize digest in vb2_sign_data() */
914 VB2_SIGN_DATA_DIGEST_INIT,
915
916 /* Unable to extend digest in vb2_sign_data() */
917 VB2_SIGN_DATA_DIGEST_EXTEND,
918
919 /* Unable to finalize digest in vb2_sign_data() */
920 VB2_SIGN_DATA_DIGEST_FINALIZE,
921
922 /* RSA encrypt failed in vb2_sign_data() */
923 VB2_SIGN_DATA_RSA_ENCRYPT,
924
925 /* Not enough buffer space to hold signature in vb2_sign_object() */
926 VB2_SIGN_OBJECT_OVERFLOW,
927
Joel Kitching9ad8a412018-08-02 16:21:17 +0800928 /**********************************************************************
Randall Spangler9328bbf2014-11-24 12:55:29 -0800929 * Errors generated by host library keyblock functions
930 */
931 VB2_ERROR_HOST_KEYBLOCK = VB2_ERROR_HOST_BASE + 0x040000,
932
933 /* Unable to determine signature sizes for vb2_create_keyblock() */
934 VB2_KEYBLOCK_CREATE_SIG_SIZE,
935
936 /* Unable to pack data key for vb2_create_keyblock() */
937 VB2_KEYBLOCK_CREATE_DATA_KEY,
938
939 /* Unable to allocate buffer in vb2_create_keyblock() */
940 VB2_KEYBLOCK_CREATE_ALLOC,
941
942 /* Unable to sign keyblock in vb2_create_keyblock() */
943 VB2_KEYBLOCK_CREATE_SIGN,
944
Joel Kitching9ad8a412018-08-02 16:21:17 +0800945 /**********************************************************************
Randall Spangler42a85002014-11-25 10:52:59 -0800946 * Errors generated by host library firmware preamble functions
947 */
948 VB2_ERROR_HOST_FW_PREAMBLE = VB2_ERROR_HOST_BASE + 0x050000,
949
950 /* Unable to determine signature sizes for vb2_create_fw_preamble() */
951 VB2_FW_PREAMBLE_CREATE_SIG_SIZE,
952
953 /* Unable to allocate buffer in vb2_create_fw_preamble() */
954 VB2_FW_PREAMBLE_CREATE_ALLOC,
955
956 /* Unable to sign preamble in vb2_create_fw_preamble() */
957 VB2_FW_PREAMBLE_CREATE_SIGN,
958
Joel Kitching9ad8a412018-08-02 16:21:17 +0800959 /**********************************************************************
Randall Spanglerf87aa722016-09-09 10:49:37 -0700960 * Errors generated by unit test functions
961 */
962 VB2_ERROR_UNIT_TEST = VB2_ERROR_HOST_BASE + 0x060000,
963
964 /* Unable to open an input file needed for a unit test */
965 VB2_ERROR_TEST_INPUT_FILE,
966
Joel Kitching9ad8a412018-08-02 16:21:17 +0800967 /**********************************************************************
Randall Spanglerb9be5362014-06-05 13:32:11 -0700968 * Highest non-zero error generated inside vboot library. Note that
969 * error codes passed through vboot when it calls external APIs may
970 * still be outside this range.
971 */
Randall Spangler02e11b32014-11-19 12:48:36 -0800972 VB2_ERROR_MAX = VB2_ERROR_BASE + 0x1fffffff,
Randall Spangler786acda2014-05-22 13:27:07 -0700973};
974
Joel Kitching9adf2aa2019-08-20 17:43:50 +0800975#endif /* VBOOT_REFERENCE_2RETURN_CODES_H_ */