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_TYPES_H_ 33 #define AVB_ATX_TYPES_H_ 34 35 #include <android_avb/libavb.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* Size in bytes of an Android Things product ID. */ 42 #define AVB_ATX_PRODUCT_ID_SIZE 16 43 44 /* Size in bytes of an Android Things unlock challenge. */ 45 #define AVB_ATX_UNLOCK_CHALLENGE_SIZE 16 46 47 /* Size in bytes of a serialized public key with a 4096-bit modulus. */ 48 #define AVB_ATX_PUBLIC_KEY_SIZE (sizeof(AvbRSAPublicKeyHeader) + 1024) 49 50 /* Data structure of Android Things permanent attributes. */ 51 typedef struct AvbAtxPermanentAttributes { 52 uint32_t version; 53 uint8_t product_root_public_key[AVB_ATX_PUBLIC_KEY_SIZE]; 54 uint8_t product_id[AVB_ATX_PRODUCT_ID_SIZE]; 55 } AVB_ATTR_PACKED AvbAtxPermanentAttributes; 56 57 /* Data structure of signed fields in an Android Things certificate. */ 58 typedef struct AvbAtxCertificateSignedData { 59 uint32_t version; 60 uint8_t public_key[AVB_ATX_PUBLIC_KEY_SIZE]; 61 uint8_t subject[AVB_SHA256_DIGEST_SIZE]; 62 uint8_t usage[AVB_SHA256_DIGEST_SIZE]; 63 uint64_t key_version; 64 } AVB_ATTR_PACKED AvbAtxCertificateSignedData; 65 66 /* Data structure of an Android Things certificate. */ 67 typedef struct AvbAtxCertificate { 68 AvbAtxCertificateSignedData signed_data; 69 uint8_t signature[AVB_RSA4096_NUM_BYTES]; 70 } AVB_ATTR_PACKED AvbAtxCertificate; 71 72 /* Data structure of Android Things public key metadata in vbmeta. */ 73 typedef struct AvbAtxPublicKeyMetadata { 74 uint32_t version; 75 AvbAtxCertificate product_intermediate_key_certificate; 76 AvbAtxCertificate product_signing_key_certificate; 77 } AVB_ATTR_PACKED AvbAtxPublicKeyMetadata; 78 79 /* Data structure of an Android Things unlock challenge. */ 80 typedef struct AvbAtxUnlockChallenge { 81 uint32_t version; 82 uint8_t product_id_hash[AVB_SHA256_DIGEST_SIZE]; 83 uint8_t challenge[AVB_ATX_UNLOCK_CHALLENGE_SIZE]; 84 } AVB_ATTR_PACKED AvbAtxUnlockChallenge; 85 86 /* Data structure of an Android Things unlock credential. */ 87 typedef struct AvbAtxUnlockCredential { 88 uint32_t version; 89 AvbAtxCertificate product_intermediate_key_certificate; 90 AvbAtxCertificate product_unlock_key_certificate; 91 uint8_t challenge_signature[AVB_RSA4096_NUM_BYTES]; 92 } AVB_ATTR_PACKED AvbAtxUnlockCredential; 93 94 #ifdef __cplusplus 95 } 96 #endif 97 98 #endif /* AVB_ATX_TYPES_H_ */ 99