Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 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 | |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 42 | /* Size in bytes of a serialized public key with a 4096-bit modulus. */ |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 43 | #define AVB_ATX_PUBLIC_KEY_SIZE (sizeof(AvbRSAPublicKeyHeader) + 1024) |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 44 | |
| 45 | /* Data structure of Android Things permanent attributes. */ |
| 46 | typedef struct AvbAtxPermanentAttributes { |
| 47 | uint32_t version; |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 48 | uint8_t product_root_public_key[AVB_ATX_PUBLIC_KEY_SIZE]; |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 49 | uint8_t product_id[AVB_ATX_PRODUCT_ID_SIZE]; |
| 50 | } AVB_ATTR_PACKED AvbAtxPermanentAttributes; |
| 51 | |
| 52 | /* Data structure of signed fields in an Android Things certificate. */ |
| 53 | typedef struct AvbAtxCertificateSignedData { |
| 54 | uint32_t version; |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 55 | uint8_t public_key[AVB_ATX_PUBLIC_KEY_SIZE]; |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 56 | uint8_t subject[AVB_SHA256_DIGEST_SIZE]; |
| 57 | uint8_t usage[AVB_SHA256_DIGEST_SIZE]; |
| 58 | uint64_t key_version; |
| 59 | } AVB_ATTR_PACKED AvbAtxCertificateSignedData; |
| 60 | |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 61 | /* Data structure of an Android Things certificate. */ |
| 62 | typedef struct AvbAtxCertificate { |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 63 | AvbAtxCertificateSignedData signed_data; |
| 64 | uint8_t signature[AVB_RSA4096_NUM_BYTES]; |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 65 | } AVB_ATTR_PACKED AvbAtxCertificate; |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 66 | |
| 67 | /* Data structure of Android Things public key metadata in vbmeta. */ |
| 68 | typedef struct AvbAtxPublicKeyMetadata { |
| 69 | uint32_t version; |
Darren Krahn | 43e12d8 | 2017-02-24 16:26:31 -0800 | [diff] [blame] | 70 | AvbAtxCertificate product_intermediate_key_certificate; |
| 71 | AvbAtxCertificate product_signing_key_certificate; |
Darren Krahn | 147b08d | 2016-12-20 16:38:29 -0800 | [diff] [blame] | 72 | } AVB_ATTR_PACKED AvbAtxPublicKeyMetadata; |
| 73 | |
| 74 | #ifdef __cplusplus |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | #endif /* AVB_ATX_TYPES_H_ */ |