Open Enclave
enclave.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_ENCLAVE_H
11 #define _OE_ENCLAVE_H
12 
13 #ifdef _OE_HOST_H
14 #error "enclave.h and host.h must not be included in the same compilation unit."
15 #endif
16 
17 #include "bits/defs.h"
18 #include "bits/exception.h"
19 #include "bits/properties.h"
20 #include "bits/report.h"
21 #include "bits/result.h"
22 #include "bits/types.h"
23 
27 OE_EXTERNC_BEGIN
28 
55  bool is_first_handler,
56  oe_vectored_exception_handler_t vectored_handler);
57 
69  oe_vectored_exception_handler_t vectored_handler);
70 
96 oe_result_t oe_call_host(const char* func, void* args);
97 
122  void (*func)(void*, oe_enclave_t*),
123  void* args);
124 
141 bool oe_is_within_enclave(const void* ptr, size_t size);
142 
159 bool oe_is_outside_enclave(const void* ptr, size_t size);
160 
174 void* oe_host_malloc(size_t size);
175 
199 void* oe_host_realloc(void* ptr, size_t size);
200 
215 void* oe_host_calloc(size_t nmemb, size_t size);
216 
226 void oe_host_free(void* ptr);
227 
241 char* oe_host_strndup(const char* str, size_t n);
242 
249 void oe_abort(void);
250 
272 void __oe_assert_fail(
273  const char* expr,
274  const char* file,
275  int line,
276  const char* func);
277 
281 #ifndef NDEBUG
282 #define oe_assert(EXPR) \
283  do \
284  { \
285  if (!(EXPR)) \
286  __oe_assert_fail(#EXPR, __FILE__, __LINE__, __FUNCTION__); \
287  } while (0)
288 #else
289 #define oe_assert(EXPR)
290 #endif
291 
322  uint32_t flags,
323  const uint8_t* report_data,
324  size_t report_data_size,
325  const void* opt_params,
326  size_t opt_params_size,
327  uint8_t* report_buffer,
328  size_t* report_buffer_size);
329 
354  const uint8_t* report,
355  size_t report_size,
356  void* target_info_buffer,
357  size_t* target_info_size);
358 
375  const uint8_t* report,
376  size_t report_size,
377  oe_report_t* parsed_report);
378 
397  const uint8_t* report,
398  size_t report_size,
399  oe_report_t* parsed_report);
400 
404 typedef enum _oe_seal_policy {
420  _OE_SEAL_POLICY_MAX = OE_ENUM_MAX,
450  oe_seal_policy_t seal_policy,
451  uint8_t* key_buffer,
452  size_t* key_buffer_size,
453  uint8_t* key_info,
454  size_t* key_info_size);
455 
478  const uint8_t* key_info,
479  size_t key_info_size,
480  uint8_t* key_buffer,
481  size_t* key_buffer_size);
482 
493 oe_enclave_t* oe_get_enclave(void);
494 
495 OE_EXTERNC_END
496 
497 #endif /* _OE_ENCLAVE_H */
void * oe_host_malloc(size_t size)
Allocate bytes from the host's heap.
void oe_host_free(void *ptr)
Release allocated memory.
Structure to hold the parsed form of a report.
Definition: report.h:112
void oe_abort(void)
Abort execution of the enclave.
oe_result_t oe_get_target_info(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_call_host(const char *func, void *args)
Perform a high-level enclave function call (OCALL).
oe_result_t oe_get_seal_key(const uint8_t *key_info, size_t key_info_size, uint8_t *key_buffer, size_t *key_buffer_size)
Get a symmetric encryption key from the enclave platform using existing key information.
void * oe_host_calloc(size_t nmemb, size_t size)
Allocate zero-filled bytes from the host's heap.
oe_result_t oe_verify_report(const uint8_t *report, size_t report_size, oe_report_t *parsed_report)
Verify the integrity of the report and its signature.
void __oe_assert_fail(const char *expr, const char *file, int line, const char *func)
Called whenever an assertion fails.
_oe_seal_policy
This enumeration type defines the policy used to derive a seal key.
Definition: enclave.h:404
This file defines data structures to setup vectored exception handlers in the enclave.
oe_result_t oe_get_report(uint32_t flags, const uint8_t *report_data, size_t report_data_size, 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_call_host_by_address(void(*func)(void *, oe_enclave_t *), void *args)
Perform a high-level host function call (OCALL).
This file defines Open Enclave return codes (results).
oe_result_t oe_get_seal_key_by_policy(oe_seal_policy_t seal_policy, uint8_t *key_buffer, size_t *key_buffer_size, uint8_t *key_info, size_t *key_info_size)
Get a symmetric encryption key derived from the specified policy and coupled to the enclave platform...
enum _oe_result oe_result_t
This enumeration type defines return codes for Open Enclave functions.
char * oe_host_strndup(const char *str, size_t n)
Make a heap copy of a string.
uint64_t(* oe_vectored_exception_handler_t)(oe_exception_record_t *exception_context)
oe_vectored_exception_handler_t - Function pointer for a vectored exception handler in an enclave...
Definition: exception.h:160
Key is derived from a measurement of the enclave.
Definition: enclave.h:410
Key is derived from the signer of the enclave.
Definition: enclave.h:416
This file defines the SGX properties for an enclave.
oe_result_t oe_remove_vectored_exception_handler(oe_vectored_exception_handler_t vectored_handler)
Remove an existing vectored exception handler.
bool oe_is_within_enclave(const void *ptr, size_t size)
Check whether the given buffer is strictly within the enclave.
oe_enclave_t * oe_get_enclave(void)
Obtains the enclave handle.
void * oe_host_realloc(void *ptr, size_t size)
Reallocate bytes from the host's heap.
enum _oe_seal_policy oe_seal_policy_t
This enumeration type defines the policy used to derive a seal key.
oe_result_t oe_add_vectored_exception_handler(bool is_first_handler, oe_vectored_exception_handler_t vectored_handler)
Register a new vectored exception handler.
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.
bool oe_is_outside_enclave(const void *ptr, size_t size)
Check whether the given buffer is strictly outside the enclave.
Unused.
Definition: enclave.h:420
This file defines structures and options passed to GetReport functions.