xref: /rk3399_rockchip-uboot/include/android_avb/avb_slot_verify.h (revision 5b69db0720b90f33ecb7fb666b196bfc90404185)
1*5b69db07SJason Zhu /*
2*5b69db07SJason Zhu  * Copyright (C) 2016 The Android Open Source Project
3*5b69db07SJason Zhu  *
4*5b69db07SJason Zhu  * Permission is hereby granted, free of charge, to any person
5*5b69db07SJason Zhu  * obtaining a copy of this software and associated documentation
6*5b69db07SJason Zhu  * files (the "Software"), to deal in the Software without
7*5b69db07SJason Zhu  * restriction, including without limitation the rights to use, copy,
8*5b69db07SJason Zhu  * modify, merge, publish, distribute, sublicense, and/or sell copies
9*5b69db07SJason Zhu  * of the Software, and to permit persons to whom the Software is
10*5b69db07SJason Zhu  * furnished to do so, subject to the following conditions:
11*5b69db07SJason Zhu  *
12*5b69db07SJason Zhu  * The above copyright notice and this permission notice shall be
13*5b69db07SJason Zhu  * included in all copies or substantial portions of the Software.
14*5b69db07SJason Zhu  *
15*5b69db07SJason Zhu  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*5b69db07SJason Zhu  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*5b69db07SJason Zhu  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18*5b69db07SJason Zhu  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19*5b69db07SJason Zhu  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20*5b69db07SJason Zhu  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21*5b69db07SJason Zhu  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*5b69db07SJason Zhu  * SOFTWARE.
23*5b69db07SJason Zhu  */
24*5b69db07SJason Zhu 
25*5b69db07SJason Zhu /*
26*5b69db07SJason Zhu #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION)
27*5b69db07SJason Zhu #error "Never include this file directly, include libavb.h instead."
28*5b69db07SJason Zhu #endif
29*5b69db07SJason Zhu */
30*5b69db07SJason Zhu 
31*5b69db07SJason Zhu #ifndef AVB_SLOT_VERIFY_H_
32*5b69db07SJason Zhu #define AVB_SLOT_VERIFY_H_
33*5b69db07SJason Zhu 
34*5b69db07SJason Zhu #include <android_avb/avb_ops.h>
35*5b69db07SJason Zhu #include <android_avb/avb_vbmeta_image.h>
36*5b69db07SJason Zhu 
37*5b69db07SJason Zhu #ifdef __cplusplus
38*5b69db07SJason Zhu extern "C" {
39*5b69db07SJason Zhu #endif
40*5b69db07SJason Zhu 
41*5b69db07SJason Zhu /* Return codes used in avb_slot_verify(), see that function for
42*5b69db07SJason Zhu  * documentation for each field.
43*5b69db07SJason Zhu  *
44*5b69db07SJason Zhu  * Use avb_slot_verify_result_to_string() to get a textual
45*5b69db07SJason Zhu  * representation usable for error/debug output.
46*5b69db07SJason Zhu  */
47*5b69db07SJason Zhu typedef enum {
48*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_OK,
49*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_OOM,
50*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_IO,
51*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION,
52*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX,
53*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED,
54*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA,
55*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION,
56*5b69db07SJason Zhu   AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT
57*5b69db07SJason Zhu } AvbSlotVerifyResult;
58*5b69db07SJason Zhu 
59*5b69db07SJason Zhu /* Various error handling modes for when verification fails using a
60*5b69db07SJason Zhu  * hashtree at runtime inside the HLOS.
61*5b69db07SJason Zhu  *
62*5b69db07SJason Zhu  * AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE means that the OS
63*5b69db07SJason Zhu  * will invalidate the current slot and restart.
64*5b69db07SJason Zhu  *
65*5b69db07SJason Zhu  * AVB_HASHTREE_ERROR_MODE_RESTART means that the OS will restart.
66*5b69db07SJason Zhu  *
67*5b69db07SJason Zhu  * AVB_HASHTREE_ERROR_MODE_EIO means that an EIO error will be
68*5b69db07SJason Zhu  * returned to applications.
69*5b69db07SJason Zhu  *
70*5b69db07SJason Zhu  * AVB_HASHTREE_ERROR_MODE_LOGGING means that errors will be logged
71*5b69db07SJason Zhu  * and corrupt data may be returned to applications. This mode should
72*5b69db07SJason Zhu  * be used ONLY for diagnostics and debugging. It cannot be used
73*5b69db07SJason Zhu  * unless AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is also
74*5b69db07SJason Zhu  * used.
75*5b69db07SJason Zhu  */
76*5b69db07SJason Zhu typedef enum {
77*5b69db07SJason Zhu   AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE,
78*5b69db07SJason Zhu   AVB_HASHTREE_ERROR_MODE_RESTART,
79*5b69db07SJason Zhu   AVB_HASHTREE_ERROR_MODE_EIO,
80*5b69db07SJason Zhu   AVB_HASHTREE_ERROR_MODE_LOGGING
81*5b69db07SJason Zhu } AvbHashtreeErrorMode;
82*5b69db07SJason Zhu 
83*5b69db07SJason Zhu /* Flags that influence how avb_slot_verify() works.
84*5b69db07SJason Zhu  *
85*5b69db07SJason Zhu  * If AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is NOT set then
86*5b69db07SJason Zhu  * avb_slot_verify() will bail out as soon as an error is encountered
87*5b69db07SJason Zhu  * and |out_data| is set only if AVB_SLOT_VERIFY_RESULT_OK is
88*5b69db07SJason Zhu  * returned.
89*5b69db07SJason Zhu  *
90*5b69db07SJason Zhu  * Otherwise if AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is set
91*5b69db07SJason Zhu  * avb_slot_verify() will continue verification efforts and |out_data|
92*5b69db07SJason Zhu  * is also set if AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED,
93*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION, or
94*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX is returned. It is
95*5b69db07SJason Zhu  * undefined which error is returned if more than one distinct error
96*5b69db07SJason Zhu  * is encountered. It is guaranteed that AVB_SLOT_VERIFY_RESULT_OK is
97*5b69db07SJason Zhu  * returned if, and only if, there are no errors. This mode is needed
98*5b69db07SJason Zhu  * to boot valid but unverified slots when the device is unlocked.
99*5b69db07SJason Zhu  *
100*5b69db07SJason Zhu  * Also, if AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is set the
101*5b69db07SJason Zhu  * contents loaded from |requested_partition| will be the contents of
102*5b69db07SJason Zhu  * the entire partition instead of just the size specified in the hash
103*5b69db07SJason Zhu  * descriptor.
104*5b69db07SJason Zhu  */
105*5b69db07SJason Zhu typedef enum {
106*5b69db07SJason Zhu   AVB_SLOT_VERIFY_FLAGS_NONE = 0,
107*5b69db07SJason Zhu   AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR = (1 << 0)
108*5b69db07SJason Zhu } AvbSlotVerifyFlags;
109*5b69db07SJason Zhu 
110*5b69db07SJason Zhu /* Get a textual representation of |result|. */
111*5b69db07SJason Zhu const char* avb_slot_verify_result_to_string(AvbSlotVerifyResult result);
112*5b69db07SJason Zhu 
113*5b69db07SJason Zhu /* Maximum number of rollback index locations supported. */
114*5b69db07SJason Zhu #define AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS 32
115*5b69db07SJason Zhu 
116*5b69db07SJason Zhu /* AvbPartitionData contains data loaded from partitions when using
117*5b69db07SJason Zhu  * avb_slot_verify(). The |partition_name| field contains the name of
118*5b69db07SJason Zhu  * the partition (without A/B suffix), |data| points to the loaded
119*5b69db07SJason Zhu  * data which is |data_size| bytes long.
120*5b69db07SJason Zhu  *
121*5b69db07SJason Zhu  * Note that this is strictly less than the partition size - it's only
122*5b69db07SJason Zhu  * the image stored there, not the entire partition nor any of the
123*5b69db07SJason Zhu  * metadata.
124*5b69db07SJason Zhu  */
125*5b69db07SJason Zhu typedef struct {
126*5b69db07SJason Zhu   char* partition_name;
127*5b69db07SJason Zhu   uint8_t* data;
128*5b69db07SJason Zhu   size_t data_size;
129*5b69db07SJason Zhu } AvbPartitionData;
130*5b69db07SJason Zhu 
131*5b69db07SJason Zhu /* AvbVBMetaData contains a vbmeta struct loaded from a partition when
132*5b69db07SJason Zhu  * using avb_slot_verify(). The |partition_name| field contains the
133*5b69db07SJason Zhu  * name of the partition (without A/B suffix), |vbmeta_data| points to
134*5b69db07SJason Zhu  * the loaded data which is |vbmeta_size| bytes long.
135*5b69db07SJason Zhu  *
136*5b69db07SJason Zhu  * The |verify_result| field contains the result of
137*5b69db07SJason Zhu  * avb_vbmeta_image_verify() on the data. This is guaranteed to be
138*5b69db07SJason Zhu  * AVB_VBMETA_VERIFY_RESULT_OK for all vbmeta images if
139*5b69db07SJason Zhu  * avb_slot_verify() returns AVB_SLOT_VERIFY_RESULT_OK.
140*5b69db07SJason Zhu  *
141*5b69db07SJason Zhu  * You can use avb_descriptor_get_all(), avb_descriptor_foreach(), and
142*5b69db07SJason Zhu  * avb_vbmeta_image_header_to_host_byte_order() with this data.
143*5b69db07SJason Zhu  */
144*5b69db07SJason Zhu typedef struct {
145*5b69db07SJason Zhu   char* partition_name;
146*5b69db07SJason Zhu   uint8_t* vbmeta_data;
147*5b69db07SJason Zhu   size_t vbmeta_size;
148*5b69db07SJason Zhu   AvbVBMetaVerifyResult verify_result;
149*5b69db07SJason Zhu } AvbVBMetaData;
150*5b69db07SJason Zhu 
151*5b69db07SJason Zhu /* AvbSlotVerifyData contains data needed to boot a particular slot
152*5b69db07SJason Zhu  * and is returned by avb_slot_verify() if partitions in a slot are
153*5b69db07SJason Zhu  * successfully verified.
154*5b69db07SJason Zhu  *
155*5b69db07SJason Zhu  * All data pointed to by this struct - including data in each item in
156*5b69db07SJason Zhu  * the |partitions| array - will be freed when the
157*5b69db07SJason Zhu  * avb_slot_verify_data_free() function is called.
158*5b69db07SJason Zhu  *
159*5b69db07SJason Zhu  * The |ab_suffix| field is the copy of the of |ab_suffix| field
160*5b69db07SJason Zhu  * passed to avb_slot_verify(). It is the A/B suffix of the slot. This
161*5b69db07SJason Zhu  * value includes the leading underscore - typical values are "" (if
162*5b69db07SJason Zhu  * no slots are in use), "_a" (for the first slot), and "_b" (for the
163*5b69db07SJason Zhu  * second slot).
164*5b69db07SJason Zhu  *
165*5b69db07SJason Zhu  * The VBMeta images that were checked are available in the
166*5b69db07SJason Zhu  * |vbmeta_images| field. The field |num_vbmeta_images| contains the
167*5b69db07SJason Zhu  * number of elements in this array. The first element -
168*5b69db07SJason Zhu  * vbmeta_images[0] - is guaranteed to be from the partition with the
169*5b69db07SJason Zhu  * top-level vbmeta struct. This is usually the "vbmeta" partition in
170*5b69db07SJason Zhu  * the requested slot but if there is no "vbmeta" partition it can
171*5b69db07SJason Zhu  * also be the "boot" partition.
172*5b69db07SJason Zhu  *
173*5b69db07SJason Zhu  * The partitions loaded and verified from from the slot are
174*5b69db07SJason Zhu  * accessible in the |loaded_partitions| array. The field
175*5b69db07SJason Zhu  * |num_loaded_partitions| contains the number of elements in this
176*5b69db07SJason Zhu  * array. The order of partitions in this array may not necessarily be
177*5b69db07SJason Zhu  * the same order as in the passed-in |requested_partitions| array.
178*5b69db07SJason Zhu  *
179*5b69db07SJason Zhu  * Rollback indexes for the verified slot are stored in the
180*5b69db07SJason Zhu  * |rollback_indexes| field. Note that avb_slot_verify() will NEVER
181*5b69db07SJason Zhu  * modify stored_rollback_index[n] locations e.g. it will never use
182*5b69db07SJason Zhu  * the write_rollback_index() AvbOps operation. Instead it is the job
183*5b69db07SJason Zhu  * of the caller of avb_slot_verify() to do this based on e.g. A/B
184*5b69db07SJason Zhu  * policy and other factors. See libavb_ab/avb_ab_flow.c for an
185*5b69db07SJason Zhu  * example of how to do this.
186*5b69db07SJason Zhu  *
187*5b69db07SJason Zhu  * The |cmdline| field is a NUL-terminated string in UTF-8 resulting
188*5b69db07SJason Zhu  * from concatenating all |AvbKernelCmdlineDescriptor| and then
189*5b69db07SJason Zhu  * performing proper substitution of the variables
190*5b69db07SJason Zhu  * $(ANDROID_SYSTEM_PARTUUID), $(ANDROID_BOOT_PARTUUID), and
191*5b69db07SJason Zhu  * $(ANDROID_VBMETA_PARTUUID) using the
192*5b69db07SJason Zhu  * get_unique_guid_for_partition() operation in |AvbOps|. Additionally
193*5b69db07SJason Zhu  * $(ANDROID_VERITY_MODE) will be replaced with the proper dm-verity
194*5b69db07SJason Zhu  * option depending on the value of |hashtree_error_mode|.
195*5b69db07SJason Zhu  *
196*5b69db07SJason Zhu  * Additionally, the |cmdline| field will have the following kernel
197*5b69db07SJason Zhu  * command-line options set:
198*5b69db07SJason Zhu  *
199*5b69db07SJason Zhu  *   androidboot.veritymode: This is set to 'disabled' if the
200*5b69db07SJason Zhu  *   AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED flag is set in top-level
201*5b69db07SJason Zhu  *   vbmeta struct. Otherwise it is set to 'enforcing' if the
202*5b69db07SJason Zhu  *   passed-in hashtree error mode is AVB_HASHTREE_ERROR_MODE_RESTART
203*5b69db07SJason Zhu  *   or AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE, 'eio' if it's
204*5b69db07SJason Zhu  *   set to AVB_HASHTREE_ERROR_MODE_EIO, and 'logging' if it's set to
205*5b69db07SJason Zhu  *   AVB_HASHTREE_ERROR_MODE_LOGGING.
206*5b69db07SJason Zhu  *
207*5b69db07SJason Zhu  *   androidboot.vbmeta.invalidate_on_error: This is set to 'yes' only
208*5b69db07SJason Zhu  *   if hashtree validation isn't disabled and the passed-in hashtree
209*5b69db07SJason Zhu  *   error mode is AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE.
210*5b69db07SJason Zhu  *
211*5b69db07SJason Zhu  *   androidboot.vbmeta.device_state: set to "locked" or "unlocked"
212*5b69db07SJason Zhu  *   depending on the result of the result of AvbOps's
213*5b69db07SJason Zhu  *   read_is_unlocked() function.
214*5b69db07SJason Zhu  *
215*5b69db07SJason Zhu  *   androidboot.vbmeta.{hash_alg, size, digest}: Will be set to
216*5b69db07SJason Zhu  *   the digest of all images in |vbmeta_images|.
217*5b69db07SJason Zhu  *
218*5b69db07SJason Zhu  *   androidboot.vbmeta.device: This is set to the value
219*5b69db07SJason Zhu  *   PARTUUID=$(ANDROID_VBMETA_PARTUUID) before substitution so it
220*5b69db07SJason Zhu  *   will end up pointing to the vbmeta partition for the verified
221*5b69db07SJason Zhu  *   slot. If there is no vbmeta partition it will point to the boot
222*5b69db07SJason Zhu  *   partition of the verified slot.
223*5b69db07SJason Zhu  *
224*5b69db07SJason Zhu  *   androidboot.vbmeta.avb_version: This is set to the decimal value
225*5b69db07SJason Zhu  *   of AVB_VERSION_MAJOR followed by a dot followed by the decimal
226*5b69db07SJason Zhu  *   value of AVB_VERSION_MINOR, for example "1.0" or "1.4". This
227*5b69db07SJason Zhu  *   version number represents the vbmeta file format version
228*5b69db07SJason Zhu  *   supported by libavb copy used in the boot loader. This is not
229*5b69db07SJason Zhu  *   necessarily the same version number of the on-disk metadata for
230*5b69db07SJason Zhu  *   the slot that was verified.
231*5b69db07SJason Zhu  *
232*5b69db07SJason Zhu  * Note that neither androidboot.slot_suffix nor androidboot.slot are
233*5b69db07SJason Zhu  * set in the |cmdline| field in |AvbSlotVerifyData| - you will have
234*5b69db07SJason Zhu  * to pass these yourself.
235*5b69db07SJason Zhu  *
236*5b69db07SJason Zhu  * Also note that androidboot.veritymode is set by libavb and since
237*5b69db07SJason Zhu  * AVB only supports 'enforcing' and 'disabled' values, the boot
238*5b69db07SJason Zhu  * loader is relieved of managing any state related to dm-verity or
239*5b69db07SJason Zhu  * setting this cmdline parameter.
240*5b69db07SJason Zhu  *
241*5b69db07SJason Zhu  * This struct may grow in the future without it being considered an
242*5b69db07SJason Zhu  * ABI break.
243*5b69db07SJason Zhu  */
244*5b69db07SJason Zhu typedef struct {
245*5b69db07SJason Zhu   char* ab_suffix;
246*5b69db07SJason Zhu   AvbVBMetaData* vbmeta_images;
247*5b69db07SJason Zhu   size_t num_vbmeta_images;
248*5b69db07SJason Zhu   AvbPartitionData* loaded_partitions;
249*5b69db07SJason Zhu   size_t num_loaded_partitions;
250*5b69db07SJason Zhu   char* cmdline;
251*5b69db07SJason Zhu   uint64_t rollback_indexes[AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS];
252*5b69db07SJason Zhu } AvbSlotVerifyData;
253*5b69db07SJason Zhu 
254*5b69db07SJason Zhu /* Frees a |AvbSlotVerifyData| including all data it points to. */
255*5b69db07SJason Zhu void avb_slot_verify_data_free(AvbSlotVerifyData* data);
256*5b69db07SJason Zhu 
257*5b69db07SJason Zhu /* Performs a full verification of the slot identified by |ab_suffix|
258*5b69db07SJason Zhu  * and load and verify the contents of the partitions whose name is in
259*5b69db07SJason Zhu  * the NULL-terminated string array |requested_partitions| (each
260*5b69db07SJason Zhu  * partition must use hash verification). If not using A/B, pass an
261*5b69db07SJason Zhu  * empty string (e.g. "", not NULL) for |ab_suffix|. This parameter
262*5b69db07SJason Zhu  * must include the leading underscore, for example "_a" should be
263*5b69db07SJason Zhu  * used to refer to the first slot.
264*5b69db07SJason Zhu  *
265*5b69db07SJason Zhu  * Typically the |requested_partitions| array only contains a single
266*5b69db07SJason Zhu  * item for the boot partition, 'boot'.
267*5b69db07SJason Zhu  *
268*5b69db07SJason Zhu  * Verification includes loading and verifying data from the 'vbmeta',
269*5b69db07SJason Zhu  * the requested hash partitions, and possibly other partitions (with
270*5b69db07SJason Zhu  * |ab_suffix| appended), inspecting rollback indexes, and checking if
271*5b69db07SJason Zhu  * the public key used to sign the data is acceptable. The functions
272*5b69db07SJason Zhu  * in |ops| will be used to do this.
273*5b69db07SJason Zhu  *
274*5b69db07SJason Zhu  * If |out_data| is not NULL, it will be set to a newly allocated
275*5b69db07SJason Zhu  * |AvbSlotVerifyData| struct containing all the data needed to
276*5b69db07SJason Zhu  * actually boot the slot. This data structure should be freed with
277*5b69db07SJason Zhu  * avb_slot_verify_data_free() when you are done with it. See below
278*5b69db07SJason Zhu  * for when this is returned.
279*5b69db07SJason Zhu  *
280*5b69db07SJason Zhu  * The |flags| parameter is used to influence the semantics of
281*5b69db07SJason Zhu  * avb_slot_verify() - for example the
282*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR flag can be used to
283*5b69db07SJason Zhu  * ignore verification errors which is something needed in the
284*5b69db07SJason Zhu  * UNLOCKED state. See the AvbSlotVerifyFlags enumeration for details.
285*5b69db07SJason Zhu  *
286*5b69db07SJason Zhu  * The |hashtree_error_mode| parameter should be set to the desired
287*5b69db07SJason Zhu  * error handling mode when hashtree validation fails inside the
288*5b69db07SJason Zhu  * HLOS. This value isn't used by libavb per se - it is forwarded to
289*5b69db07SJason Zhu  * the HLOS through the androidboot.veritymode and
290*5b69db07SJason Zhu  * androidboot.vbmeta.invalidate_on_error cmdline parameters. See the
291*5b69db07SJason Zhu  * AvbHashtreeErrorMode enumeration for details.
292*5b69db07SJason Zhu  *
293*5b69db07SJason Zhu  * Also note that |out_data| is never set if
294*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_OOM, AVB_SLOT_VERIFY_RESULT_ERROR_IO,
295*5b69db07SJason Zhu  * or AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA is returned.
296*5b69db07SJason Zhu  *
297*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_OK is returned if everything is verified
298*5b69db07SJason Zhu  * correctly and all public keys are accepted.
299*5b69db07SJason Zhu  *
300*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED is returned if
301*5b69db07SJason Zhu  * everything is verified correctly out but one or more public keys
302*5b69db07SJason Zhu  * are not accepted. This includes the case where integrity data is
303*5b69db07SJason Zhu  * not signed.
304*5b69db07SJason Zhu  *
305*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_OOM is returned if unable to
306*5b69db07SJason Zhu  * allocate memory.
307*5b69db07SJason Zhu  *
308*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_IO is returned if an I/O error
309*5b69db07SJason Zhu  * occurred while trying to load data or get a rollback index.
310*5b69db07SJason Zhu  *
311*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION is returned if the data
312*5b69db07SJason Zhu  * did not verify, e.g. the digest didn't match or signature checks
313*5b69db07SJason Zhu  * failed.
314*5b69db07SJason Zhu  *
315*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX is returned if a
316*5b69db07SJason Zhu  * rollback index was less than its stored value.
317*5b69db07SJason Zhu  *
318*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA is returned if some
319*5b69db07SJason Zhu  * of the metadata is invalid or inconsistent.
320*5b69db07SJason Zhu  *
321*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION is returned if
322*5b69db07SJason Zhu  * some of the metadata requires a newer version of libavb than what
323*5b69db07SJason Zhu  * is in use.
324*5b69db07SJason Zhu  *
325*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT is returned if the
326*5b69db07SJason Zhu  * caller passed invalid parameters, for example trying to use
327*5b69db07SJason Zhu  * AVB_HASHTREE_ERROR_MODE_LOGGING without
328*5b69db07SJason Zhu  * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR.
329*5b69db07SJason Zhu  */
330*5b69db07SJason Zhu AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
331*5b69db07SJason Zhu                                     const char* const* requested_partitions,
332*5b69db07SJason Zhu                                     const char* ab_suffix,
333*5b69db07SJason Zhu                                     AvbSlotVerifyFlags flags,
334*5b69db07SJason Zhu                                     AvbHashtreeErrorMode hashtree_error_mode,
335*5b69db07SJason Zhu                                     AvbSlotVerifyData** out_data);
336*5b69db07SJason Zhu 
337*5b69db07SJason Zhu #ifdef __cplusplus
338*5b69db07SJason Zhu }
339*5b69db07SJason Zhu #endif
340*5b69db07SJason Zhu 
341*5b69db07SJason Zhu #endif /* AVB_SLOT_VERIFY_H_ */
342