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