1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 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: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 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. 23 */ 24 25 /* 26 #if !defined(AVB_INSIDE_LIBAVB_ATX_H) && !defined(AVB_COMPILATION) 27 #error \ 28 "Never include this file directly, include libavb_atx/libavb_atx.h instead." 29 #endif 30 */ 31 32 #ifndef AVB_ATX_OPS_H_ 33 #define AVB_ATX_OPS_H_ 34 35 #include <android_avb/libavb.h> 36 37 #include <android_avb/avb_atx_types.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 struct AvbAtxOps; 44 typedef struct AvbAtxOps AvbAtxOps; 45 46 /* An extension to AvbOps required by avb_atx_validate_vbmeta_public_key(). */ 47 struct AvbAtxOps { 48 /* Operations from libavb. */ 49 AvbOps* ops; 50 51 /* Reads permanent |attributes| data. There are no restrictions on where this 52 * data is stored. On success, returns AVB_IO_RESULT_OK and populates 53 * |attributes|. 54 */ 55 AvbIOResult (*read_permanent_attributes)( 56 AvbAtxOps* atx_ops, AvbAtxPermanentAttributes* attributes); 57 58 /* Reads a |hash| of permanent attributes. This hash MUST be retrieved from a 59 * permanently read-only location (e.g. fuses) when a device is LOCKED. On 60 * success, returned AVB_IO_RESULT_OK and populates |hash|. 61 */ 62 AvbIOResult (*read_permanent_attributes_hash)( 63 AvbAtxOps* atx_ops, uint8_t hash[AVB_SHA256_DIGEST_SIZE]); 64 65 /* Provides the key version of a key used during verification. This may be 66 * useful for managing the minimum key version. 67 */ 68 void (*set_key_version)(AvbAtxOps* atx_ops, 69 size_t rollback_index_location, 70 uint64_t key_version); 71 72 /* Generates |num_bytes| random bytes and stores them in |output|, 73 * which must point to a buffer large enough to store the bytes. 74 * 75 * Returns AVB_IO_RESULT_OK on success, otherwise an error code. 76 */ 77 AvbIOResult (*get_random)(AvbAtxOps* atx_ops, 78 size_t num_bytes, 79 uint8_t* output); 80 }; 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif /* AVB_ATX_OPS_H_ */ 87