Open Enclave  0.6.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 
28 OE_EXTERNC_BEGIN
29 
40 #define OE_ENCLAVE_FLAG_DEBUG 0x00000001u
41 
45 #define OE_ENCLAVE_FLAG_SIMULATE 0x00000002u
46 
50 #define OE_ENCLAVE_FLAG_RESERVED \
51  (~(OE_ENCLAVE_FLAG_DEBUG | OE_ENCLAVE_FLAG_SIMULATE))
52 
59 typedef void (*oe_ocall_func_t)(
60  const uint8_t* input_buffer,
61  size_t input_buffer_size,
62  uint8_t* output_buffer,
63  size_t output_buffer_size,
64  size_t* output_bytes_written);
65 
101  const char* path,
102  oe_enclave_type_t type,
103  uint32_t flags,
104  const void* config,
105  uint32_t config_size,
106  const oe_ocall_func_t* ocall_table,
107  uint32_t ocall_table_size,
108  oe_enclave_t** enclave);
109 
123 
124 #if (OE_API_VERSION < 2)
125 #error "Only OE_API_VERSION of 2 is supported"
126 #else
127 #define oe_get_report oe_get_report_v2
128 #endif
129 
152  oe_enclave_t* enclave,
153  uint32_t flags,
154  const void* opt_params,
155  size_t opt_params_size,
156  uint8_t** report_buffer,
157  size_t* report_buffer_size);
158 
164 void oe_free_report(uint8_t* report_buffer);
165 
166 #if (OE_API_VERSION < 2)
167 #error "Only OE_API_VERSION of 2 is supported"
168 #else
169 #define oe_get_target_info oe_get_target_info_v2
170 #endif
171 
193  const uint8_t* report,
194  size_t report_size,
195  void** target_info_buffer,
196  size_t* target_info_size);
197 
203 void oe_free_target_info(void* target_info_buffer);
204 
220  const uint8_t* report,
221  size_t report_size,
222  oe_report_t* parsed_report);
223 
244  oe_enclave_t* enclave,
245  const uint8_t* report,
246  size_t report_size,
247  oe_report_t* parsed_report);
248 
271  oe_enclave_t* enclave,
272  oe_seal_policy_t seal_policy,
273  const oe_asymmetric_key_params_t* key_params,
274  uint8_t** key_buffer,
275  size_t* key_buffer_size,
276  uint8_t** key_info,
277  size_t* key_info_size);
278 
297  oe_enclave_t* enclave,
298  const oe_asymmetric_key_params_t* key_params,
299  const uint8_t* key_info,
300  size_t key_info_size,
301  uint8_t** key_buffer,
302  size_t* key_buffer_size);
303 
313 void oe_free_key(
314  uint8_t* key_buffer,
315  size_t key_buffer_size,
316  uint8_t* key_info,
317  size_t key_info_size);
318 
324 typedef oe_result_t (
326 
349  uint8_t* cert_in_der,
350  size_t cert_in_der_len,
351  oe_identity_verify_callback_t enclave_identity_callback,
352  void* arg);
353 
354 OE_EXTERNC_END
355 
356 #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.
oe_result_t oe_verify_attestation_certificate(uint8_t *cert_in_der, size_t cert_in_der_len, oe_identity_verify_callback_t enclave_identity_callback, void *arg)
oe_verify_attestation_certificate
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_identity_verify_callback_t)(oe_identity_t *identity, void *arg)
identity validation callback type
Definition: host.h:325
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.
Structure to represent the identity of an enclave.
Definition: report.h:80
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.
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_table_size, oe_enclave_t **enclave)
Create an enclave from an enclave image file.
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:198
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.
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:59
struct _oe_enclave oe_enclave_t
This is an opaque handle to an enclave returned by oe_create_enclave().
Definition: types.h:134
This file defines structures and options passed to oe_get_report functions.