Open Enclave
properties.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License.
3 
14 #ifndef _OE_BITS_PROPERTIES_H
15 #define _OE_BITS_PROPERTIES_H
16 
17 #include "defs.h"
18 #include "result.h"
19 #include "types.h"
20 
21 OE_EXTERNC_BEGIN
22 
26 /* Injected by OE_SET_ENCLAVE_SGX macro and by the signing tool (oesign) */
27 #define OE_INFO_SECTION_NAME ".oeinfo"
28 
29 /* Max number of threads in an enclave supported */
30 #define OE_SGX_MAX_TCS 32
31 
32 typedef struct _oe_enclave_size_settings
33 {
34  uint64_t num_heap_pages;
35  uint64_t num_stack_pages;
36  uint64_t num_tcs;
37 } oe_enclave_size_settings_t;
38 
39 /* Base type for enclave properties */
40 typedef struct _oe_enclave_properties_header
41 {
42  uint32_t size;
44  oe_enclave_type_t enclave_type;
46  oe_enclave_size_settings_t size_settings;
47 } oe_enclave_properties_header_t;
48 
49 // oe_sgx_enclave_properties_t SGX enclave properties derived type
50 #define OE_SGX_FLAGS_DEBUG 0x0000000000000002ULL
51 #define OE_SGX_FLAGS_MODE64BIT 0x0000000000000004ULL
52 #define OE_SGX_SIGSTRUCT_SIZE 1808
53 
54 typedef struct oe_sgx_enclave_config_t
55 {
56  uint16_t product_id;
57  uint16_t security_version;
58 
59  /* Padding to make packed and unpacked size the same */
60  uint32_t padding;
61 
62  /* (OE_SGX_FLAGS_DEBUG | OE_SGX_FLAGS_MODE64BIT) */
63  uint64_t attributes;
64 } oe_sgx_enclave_config_t;
65 
66 /* Extends oe_enclave_properties_header_t base type */
67 typedef struct oe_sgx_enclave_properties_t
68 {
69  /* (0) */
70  oe_enclave_properties_header_t header;
71 
72  /* (32) */
73  oe_sgx_enclave_config_t config;
74 
75  /* (48) */
76  uint8_t sigstruct[OE_SGX_SIGSTRUCT_SIZE];
77 } oe_sgx_enclave_properties_t;
78 
79 #define OE_INFO_SECTION_BEGIN __attribute__((section(".oeinfo")))
80 #define OE_INFO_SECTION_END
81 
82 #define OE_MAKE_ATTRIBUTES(ALLOW_DEBUG) \
83  (OE_SGX_FLAGS_MODE64BIT | (ALLOW_DEBUG ? OE_SGX_FLAGS_DEBUG : 0))
84 
89 // This macro initializes and injects an oe_sgx_enclave_properties_t struct
90 // into the .oeinfo section.
91 
110 // Note: disable clang-format since it badly misformats this macro
111 // clang-format off
112 
113 #define OE_SET_ENCLAVE_SGX( \
114  PRODUCT_ID, \
115  SECURITY_VERSION, \
116  ALLOW_DEBUG, \
117  HEAP_PAGE_COUNT, \
118  STACK_PAGE_COUNT, \
119  TCS_COUNT) \
120  OE_INFO_SECTION_BEGIN \
121  OE_EXPORT_CONST oe_sgx_enclave_properties_t oe_enclave_properties_sgx = \
122  { \
123  .header = \
124  { \
125  .size = sizeof(oe_sgx_enclave_properties_t), \
126  .enclave_type = OE_ENCLAVE_TYPE_SGX, \
127  .size_settings = \
128  { \
129  .num_heap_pages = HEAP_PAGE_COUNT, \
130  .num_stack_pages = STACK_PAGE_COUNT, \
131  .num_tcs = TCS_COUNT \
132  } \
133  }, \
134  .config = \
135  { \
136  .product_id = PRODUCT_ID, \
137  .security_version = SECURITY_VERSION, \
138  .padding = 0, \
139  .attributes = OE_MAKE_ATTRIBUTES(ALLOW_DEBUG) \
140  }, \
141  .sigstruct = \
142  { \
143  0 \
144  } \
145  }; \
146  OE_INFO_SECTION_END
147 
148 // clang-format on
149 
159  uint32_t year,
160  uint32_t month,
161  uint32_t day,
162  uint32_t hours,
163  uint32_t minutes,
164  uint32_t seconds);
165 
166 OE_EXTERNC_END
167 
168 #endif /* _OE_BITS_PROPERTIES_H */
This file defines Open Enclave return codes (results).
enum _oe_result oe_result_t
This enumeration type defines return codes for Open Enclave functions.
oe_result_t __oe_sgx_set_minimum_crl_tcb_issue_date(uint32_t year, uint32_t month, uint32_t day, uint32_t hours, uint32_t minutes, uint32_t seconds)
This function sets the minimum value of issue dates of CRL and TCB info accepted by the enclave...