1 /* 2 * Copyright (c) 2019-2022 Intel Corporation. 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 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 26 * OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef _ATT_KEYBOX_H 30 #define _ATT_KEYBOX_H 31 32 typedef struct _HECI_MESSAGE_HEADER { 33 uint32_t groupid : 8; 34 uint32_t command : 7; 35 uint32_t is_response : 1; 36 uint32_t reserved : 8; 37 uint32_t result : 8; 38 } HECI_MESSAGE_HEADER; 39 40 typedef struct 41 { 42 HECI_MESSAGE_HEADER header; 43 /* Size of the whole attkb file, including the added encryption header. */ 44 uint16_t total_file_size; 45 uint16_t read_offset; 46 /* Size in bytes actually read */ 47 uint16_t read_size; 48 uint16_t reserved; 49 uint8_t file_data[]; 50 } HECI_READ_ATTKB_EX_Response; 51 52 typedef struct 53 { 54 HECI_MESSAGE_HEADER header; 55 uint16_t offset; // Offset in file in bytes. 56 uint16_t size; // Size in bytes to read 57 struct 58 { 59 uint32_t encryption : 1; 60 uint32_t reserved : 31; 61 } flags; 62 } HECI_READ_ATTKB_EX_Request; 63 64 #pragma pack (1) 65 typedef struct rpmb_block { 66 uint8_t signature[4]; 67 uint32_t length; 68 uint32_t revision; 69 uint32_t flag; 70 uint16_t attkb_addr; 71 uint32_t attkb_size; 72 uint16_t attkb_svn; 73 uint16_t user_vm_rpmb_size; 74 uint8_t reserved[230]; 75 } rpmb_block_t; 76 #pragma pack () 77 78 uint16_t read_attkb(void *data, uint16_t size); 79 uint16_t get_attkb_size(void); 80 81 #endif // _ATT_KEYBOX_H 82