Open Enclave  0.5.x
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 
87 bool oe_is_within_enclave(const void* ptr, size_t size);
88 
105 bool oe_is_outside_enclave(const void* ptr, size_t size);
106 
120 void* oe_host_malloc(size_t size);
121 
145 void* oe_host_realloc(void* ptr, size_t size);
146 
161 void* oe_host_calloc(size_t nmemb, size_t size);
162 
172 void oe_host_free(void* ptr);
173 
187 char* oe_host_strndup(const char* str, size_t n);
188 
195 void oe_abort(void);
196 
222 void __oe_assert_fail(
223  const char* expr,
224  const char* file,
225  int line,
226  const char* func);
237 #ifndef NDEBUG
238 #define oe_assert(EXPR) \
239  do \
240  { \
241  if (!(EXPR)) \
242  __oe_assert_fail(#EXPR, __FILE__, __LINE__, __FUNCTION__); \
243  } while (0)
244 #else
245 #define oe_assert(EXPR)
246 #endif
247 
248 #if (OE_API_VERSION < 2)
249 #define oe_get_report oe_get_report_v1
250 #else
251 #define oe_get_report oe_get_report_v2
252 #endif
253 
286  uint32_t flags,
287  const uint8_t* report_data,
288  size_t report_data_size,
289  const void* opt_params,
290  size_t opt_params_size,
291  uint8_t* report_buffer,
292  size_t* report_buffer_size);
293 
318  uint32_t flags,
319  const uint8_t* report_data,
320  size_t report_data_size,
321  const void* opt_params,
322  size_t opt_params_size,
323  uint8_t** report_buffer,
324  size_t* report_buffer_size);
325 
331 void oe_free_report(uint8_t* report_buffer);
332 
333 #if (OE_API_VERSION < 2)
334 #define oe_get_target_info oe_get_target_info_v1
335 #else
336 #define oe_get_target_info oe_get_target_info_v2
337 #endif
338 
365  const uint8_t* report,
366  size_t report_size,
367  void* target_info_buffer,
368  size_t* target_info_size);
369 
391  const uint8_t* report,
392  size_t report_size,
393  void** target_info_buffer,
394  size_t* target_info_size);
395 
402 void oe_free_target_info(void* target_info);
403 
420  const uint8_t* report,
421  size_t report_size,
422  oe_report_t* parsed_report);
423 
442  const uint8_t* report,
443  size_t report_size,
444  oe_report_t* parsed_report);
445 
446 #if (OE_API_VERSION < 2)
447 #define oe_get_seal_key_by_policy oe_get_seal_key_by_policy_v1
448 #else
449 #define oe_get_seal_key_by_policy oe_get_seal_key_by_policy_v2
450 #endif
451 
482  oe_seal_policy_t seal_policy,
483  uint8_t* key_buffer,
484  size_t* key_buffer_size,
485  uint8_t* key_info,
486  size_t* key_info_size);
487 
512  oe_seal_policy_t seal_policy,
513  uint8_t** key_buffer,
514  size_t* key_buffer_size,
515  uint8_t** key_info,
516  size_t* key_info_size);
517 
518 #if (OE_API_VERSION < 2)
519 #define oe_get_seal_key oe_get_seal_key_v1
520 #else
521 #define oe_get_seal_key oe_get_seal_key_v2
522 #endif
523 
548  const uint8_t* key_info,
549  size_t key_info_size,
550  uint8_t* key_buffer,
551  size_t* key_buffer_size);
552 
574  oe_seal_policy_t seal_policy,
575  const oe_asymmetric_key_params_t* key_params,
576  uint8_t** key_buffer,
577  size_t* key_buffer_size,
578  uint8_t** key_info,
579  size_t* key_info_size);
580 
598  const oe_asymmetric_key_params_t* key_params,
599  const uint8_t* key_info,
600  size_t key_info_size,
601  uint8_t** key_buffer,
602  size_t* key_buffer_size);
603 
625  oe_seal_policy_t seal_policy,
626  const oe_asymmetric_key_params_t* key_params,
627  uint8_t** key_buffer,
628  size_t* key_buffer_size,
629  uint8_t** key_info,
630  size_t* key_info_size);
631 
649  const oe_asymmetric_key_params_t* key_params,
650  const uint8_t* key_info,
651  size_t key_info_size,
652  uint8_t** key_buffer,
653  size_t* key_buffer_size);
654 
664 void oe_free_key(
665  uint8_t* key_buffer,
666  size_t key_buffer_size,
667  uint8_t* key_info,
668  size_t key_info_size);
669 
690  const uint8_t* key_info,
691  size_t key_info_size,
692  uint8_t** key_buffer,
693  size_t* key_buffer_size);
694 
701 void oe_free_seal_key(uint8_t* key_buffer, uint8_t* key_info);
702 
714 
725 oe_result_t oe_random(void* data, size_t size);
726 
727 OE_EXTERNC_END
728 
729 #endif /* _OE_ENCLAVE_H */
void * oe_host_malloc(size_t size)
Allocate bytes from the host&#39;s heap.
void oe_free_report(uint8_t *report_buffer)
Frees a report buffer obtained from oe_get_report.
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(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.
void oe_host_free(void *ptr)
Release allocated memory.
oe_result_t oe_random(void *data, size_t size)
Generate a sequence of random bytes.
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_private_key_by_policy(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 private key that is associated with the identity of the enclave and the specified policy...
void oe_free_target_info(void *target_info)
Frees target info obtained from oe_get_target_info.
void * oe_host_calloc(size_t nmemb, size_t size)
Allocate zero-filled bytes from the host&#39;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.
oe_result_t oe_get_seal_key_by_policy_v1(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...
oe_result_t oe_get_report_v2(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.
This file defines data structures to set up vectored exception handlers in the enclave.
oe_result_t oe_get_seal_key_v2(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.
This file defines Open Enclave return codes (results).
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.
This struct contains the parameters for asymmetric key derivation.
Definition: types.h:198
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
oe_result_t oe_get_report_v1(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.
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_seal_key(uint8_t *key_buffer, uint8_t *key_info)
Frees a key and/or key info.
This file defines the properties for an enclave.
oe_result_t oe_get_private_key(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 private key that is associated with the identity of the enclave.
oe_result_t oe_remove_vectored_exception_handler(oe_vectored_exception_handler_t vectored_handler)
Remove an existing vectored exception handler.
oe_result_t oe_get_public_key_by_policy(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...
bool oe_is_within_enclave(const void *ptr, size_t size)
Check whether the given buffer is strictly within the enclave.
oe_result_t oe_get_seal_key_v1(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.
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&#39;s heap.
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_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.
oe_result_t oe_get_seal_key_by_policy_v2(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...
struct _oe_enclave oe_enclave_t
This is an opaque handle to an enclave returned by oe_create_enclave().
Definition: types.h:134
oe_result_t oe_get_target_info_v1(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 structures and options passed to oe_get_report functions.