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 #if !defined(AVB_INSIDE_LIBAVB_ATX_H) && !defined(AVB_COMPILATION) 26 #error \ 27 "Never include this file directly, include libavb_atx/libavb_atx.h instead." 28 #endif 29 30 #ifndef AVB_ATX_VALIDATE_H_ 31 #define AVB_ATX_VALIDATE_H_ 32 33 #include "libavb_atx/avb_atx_ops.h" 34 #include "libavb_atx/avb_atx_types.h" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* Rollback index locations for Android Things key versions. */ 41 #define AVB_ATX_PIK_VERSION_LOCATION 0x1000 42 #define AVB_ATX_PSK_VERSION_LOCATION 0x1001 43 44 /* An implementation of validate_vbmeta_public_key for Android Things. See 45 * libavb/avb_ops.h for details on validate_vbmeta_public_key in general. This 46 * implementation uses the metadata expected with Android Things vbmeta images 47 * to perform validation on the public key. The ATX ops must be implemented. 48 * That is, |ops->atx_ops| must be valid. 49 * 50 * There are a multiple values that need verification: 51 * - Permanent Product Attributes: A hash of these attributes is fused into 52 * hardware. Consistency is checked. 53 * - Product Root Key (PRK): This key is provided in permanent attributes and 54 * is the root authority for all Android Things 55 * products. 56 * - Product Intermediate Key (PIK): This key is a rotated intermediary. It is 57 * certified by the PRK. 58 * - Product Signing Key (PSK): This key is a rotated authority for a specific 59 * Android Things product. It is certified by a 60 * PIK and must match |public_key_data|. 61 * - Product ID: This value is provided in permanent attributes and is unique 62 * to a specific Android Things product. This value must match 63 * the subject of the PSK certificate. 64 */ 65 AvbIOResult avb_atx_validate_vbmeta_public_key( 66 AvbOps* ops, 67 const uint8_t* public_key_data, 68 size_t public_key_length, 69 const uint8_t* public_key_metadata, 70 size_t public_key_metadata_length, 71 bool* out_is_trusted); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif /* AVB_ATX_VALIDATE_H_ */ 78