|
| 1 | +/* |
| 2 | + * Copyright (C) 2018 Intel Corporation. All rights reserved. |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions |
| 6 | + * are met: |
| 7 | + * |
| 8 | + * * Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * * Redistributions in binary form must reproduce the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer in |
| 12 | + * the documentation and/or other materials provided with the |
| 13 | + * distribution. |
| 14 | + * * Neither the name of Intel Corporation nor the names of its |
| 15 | + * contributors may be used to endorse or promote products derived |
| 16 | + * from this software without specific prior written permission. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | + |
| 31 | +#ifndef TRUSTY_H_ |
| 32 | +#define TRUSTY_H_ |
| 33 | + |
| 34 | +#define BOOTLOADER_SEED_MAX_ENTRIES 10 |
| 35 | +#define RPMB_MAX_PARTITION_NUMBER 6 |
| 36 | +#define MMC_PROD_NAME_WITH_PSN_LEN 15 |
| 37 | +#define BUP_MKHI_BOOTLOADER_SEED_LEN 64 |
| 38 | + |
| 39 | +/* Structure of seed info */ |
| 40 | +struct seed_info { |
| 41 | + uint8_t cse_svn; |
| 42 | + uint8_t bios_svn; |
| 43 | + uint8_t padding[2]; |
| 44 | + uint8_t seed[BUP_MKHI_BOOTLOADER_SEED_LEN]; |
| 45 | +}; |
| 46 | + |
| 47 | +/* Structure of key info */ |
| 48 | +struct key_info { |
| 49 | + uint32_t size_of_this_struct; |
| 50 | + |
| 51 | + /* version info: |
| 52 | + 0: baseline structure |
| 53 | + 1: add ** new field |
| 54 | + */ |
| 55 | + uint32_t version; |
| 56 | + |
| 57 | + /* platform: |
| 58 | + 0: Dummy (fake secret) |
| 59 | + 1: APL (APL + ABL) |
| 60 | + 2: ICL (ICL + SBL) |
| 61 | + 3: CWP (APL|ICL + SBL + CWP) |
| 62 | + 4: Brillo (Android Things) |
| 63 | + */ |
| 64 | + uint32_t platform; |
| 65 | + |
| 66 | + /* flags info: |
| 67 | + Bit 0: manufacturing state (0:manufacturing done; |
| 68 | + 1:in manufacturing mode) |
| 69 | + Bit 1: secure boot state (0:disabled; 1: enabled) |
| 70 | + Bit 2: test seeds (ICL only - 0:production seeds; 1: test seeds) |
| 71 | + other bits all reserved as 0 |
| 72 | + */ |
| 73 | + uint32_t flags; |
| 74 | + |
| 75 | + /* Keep 64-bit align */ |
| 76 | + uint32_t pad1; |
| 77 | + |
| 78 | + /* Seed list, include useeds(user seeds) and dseed(device seeds) */ |
| 79 | + uint32_t num_seeds; |
| 80 | + struct seed_info useed_list[BOOTLOADER_SEED_MAX_ENTRIES]; |
| 81 | + struct seed_info dseed_list[BOOTLOADER_SEED_MAX_ENTRIES]; |
| 82 | + |
| 83 | + /* For ICL+ */ |
| 84 | + /* rpmb keys, Currently HMAC-SHA256 is used in RPMB spec |
| 85 | + * and 256-bit (32byte) is enough. Hence only lower 32 bytes will be |
| 86 | + * used for now for each entry. But keep higher 32 bytes for future |
| 87 | + * extension. Note that, RPMB keys are already tied to storage device |
| 88 | + * serial number.If there are multiple RPMB partitions, then we will |
| 89 | + * get multiple available RPMB keys. And if rpmb_key[n][64] == 0, |
| 90 | + * then the n-th RPMB key is unavailable (Either because of no such |
| 91 | + * RPMB partition, or because OSloader doesn't want to share |
| 92 | + * the n-th RPMB key with Trusty) |
| 93 | + */ |
| 94 | + uint8_t rpmb_key[RPMB_MAX_PARTITION_NUMBER][64]; |
| 95 | + |
| 96 | + /* 256-bit AES encryption key to encrypt/decrypt attestation keybox, |
| 97 | + this key should be derived from a fixed key which is RPMB seed. |
| 98 | + RPMB key (HMAC key) and this encryption key (AES key) are both |
| 99 | + derived from the same RPMB seed. |
| 100 | + */ |
| 101 | + uint8_t attkb_enc_key[32]; |
| 102 | + |
| 103 | + /* For APL only */ |
| 104 | + /* RPMB key is derived with dseed together with this serial number, |
| 105 | + * for ICL +, CSE directly provides the rpmb_key which is already |
| 106 | + * tied to serial number. Concatenation of emmc product name |
| 107 | + * with a string representation of PSN |
| 108 | + */ |
| 109 | + char serial[MMC_PROD_NAME_WITH_PSN_LEN]; |
| 110 | + char pad2; |
| 111 | +}; |
| 112 | + |
| 113 | +struct secure_world_memory { |
| 114 | + /* The secure world base address of GPA in SOS */ |
| 115 | + uint64_t base_gpa; |
| 116 | + /* The secure world base address of HPA */ |
| 117 | + uint64_t base_hpa; |
| 118 | + /* Secure world runtime memory size */ |
| 119 | + uint64_t length; |
| 120 | +}; |
| 121 | + |
| 122 | +struct secure_world_control { |
| 123 | + /* Whether secure world is enabled for current VM */ |
| 124 | + bool sworld_enabled; |
| 125 | + /* key info structure */ |
| 126 | + struct key_info key_info; |
| 127 | + /* Secure world memory structure */ |
| 128 | + struct secure_world_memory sworld_memory; |
| 129 | +}; |
| 130 | + |
| 131 | +#endif /* TRUSTY_H_ */ |
| 132 | + |
0 commit comments