Open Enclave  0.7.x
host.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License.
3 
10 #ifndef _OE_HOST_H
11 #define _OE_HOST_H
12 
13 #ifdef _OE_ENCLAVE_H
14 #error "enclave.h and host.h must not be included in the same compilation unit."
15 #endif
16 
17 #include <stdarg.h>
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include "bits/defs.h"
24 #include "bits/report.h"
25 #include "bits/result.h"
26 #include "bits/types.h"
27 #include "host_verify.h"
28 
29 OE_EXTERNC_BEGIN
30 
41 #define OE_ENCLAVE_FLAG_DEBUG 0x00000001u
42 
46 #define OE_ENCLAVE_FLAG_SIMULATE 0x00000002u
47 
51 #define OE_ENCLAVE_FLAG_RESERVED \
52  (~(OE_ENCLAVE_FLAG_DEBUG | OE_ENCLAVE_FLAG_SIMULATE))
53 
61 typedef void (*oe_ocall_func_t)(
62  const uint8_t* input_buffer,
63  size_t input_buffer_size,
64  uint8_t* output_buffer,
65  size_t output_buffer_size,
66  size_t* output_bytes_written);
67 
72 #ifdef OE_CONTEXT_SWITCHLESS_EXPERIMENTAL_FEATURE
73 
77 typedef enum _oe_enclave_config_type
78 {
79  OE_ENCLAVE_CONFIG_CONTEXT_SWITCHLESS = 0xdc73a628,
80 } oe_enclave_config_type_t;
81 
85 typedef struct _oe_enclave_config_context_switchless
86 {
92  size_t max_host_workers;
97  size_t max_enclave_workers;
98 } oe_enclave_config_context_switchless_t;
99 
104 typedef struct _oe_enclave_config
105 {
109  oe_enclave_config_type_t config_type;
114  union {
115  const oe_enclave_config_context_switchless_t* context_switchless_config;
116  /* Add new configuration types here. */
117  } u;
118 } oe_enclave_config_t;
119 
120 #endif /* OE_CONTEXT_SWITCHLESS_EXPERIMENTAL_FEATURE */
121 
157  const char* path,
158  oe_enclave_type_t type,
159  uint32_t flags,
160 #ifdef OE_CONTEXT_SWITCHLESS_EXPERIMENTAL_FEATURE
161  const oe_enclave_config_t* configs,
162  uint32_t config_count,
163 #else
164  const void* config,
165  uint32_t config_size,
166 #endif
167  const oe_ocall_func_t* ocall_table,
168  uint32_t ocall_count,
169  oe_enclave_t** enclave);
170 
184 
185 #if (OE_API_VERSION < 2)
186 #error "Only OE_API_VERSION of 2 is supported"
187 #else
188 #define oe_get_report oe_get_report_v2
189 #endif
190 
213  oe_enclave_t* enclave,
214  uint32_t flags,
215  const void* opt_params,
216  size_t opt_params_size,
217  uint8_t** report_buffer,
218  size_t* report_buffer_size);
219 
225 void oe_free_report(uint8_t* report_buffer);
226 
227 #if (OE_API_VERSION < 2)
228 #error "Only OE_API_VERSION of 2 is supported"
229 #else
230 #define oe_get_target_info oe_get_target_info_v2
231 #endif
232 
254  const uint8_t* report,
255  size_t report_size,
256  void** target_info_buffer,
257  size_t* target_info_size);
258 
264 void oe_free_target_info(void* target_info_buffer);
265 
281  const uint8_t* report,
282  size_t report_size,
283  oe_report_t* parsed_report);
284 
305  oe_enclave_t* enclave,
306  const uint8_t* report,
307  size_t report_size,
308  oe_report_t* parsed_report);
309 
332  oe_enclave_t* enclave,
333  oe_seal_policy_t seal_policy,
334  const oe_asymmetric_key_params_t* key_params,
335  uint8_t** key_buffer,
336  size_t* key_buffer_size,
337  uint8_t** key_info,
338  size_t* key_info_size);
339 
358  oe_enclave_t* enclave,
359  const oe_asymmetric_key_params_t* key_params,
360  const uint8_t* key_info,
361  size_t key_info_size,
362  uint8_t** key_buffer,
363  size_t* key_buffer_size);
364 
374 void oe_free_key(
375  uint8_t* key_buffer,
376  size_t key_buffer_size,
377  uint8_t* key_info,
378  size_t key_info_size);
379 
380 OE_EXTERNC_END
381 
382 #endif /* _OE_HOST_H */
oe_result_t oe_get_public_key_by_policy(oe_enclave_t *enclave, oe_seal_policy_t seal_policy, const oe_asymmetric_key_params_t *key_params, uint8_t **key_buffer, size_t *key_buffer_size, uint8_t **key_info, size_t *key_info_size)
Returns a public key that is associated with the identity of the enclave and the specified policy...
enum _oe_seal_policy oe_seal_policy_t
This enumeration type defines the policy used to derive a seal key.
oe_result_t oe_get_public_key(oe_enclave_t *enclave, const oe_asymmetric_key_params_t *key_params, const uint8_t *key_info, size_t key_info_size, uint8_t **key_buffer, size_t *key_buffer_size)
Returns a public key that is associated with the identity of the enclave.
This file defines the types used by the OE SDK.
Structure to hold the parsed form of a report.
Definition: report.h:112
enum _oe_enclave_type oe_enclave_type_t
This enumeration defines values for the type parameter passed to oe_create_enclave().
oe_result_t oe_get_report_v2(oe_enclave_t *enclave, uint32_t flags, const void *opt_params, size_t opt_params_size, uint8_t **report_buffer, size_t *report_buffer_size)
Get a report signed by the enclave platform for use in attestation.
oe_result_t oe_get_target_info_v2(const uint8_t *report, size_t report_size, void **target_info_buffer, size_t *target_info_size)
Extracts additional platform specific data from the report and writes it to target_info_buffer.
This file defines Open Enclave return codes (results).
enum _oe_result oe_result_t
This enumeration type defines return codes for Open Enclave functions.
This struct contains the parameters for asymmetric key derivation.
Definition: types.h:204
void oe_free_key(uint8_t *key_buffer, size_t key_buffer_size, uint8_t *key_info, size_t key_info_size)
Frees the given key and/or key info.
oe_result_t oe_create_enclave(const char *path, oe_enclave_type_t type, uint32_t flags, const void *config, uint32_t config_size, const oe_ocall_func_t *ocall_table, uint32_t ocall_count, oe_enclave_t **enclave)
The following structures are used by context-switchless calls, which is experimental, and subject to changes.
void oe_free_report(uint8_t *report_buffer)
Frees a report buffer obtained from oe_get_report.
oe_result_t oe_parse_report(const uint8_t *report, size_t report_size, oe_report_t *parsed_report)
Parse an enclave report into a standard format for reading.
oe_result_t oe_verify_report(oe_enclave_t *enclave, const uint8_t *report, size_t report_size, oe_report_t *parsed_report)
Verify the integrity of the report and its signature.
void oe_free_target_info(void *target_info_buffer)
Frees a target info obtained from oe_get_target_info.
oe_result_t oe_terminate_enclave(oe_enclave_t *enclave)
Terminate an enclave and reclaims its resources.
void(* oe_ocall_func_t)(const uint8_t *input_buffer, size_t input_buffer_size, uint8_t *output_buffer, size_t output_buffer_size, size_t *output_bytes_written)
Type of each function in an ocall-table.
Definition: host.h:61
struct _oe_enclave oe_enclave_t
This is an opaque handle to an enclave returned by oe_create_enclave().
Definition: types.h:140
This file defines structures and options passed to oe_get_report functions.