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