Open Enclave  0.6.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/fs.h"
20 #include "bits/module.h"
21 #include "bits/properties.h"
22 #include "bits/report.h"
23 #include "bits/result.h"
24 #include "bits/types.h"
25 
29 OE_EXTERNC_BEGIN
30 
57  bool is_first_handler,
58  oe_vectored_exception_handler_t vectored_handler);
59 
71  oe_vectored_exception_handler_t vectored_handler);
72 
89 bool oe_is_within_enclave(const void* ptr, size_t size);
90 
107 bool oe_is_outside_enclave(const void* ptr, size_t size);
108 
122 void* oe_host_malloc(size_t size);
123 
147 void* oe_host_realloc(void* ptr, size_t size);
148 
163 void* oe_host_calloc(size_t nmemb, size_t size);
164 
174 void oe_host_free(void* ptr);
175 
189 char* oe_host_strndup(const char* str, size_t n);
190 
197 void oe_abort(void);
198 
224 void __oe_assert_fail(
225  const char* expr,
226  const char* file,
227  int line,
228  const char* func);
239 #ifndef NDEBUG
240 #define oe_assert(EXPR) \
241  do \
242  { \
243  if (!(EXPR)) \
244  __oe_assert_fail(#EXPR, __FILE__, __LINE__, __FUNCTION__); \
245  } while (0)
246 #else
247 #define oe_assert(EXPR)
248 #endif
249 
250 #if (OE_API_VERSION < 2)
251 #error "Only OE_API_VERSION of 2 is supported"
252 #else
253 #define oe_get_report oe_get_report_v2
254 #endif
255 
280  uint32_t flags,
281  const uint8_t* report_data,
282  size_t report_data_size,
283  const void* opt_params,
284  size_t opt_params_size,
285  uint8_t** report_buffer,
286  size_t* report_buffer_size);
287 
293 void oe_free_report(uint8_t* report_buffer);
294 
295 #if (OE_API_VERSION < 2)
296 #error "Only OE_API_VERSION of 2 is supported"
297 #else
298 #define oe_get_target_info oe_get_target_info_v2
299 #endif
300 
322  const uint8_t* report,
323  size_t report_size,
324  void** target_info_buffer,
325  size_t* target_info_size);
326 
333 void oe_free_target_info(void* target_info);
334 
351  const uint8_t* report,
352  size_t report_size,
353  oe_report_t* parsed_report);
354 
373  const uint8_t* report,
374  size_t report_size,
375  oe_report_t* parsed_report);
376 
377 #if (OE_API_VERSION < 2)
378 #error "Only OE_API_VERSION of 2 is supported"
379 #else
380 #define oe_get_seal_key_by_policy oe_get_seal_key_by_policy_v2
381 #endif
382 
407  oe_seal_policy_t seal_policy,
408  uint8_t** key_buffer,
409  size_t* key_buffer_size,
410  uint8_t** key_info,
411  size_t* key_info_size);
412 
413 #if (OE_API_VERSION < 2)
414 #error "Only OE_API_VERSION of 2 is supported"
415 #else
416 #define oe_get_seal_key oe_get_seal_key_v2
417 #endif
418 
440  oe_seal_policy_t seal_policy,
441  const oe_asymmetric_key_params_t* key_params,
442  uint8_t** key_buffer,
443  size_t* key_buffer_size,
444  uint8_t** key_info,
445  size_t* key_info_size);
446 
464  const oe_asymmetric_key_params_t* key_params,
465  const uint8_t* key_info,
466  size_t key_info_size,
467  uint8_t** key_buffer,
468  size_t* key_buffer_size);
469 
491  oe_seal_policy_t seal_policy,
492  const oe_asymmetric_key_params_t* key_params,
493  uint8_t** key_buffer,
494  size_t* key_buffer_size,
495  uint8_t** key_info,
496  size_t* key_info_size);
497 
515  const oe_asymmetric_key_params_t* key_params,
516  const uint8_t* key_info,
517  size_t key_info_size,
518  uint8_t** key_buffer,
519  size_t* key_buffer_size);
520 
530 void oe_free_key(
531  uint8_t* key_buffer,
532  size_t key_buffer_size,
533  uint8_t* key_info,
534  size_t key_info_size);
535 
556  const uint8_t* key_info,
557  size_t key_info_size,
558  uint8_t** key_buffer,
559  size_t* key_buffer_size);
560 
567 void oe_free_seal_key(uint8_t* key_buffer, uint8_t* key_info);
568 
580 
591 oe_result_t oe_random(void* data, size_t size);
592 
616  const unsigned char* subject_name,
617  uint8_t* private_key,
618  size_t private_key_size,
619  uint8_t* public_key,
620  size_t public_key_size,
621  uint8_t** output_cert,
622  size_t* output_cert_size);
623 
628 void oe_free_attestation_certificate(uint8_t* cert);
629 
635 typedef oe_result_t (
637 
660  uint8_t* cert_in_der,
661  size_t cert_in_der_len,
662  oe_identity_verify_callback_t enclave_identity_callback,
663  void* arg);
664 
665 OE_EXTERNC_END
666 
667 #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...
Structure to represent the identity of an enclave.
Definition: report.h:80
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_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.
void oe_free_attestation_certificate(uint8_t *cert)
Free the given cert.
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_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
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_generate_attestation_certificate(const unsigned char *subject_name, uint8_t *private_key, size_t private_key_size, uint8_t *public_key, size_t public_key_size, uint8_t **output_cert, size_t *output_cert_size)
oe_generate_attestation_certificate.
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_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.
This file defines functions to load the optional modules available.
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_identity_verify_callback_t)(oe_identity_t *identity, void *arg)
identity validation callback type
Definition: enclave.h:636
This file defines structures and options passed to oe_get_report functions.