blob: 6d698592ad0e3d60758e36a30e56bd7842f7d9d0 [file] [log] [blame]
Darren Krahn147b08d2016-12-20 16:38:29 -08001/*
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
36extern "C" {
37#endif
38
39/* Size in bytes of an Android Things product ID. */
40#define AVB_ATX_PRODUCT_ID_SIZE 16
41
Darren Krahn147b08d2016-12-20 16:38:29 -080042/* Size in bytes of a serialized public key with a 4096-bit modulus. */
Darren Krahn43e12d82017-02-24 16:26:31 -080043#define AVB_ATX_PUBLIC_KEY_SIZE (sizeof(AvbRSAPublicKeyHeader) + 1024)
Darren Krahn147b08d2016-12-20 16:38:29 -080044
45/* Data structure of Android Things permanent attributes. */
46typedef struct AvbAtxPermanentAttributes {
47 uint32_t version;
Darren Krahn43e12d82017-02-24 16:26:31 -080048 uint8_t product_root_public_key[AVB_ATX_PUBLIC_KEY_SIZE];
Darren Krahn147b08d2016-12-20 16:38:29 -080049 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. */
53typedef struct AvbAtxCertificateSignedData {
54 uint32_t version;
Darren Krahn43e12d82017-02-24 16:26:31 -080055 uint8_t public_key[AVB_ATX_PUBLIC_KEY_SIZE];
Darren Krahn147b08d2016-12-20 16:38:29 -080056 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 Krahn43e12d82017-02-24 16:26:31 -080061/* Data structure of an Android Things certificate. */
62typedef struct AvbAtxCertificate {
Darren Krahn147b08d2016-12-20 16:38:29 -080063 AvbAtxCertificateSignedData signed_data;
64 uint8_t signature[AVB_RSA4096_NUM_BYTES];
Darren Krahn43e12d82017-02-24 16:26:31 -080065} AVB_ATTR_PACKED AvbAtxCertificate;
Darren Krahn147b08d2016-12-20 16:38:29 -080066
67/* Data structure of Android Things public key metadata in vbmeta. */
68typedef struct AvbAtxPublicKeyMetadata {
69 uint32_t version;
Darren Krahn43e12d82017-02-24 16:26:31 -080070 AvbAtxCertificate product_intermediate_key_certificate;
71 AvbAtxCertificate product_signing_key_certificate;
Darren Krahn147b08d2016-12-20 16:38:29 -080072} AVB_ATTR_PACKED AvbAtxPublicKeyMetadata;
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* AVB_ATX_TYPES_H_ */