1*3ccd4bb0SJason Zhu /* 2*3ccd4bb0SJason Zhu * Copyright (C) 2016 The Android Open Source Project 3*3ccd4bb0SJason Zhu * 4*3ccd4bb0SJason Zhu * Permission is hereby granted, free of charge, to any person 5*3ccd4bb0SJason Zhu * obtaining a copy of this software and associated documentation 6*3ccd4bb0SJason Zhu * files (the "Software"), to deal in the Software without 7*3ccd4bb0SJason Zhu * restriction, including without limitation the rights to use, copy, 8*3ccd4bb0SJason Zhu * modify, merge, publish, distribute, sublicense, and/or sell copies 9*3ccd4bb0SJason Zhu * of the Software, and to permit persons to whom the Software is 10*3ccd4bb0SJason Zhu * furnished to do so, subject to the following conditions: 11*3ccd4bb0SJason Zhu * 12*3ccd4bb0SJason Zhu * The above copyright notice and this permission notice shall be 13*3ccd4bb0SJason Zhu * included in all copies or substantial portions of the Software. 14*3ccd4bb0SJason Zhu * 15*3ccd4bb0SJason Zhu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16*3ccd4bb0SJason Zhu * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17*3ccd4bb0SJason Zhu * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18*3ccd4bb0SJason Zhu * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19*3ccd4bb0SJason Zhu * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20*3ccd4bb0SJason Zhu * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21*3ccd4bb0SJason Zhu * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22*3ccd4bb0SJason Zhu * SOFTWARE. 23*3ccd4bb0SJason Zhu */ 24*3ccd4bb0SJason Zhu 25*3ccd4bb0SJason Zhu /* 26*3ccd4bb0SJason Zhu #if !defined(AVB_INSIDE_LIBAVB_ATX_H) && !defined(AVB_COMPILATION) 27*3ccd4bb0SJason Zhu #error \ 28*3ccd4bb0SJason Zhu "Never include this file directly, include libavb_atx/libavb_atx.h instead." 29*3ccd4bb0SJason Zhu #endif 30*3ccd4bb0SJason Zhu */ 31*3ccd4bb0SJason Zhu 32*3ccd4bb0SJason Zhu #ifndef AVB_ATX_VALIDATE_H_ 33*3ccd4bb0SJason Zhu #define AVB_ATX_VALIDATE_H_ 34*3ccd4bb0SJason Zhu 35*3ccd4bb0SJason Zhu #include <android_avb/avb_atx_ops.h> 36*3ccd4bb0SJason Zhu #include <android_avb/avb_atx_types.h> 37*3ccd4bb0SJason Zhu 38*3ccd4bb0SJason Zhu #ifdef __cplusplus 39*3ccd4bb0SJason Zhu extern "C" { 40*3ccd4bb0SJason Zhu #endif 41*3ccd4bb0SJason Zhu 42*3ccd4bb0SJason Zhu /* Rollback index locations for Android Things key versions. */ 43*3ccd4bb0SJason Zhu #define AVB_ATX_PIK_VERSION_LOCATION 0x1000 44*3ccd4bb0SJason Zhu #define AVB_ATX_PSK_VERSION_LOCATION 0x1001 45*3ccd4bb0SJason Zhu 46*3ccd4bb0SJason Zhu /* An implementation of validate_vbmeta_public_key for Android Things. See 47*3ccd4bb0SJason Zhu * libavb/avb_ops.h for details on validate_vbmeta_public_key in general. This 48*3ccd4bb0SJason Zhu * implementation uses the metadata expected with Android Things vbmeta images 49*3ccd4bb0SJason Zhu * to perform validation on the public key. The ATX ops must be implemented. 50*3ccd4bb0SJason Zhu * That is, |ops->atx_ops| must be valid. 51*3ccd4bb0SJason Zhu * 52*3ccd4bb0SJason Zhu * There are a multiple values that need verification: 53*3ccd4bb0SJason Zhu * - Permanent Product Attributes: A hash of these attributes is fused into 54*3ccd4bb0SJason Zhu * hardware. Consistency is checked. 55*3ccd4bb0SJason Zhu * - Product Root Key (PRK): This key is provided in permanent attributes and 56*3ccd4bb0SJason Zhu * is the root authority for all Android Things 57*3ccd4bb0SJason Zhu * products. 58*3ccd4bb0SJason Zhu * - Product Intermediate Key (PIK): This key is a rotated intermediary. It is 59*3ccd4bb0SJason Zhu * certified by the PRK. 60*3ccd4bb0SJason Zhu * - Product Signing Key (PSK): This key is a rotated authority for a specific 61*3ccd4bb0SJason Zhu * Android Things product. It is certified by a 62*3ccd4bb0SJason Zhu * PIK and must match |public_key_data|. 63*3ccd4bb0SJason Zhu * - Product ID: This value is provided in permanent attributes and is unique 64*3ccd4bb0SJason Zhu * to a specific Android Things product. This value must match 65*3ccd4bb0SJason Zhu * the subject of the PSK certificate. 66*3ccd4bb0SJason Zhu */ 67*3ccd4bb0SJason Zhu AvbIOResult avb_atx_validate_vbmeta_public_key( 68*3ccd4bb0SJason Zhu AvbOps* ops, 69*3ccd4bb0SJason Zhu const uint8_t* public_key_data, 70*3ccd4bb0SJason Zhu size_t public_key_length, 71*3ccd4bb0SJason Zhu const uint8_t* public_key_metadata, 72*3ccd4bb0SJason Zhu size_t public_key_metadata_length, 73*3ccd4bb0SJason Zhu bool* out_is_trusted); 74*3ccd4bb0SJason Zhu 75*3ccd4bb0SJason Zhu #ifdef __cplusplus 76*3ccd4bb0SJason Zhu } 77*3ccd4bb0SJason Zhu #endif 78*3ccd4bb0SJason Zhu 79*3ccd4bb0SJason Zhu #endif /* AVB_ATX_VALIDATE_H_ */ 80