15b69db07SJason Zhu /* 25b69db07SJason Zhu * Copyright (C) 2016 The Android Open Source Project 35b69db07SJason Zhu * 45b69db07SJason Zhu * Permission is hereby granted, free of charge, to any person 55b69db07SJason Zhu * obtaining a copy of this software and associated documentation 65b69db07SJason Zhu * files (the "Software"), to deal in the Software without 75b69db07SJason Zhu * restriction, including without limitation the rights to use, copy, 85b69db07SJason Zhu * modify, merge, publish, distribute, sublicense, and/or sell copies 95b69db07SJason Zhu * of the Software, and to permit persons to whom the Software is 105b69db07SJason Zhu * furnished to do so, subject to the following conditions: 115b69db07SJason Zhu * 125b69db07SJason Zhu * The above copyright notice and this permission notice shall be 135b69db07SJason Zhu * included in all copies or substantial portions of the Software. 145b69db07SJason Zhu * 155b69db07SJason Zhu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 165b69db07SJason Zhu * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 175b69db07SJason Zhu * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 185b69db07SJason Zhu * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 195b69db07SJason Zhu * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 205b69db07SJason Zhu * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 215b69db07SJason Zhu * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 225b69db07SJason Zhu * SOFTWARE. 235b69db07SJason Zhu */ 245b69db07SJason Zhu 255b69db07SJason Zhu /* 265b69db07SJason Zhu #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION) 275b69db07SJason Zhu #error "Never include this file directly, include libavb.h instead." 285b69db07SJason Zhu #endif 295b69db07SJason Zhu */ 305b69db07SJason Zhu 315b69db07SJason Zhu #ifndef AVB_SLOT_VERIFY_H_ 325b69db07SJason Zhu #define AVB_SLOT_VERIFY_H_ 335b69db07SJason Zhu 345b69db07SJason Zhu #include <android_avb/avb_ops.h> 355b69db07SJason Zhu #include <android_avb/avb_vbmeta_image.h> 365b69db07SJason Zhu 375b69db07SJason Zhu #ifdef __cplusplus 385b69db07SJason Zhu extern "C" { 395b69db07SJason Zhu #endif 405b69db07SJason Zhu 415b69db07SJason Zhu /* Return codes used in avb_slot_verify(), see that function for 425b69db07SJason Zhu * documentation for each field. 435b69db07SJason Zhu * 445b69db07SJason Zhu * Use avb_slot_verify_result_to_string() to get a textual 455b69db07SJason Zhu * representation usable for error/debug output. 465b69db07SJason Zhu */ 475b69db07SJason Zhu typedef enum { 485b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_OK, 495b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_OOM, 505b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_IO, 515b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION, 525b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX, 535b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED, 545b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA, 555b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION, 565b69db07SJason Zhu AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT 575b69db07SJason Zhu } AvbSlotVerifyResult; 585b69db07SJason Zhu 595b69db07SJason Zhu /* Various error handling modes for when verification fails using a 605b69db07SJason Zhu * hashtree at runtime inside the HLOS. 615b69db07SJason Zhu * 625b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE means that the OS 635b69db07SJason Zhu * will invalidate the current slot and restart. 645b69db07SJason Zhu * 655b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_RESTART means that the OS will restart. 665b69db07SJason Zhu * 675b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_EIO means that an EIO error will be 685b69db07SJason Zhu * returned to applications. 695b69db07SJason Zhu * 705b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_LOGGING means that errors will be logged 715b69db07SJason Zhu * and corrupt data may be returned to applications. This mode should 725b69db07SJason Zhu * be used ONLY for diagnostics and debugging. It cannot be used 735b69db07SJason Zhu * unless AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is also 745b69db07SJason Zhu * used. 755b69db07SJason Zhu */ 765b69db07SJason Zhu typedef enum { 775b69db07SJason Zhu AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE, 785b69db07SJason Zhu AVB_HASHTREE_ERROR_MODE_RESTART, 795b69db07SJason Zhu AVB_HASHTREE_ERROR_MODE_EIO, 805b69db07SJason Zhu AVB_HASHTREE_ERROR_MODE_LOGGING 815b69db07SJason Zhu } AvbHashtreeErrorMode; 825b69db07SJason Zhu 835b69db07SJason Zhu /* Flags that influence how avb_slot_verify() works. 845b69db07SJason Zhu * 855b69db07SJason Zhu * If AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is NOT set then 865b69db07SJason Zhu * avb_slot_verify() will bail out as soon as an error is encountered 875b69db07SJason Zhu * and |out_data| is set only if AVB_SLOT_VERIFY_RESULT_OK is 885b69db07SJason Zhu * returned. 895b69db07SJason Zhu * 905b69db07SJason Zhu * Otherwise if AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is set 915b69db07SJason Zhu * avb_slot_verify() will continue verification efforts and |out_data| 925b69db07SJason Zhu * is also set if AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED, 935b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION, or 945b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX is returned. It is 955b69db07SJason Zhu * undefined which error is returned if more than one distinct error 965b69db07SJason Zhu * is encountered. It is guaranteed that AVB_SLOT_VERIFY_RESULT_OK is 975b69db07SJason Zhu * returned if, and only if, there are no errors. This mode is needed 985b69db07SJason Zhu * to boot valid but unverified slots when the device is unlocked. 995b69db07SJason Zhu * 1005b69db07SJason Zhu * Also, if AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR is set the 1015b69db07SJason Zhu * contents loaded from |requested_partition| will be the contents of 1025b69db07SJason Zhu * the entire partition instead of just the size specified in the hash 1035b69db07SJason Zhu * descriptor. 1045b69db07SJason Zhu */ 1055b69db07SJason Zhu typedef enum { 1065b69db07SJason Zhu AVB_SLOT_VERIFY_FLAGS_NONE = 0, 1075b69db07SJason Zhu AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR = (1 << 0) 1085b69db07SJason Zhu } AvbSlotVerifyFlags; 1095b69db07SJason Zhu 1105b69db07SJason Zhu /* Get a textual representation of |result|. */ 1115b69db07SJason Zhu const char* avb_slot_verify_result_to_string(AvbSlotVerifyResult result); 1125b69db07SJason Zhu 1135b69db07SJason Zhu /* Maximum number of rollback index locations supported. */ 1145b69db07SJason Zhu #define AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS 32 1155b69db07SJason Zhu 1165b69db07SJason Zhu /* AvbPartitionData contains data loaded from partitions when using 1175b69db07SJason Zhu * avb_slot_verify(). The |partition_name| field contains the name of 1185b69db07SJason Zhu * the partition (without A/B suffix), |data| points to the loaded 11937a7bc39SJason Zhu * data which is |data_size| bytes long. If |preloaded| is set to true, 12037a7bc39SJason Zhu * this structure dose not own |data|. The caller of |avb_slot_verify| 12137a7bc39SJason Zhu * needs to make sure that the preloaded data outlives this 12237a7bc39SJason Zhu * |AvbPartitionData| structure. 1235b69db07SJason Zhu * 1245b69db07SJason Zhu * Note that this is strictly less than the partition size - it's only 1255b69db07SJason Zhu * the image stored there, not the entire partition nor any of the 1265b69db07SJason Zhu * metadata. 1275b69db07SJason Zhu */ 1285b69db07SJason Zhu typedef struct { 1295b69db07SJason Zhu char* partition_name; 1305b69db07SJason Zhu uint8_t* data; 1315b69db07SJason Zhu size_t data_size; 13237a7bc39SJason Zhu bool preloaded; 1335b69db07SJason Zhu } AvbPartitionData; 1345b69db07SJason Zhu 1355b69db07SJason Zhu /* AvbVBMetaData contains a vbmeta struct loaded from a partition when 1365b69db07SJason Zhu * using avb_slot_verify(). The |partition_name| field contains the 1375b69db07SJason Zhu * name of the partition (without A/B suffix), |vbmeta_data| points to 1385b69db07SJason Zhu * the loaded data which is |vbmeta_size| bytes long. 1395b69db07SJason Zhu * 1405b69db07SJason Zhu * The |verify_result| field contains the result of 1415b69db07SJason Zhu * avb_vbmeta_image_verify() on the data. This is guaranteed to be 1425b69db07SJason Zhu * AVB_VBMETA_VERIFY_RESULT_OK for all vbmeta images if 1435b69db07SJason Zhu * avb_slot_verify() returns AVB_SLOT_VERIFY_RESULT_OK. 1445b69db07SJason Zhu * 1455b69db07SJason Zhu * You can use avb_descriptor_get_all(), avb_descriptor_foreach(), and 1465b69db07SJason Zhu * avb_vbmeta_image_header_to_host_byte_order() with this data. 1475b69db07SJason Zhu */ 1485b69db07SJason Zhu typedef struct { 1495b69db07SJason Zhu char* partition_name; 1505b69db07SJason Zhu uint8_t* vbmeta_data; 1515b69db07SJason Zhu size_t vbmeta_size; 1525b69db07SJason Zhu AvbVBMetaVerifyResult verify_result; 1535b69db07SJason Zhu } AvbVBMetaData; 1545b69db07SJason Zhu 1555b69db07SJason Zhu /* AvbSlotVerifyData contains data needed to boot a particular slot 1565b69db07SJason Zhu * and is returned by avb_slot_verify() if partitions in a slot are 1575b69db07SJason Zhu * successfully verified. 1585b69db07SJason Zhu * 1595b69db07SJason Zhu * All data pointed to by this struct - including data in each item in 1605b69db07SJason Zhu * the |partitions| array - will be freed when the 1615b69db07SJason Zhu * avb_slot_verify_data_free() function is called. 1625b69db07SJason Zhu * 1635b69db07SJason Zhu * The |ab_suffix| field is the copy of the of |ab_suffix| field 1645b69db07SJason Zhu * passed to avb_slot_verify(). It is the A/B suffix of the slot. This 1655b69db07SJason Zhu * value includes the leading underscore - typical values are "" (if 1665b69db07SJason Zhu * no slots are in use), "_a" (for the first slot), and "_b" (for the 1675b69db07SJason Zhu * second slot). 1685b69db07SJason Zhu * 1695b69db07SJason Zhu * The VBMeta images that were checked are available in the 1705b69db07SJason Zhu * |vbmeta_images| field. The field |num_vbmeta_images| contains the 1715b69db07SJason Zhu * number of elements in this array. The first element - 1725b69db07SJason Zhu * vbmeta_images[0] - is guaranteed to be from the partition with the 1735b69db07SJason Zhu * top-level vbmeta struct. This is usually the "vbmeta" partition in 1745b69db07SJason Zhu * the requested slot but if there is no "vbmeta" partition it can 1755b69db07SJason Zhu * also be the "boot" partition. 1765b69db07SJason Zhu * 1775b69db07SJason Zhu * The partitions loaded and verified from from the slot are 1785b69db07SJason Zhu * accessible in the |loaded_partitions| array. The field 1795b69db07SJason Zhu * |num_loaded_partitions| contains the number of elements in this 1805b69db07SJason Zhu * array. The order of partitions in this array may not necessarily be 1815b69db07SJason Zhu * the same order as in the passed-in |requested_partitions| array. 1825b69db07SJason Zhu * 1835b69db07SJason Zhu * Rollback indexes for the verified slot are stored in the 1845b69db07SJason Zhu * |rollback_indexes| field. Note that avb_slot_verify() will NEVER 1855b69db07SJason Zhu * modify stored_rollback_index[n] locations e.g. it will never use 1865b69db07SJason Zhu * the write_rollback_index() AvbOps operation. Instead it is the job 1875b69db07SJason Zhu * of the caller of avb_slot_verify() to do this based on e.g. A/B 1885b69db07SJason Zhu * policy and other factors. See libavb_ab/avb_ab_flow.c for an 1895b69db07SJason Zhu * example of how to do this. 1905b69db07SJason Zhu * 1915b69db07SJason Zhu * The |cmdline| field is a NUL-terminated string in UTF-8 resulting 1925b69db07SJason Zhu * from concatenating all |AvbKernelCmdlineDescriptor| and then 1935b69db07SJason Zhu * performing proper substitution of the variables 1945b69db07SJason Zhu * $(ANDROID_SYSTEM_PARTUUID), $(ANDROID_BOOT_PARTUUID), and 1955b69db07SJason Zhu * $(ANDROID_VBMETA_PARTUUID) using the 1965b69db07SJason Zhu * get_unique_guid_for_partition() operation in |AvbOps|. Additionally 1975b69db07SJason Zhu * $(ANDROID_VERITY_MODE) will be replaced with the proper dm-verity 1985b69db07SJason Zhu * option depending on the value of |hashtree_error_mode|. 1995b69db07SJason Zhu * 2005b69db07SJason Zhu * Additionally, the |cmdline| field will have the following kernel 20137a7bc39SJason Zhu * command-line options set (unless verification is disabled, see 20237a7bc39SJason Zhu * below): 2035b69db07SJason Zhu * 2045b69db07SJason Zhu * androidboot.veritymode: This is set to 'disabled' if the 2055b69db07SJason Zhu * AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED flag is set in top-level 2065b69db07SJason Zhu * vbmeta struct. Otherwise it is set to 'enforcing' if the 2075b69db07SJason Zhu * passed-in hashtree error mode is AVB_HASHTREE_ERROR_MODE_RESTART 2085b69db07SJason Zhu * or AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE, 'eio' if it's 2095b69db07SJason Zhu * set to AVB_HASHTREE_ERROR_MODE_EIO, and 'logging' if it's set to 2105b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_LOGGING. 2115b69db07SJason Zhu * 2125b69db07SJason Zhu * androidboot.vbmeta.invalidate_on_error: This is set to 'yes' only 2135b69db07SJason Zhu * if hashtree validation isn't disabled and the passed-in hashtree 2145b69db07SJason Zhu * error mode is AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE. 2155b69db07SJason Zhu * 2165b69db07SJason Zhu * androidboot.vbmeta.device_state: set to "locked" or "unlocked" 2175b69db07SJason Zhu * depending on the result of the result of AvbOps's 2185b69db07SJason Zhu * read_is_unlocked() function. 2195b69db07SJason Zhu * 2205b69db07SJason Zhu * androidboot.vbmeta.{hash_alg, size, digest}: Will be set to 2215b69db07SJason Zhu * the digest of all images in |vbmeta_images|. 2225b69db07SJason Zhu * 2235b69db07SJason Zhu * androidboot.vbmeta.device: This is set to the value 2245b69db07SJason Zhu * PARTUUID=$(ANDROID_VBMETA_PARTUUID) before substitution so it 2255b69db07SJason Zhu * will end up pointing to the vbmeta partition for the verified 2265b69db07SJason Zhu * slot. If there is no vbmeta partition it will point to the boot 2275b69db07SJason Zhu * partition of the verified slot. 2285b69db07SJason Zhu * 2295b69db07SJason Zhu * androidboot.vbmeta.avb_version: This is set to the decimal value 2305b69db07SJason Zhu * of AVB_VERSION_MAJOR followed by a dot followed by the decimal 2315b69db07SJason Zhu * value of AVB_VERSION_MINOR, for example "1.0" or "1.4". This 2325b69db07SJason Zhu * version number represents the vbmeta file format version 2335b69db07SJason Zhu * supported by libavb copy used in the boot loader. This is not 2345b69db07SJason Zhu * necessarily the same version number of the on-disk metadata for 2355b69db07SJason Zhu * the slot that was verified. 2365b69db07SJason Zhu * 23737a7bc39SJason Zhu * Note that androidboot.slot_suffix is not set in the |cmdline| field 23837a7bc39SJason Zhu * in |AvbSlotVerifyData| - you will have to set this yourself. 2395b69db07SJason Zhu * 24037a7bc39SJason Zhu * If the |AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED| flag is set 24137a7bc39SJason Zhu * in the top-level vbmeta struct then only the top-level vbmeta 24237a7bc39SJason Zhu * struct is verified and descriptors will not processed. The return 24337a7bc39SJason Zhu * value will be set accordingly (if this flag is set via 'avbctl 24437a7bc39SJason Zhu * disable-verification' then the return value will be 24537a7bc39SJason Zhu * |AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION|) and 24637a7bc39SJason Zhu * |AvbSlotVerifyData| is returned. Additionally all partitions in the 24737a7bc39SJason Zhu * |requested_partitions| are loaded and the |cmdline| field is set to 24837a7bc39SJason Zhu * "root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)" and the GUID for the 24937a7bc39SJason Zhu * appropriate system partition is substituted in. Note that none of 25037a7bc39SJason Zhu * the androidboot.* options mentioned above will be set. 2515b69db07SJason Zhu * 2525b69db07SJason Zhu * This struct may grow in the future without it being considered an 2535b69db07SJason Zhu * ABI break. 2545b69db07SJason Zhu */ 2555b69db07SJason Zhu typedef struct { 2565b69db07SJason Zhu char* ab_suffix; 2575b69db07SJason Zhu AvbVBMetaData* vbmeta_images; 2585b69db07SJason Zhu size_t num_vbmeta_images; 2595b69db07SJason Zhu AvbPartitionData* loaded_partitions; 2605b69db07SJason Zhu size_t num_loaded_partitions; 2615b69db07SJason Zhu char* cmdline; 2625b69db07SJason Zhu uint64_t rollback_indexes[AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS]; 2635b69db07SJason Zhu } AvbSlotVerifyData; 2645b69db07SJason Zhu 265*ab608f80SJason Zhu /* Calculates a digest of all vbmeta images in |data| using 266*ab608f80SJason Zhu * the digest indicated by |digest_type|. Stores the result 267*ab608f80SJason Zhu * in |out_digest| which must be large enough to hold a digest 268*ab608f80SJason Zhu * of the requested type. 269*ab608f80SJason Zhu */ 270*ab608f80SJason Zhu void avb_slot_verify_data_calculate_vbmeta_digest(AvbSlotVerifyData* data, 271*ab608f80SJason Zhu AvbDigestType digest_type, 272*ab608f80SJason Zhu uint8_t* out_digest); 273*ab608f80SJason Zhu 2745b69db07SJason Zhu /* Frees a |AvbSlotVerifyData| including all data it points to. */ 2755b69db07SJason Zhu void avb_slot_verify_data_free(AvbSlotVerifyData* data); 2765b69db07SJason Zhu 2775b69db07SJason Zhu /* Performs a full verification of the slot identified by |ab_suffix| 2785b69db07SJason Zhu * and load and verify the contents of the partitions whose name is in 2795b69db07SJason Zhu * the NULL-terminated string array |requested_partitions| (each 2805b69db07SJason Zhu * partition must use hash verification). If not using A/B, pass an 2815b69db07SJason Zhu * empty string (e.g. "", not NULL) for |ab_suffix|. This parameter 2825b69db07SJason Zhu * must include the leading underscore, for example "_a" should be 2835b69db07SJason Zhu * used to refer to the first slot. 2845b69db07SJason Zhu * 2855b69db07SJason Zhu * Typically the |requested_partitions| array only contains a single 2865b69db07SJason Zhu * item for the boot partition, 'boot'. 2875b69db07SJason Zhu * 2885b69db07SJason Zhu * Verification includes loading and verifying data from the 'vbmeta', 2895b69db07SJason Zhu * the requested hash partitions, and possibly other partitions (with 2905b69db07SJason Zhu * |ab_suffix| appended), inspecting rollback indexes, and checking if 2915b69db07SJason Zhu * the public key used to sign the data is acceptable. The functions 2925b69db07SJason Zhu * in |ops| will be used to do this. 2935b69db07SJason Zhu * 2945b69db07SJason Zhu * If |out_data| is not NULL, it will be set to a newly allocated 2955b69db07SJason Zhu * |AvbSlotVerifyData| struct containing all the data needed to 2965b69db07SJason Zhu * actually boot the slot. This data structure should be freed with 2975b69db07SJason Zhu * avb_slot_verify_data_free() when you are done with it. See below 2985b69db07SJason Zhu * for when this is returned. 2995b69db07SJason Zhu * 3005b69db07SJason Zhu * The |flags| parameter is used to influence the semantics of 3015b69db07SJason Zhu * avb_slot_verify() - for example the 3025b69db07SJason Zhu * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR flag can be used to 3035b69db07SJason Zhu * ignore verification errors which is something needed in the 3045b69db07SJason Zhu * UNLOCKED state. See the AvbSlotVerifyFlags enumeration for details. 3055b69db07SJason Zhu * 3065b69db07SJason Zhu * The |hashtree_error_mode| parameter should be set to the desired 3075b69db07SJason Zhu * error handling mode when hashtree validation fails inside the 3085b69db07SJason Zhu * HLOS. This value isn't used by libavb per se - it is forwarded to 3095b69db07SJason Zhu * the HLOS through the androidboot.veritymode and 3105b69db07SJason Zhu * androidboot.vbmeta.invalidate_on_error cmdline parameters. See the 3115b69db07SJason Zhu * AvbHashtreeErrorMode enumeration for details. 3125b69db07SJason Zhu * 3135b69db07SJason Zhu * Also note that |out_data| is never set if 3145b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_OOM, AVB_SLOT_VERIFY_RESULT_ERROR_IO, 3155b69db07SJason Zhu * or AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA is returned. 3165b69db07SJason Zhu * 3175b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_OK is returned if everything is verified 3185b69db07SJason Zhu * correctly and all public keys are accepted. 3195b69db07SJason Zhu * 3205b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED is returned if 3215b69db07SJason Zhu * everything is verified correctly out but one or more public keys 3225b69db07SJason Zhu * are not accepted. This includes the case where integrity data is 3235b69db07SJason Zhu * not signed. 3245b69db07SJason Zhu * 3255b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_OOM is returned if unable to 3265b69db07SJason Zhu * allocate memory. 3275b69db07SJason Zhu * 3285b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_IO is returned if an I/O error 3295b69db07SJason Zhu * occurred while trying to load data or get a rollback index. 3305b69db07SJason Zhu * 3315b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION is returned if the data 3325b69db07SJason Zhu * did not verify, e.g. the digest didn't match or signature checks 3335b69db07SJason Zhu * failed. 3345b69db07SJason Zhu * 3355b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX is returned if a 3365b69db07SJason Zhu * rollback index was less than its stored value. 3375b69db07SJason Zhu * 3385b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA is returned if some 3395b69db07SJason Zhu * of the metadata is invalid or inconsistent. 3405b69db07SJason Zhu * 3415b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION is returned if 3425b69db07SJason Zhu * some of the metadata requires a newer version of libavb than what 3435b69db07SJason Zhu * is in use. 3445b69db07SJason Zhu * 3455b69db07SJason Zhu * AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT is returned if the 3465b69db07SJason Zhu * caller passed invalid parameters, for example trying to use 3475b69db07SJason Zhu * AVB_HASHTREE_ERROR_MODE_LOGGING without 3485b69db07SJason Zhu * AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR. 3495b69db07SJason Zhu */ 3505b69db07SJason Zhu AvbSlotVerifyResult avb_slot_verify(AvbOps* ops, 3515b69db07SJason Zhu const char* const* requested_partitions, 3525b69db07SJason Zhu const char* ab_suffix, 3535b69db07SJason Zhu AvbSlotVerifyFlags flags, 3545b69db07SJason Zhu AvbHashtreeErrorMode hashtree_error_mode, 3555b69db07SJason Zhu AvbSlotVerifyData** out_data); 3565b69db07SJason Zhu 3575b69db07SJason Zhu #ifdef __cplusplus 3585b69db07SJason Zhu } 3595b69db07SJason Zhu #endif 3605b69db07SJason Zhu 3615b69db07SJason Zhu #endif /* AVB_SLOT_VERIFY_H_ */ 362