CCF
Loading...
Searching...
No Matches
enclave.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include <stdlib.h>
6
7#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE)
8#else
9# include <openenclave/attestation/attester.h>
10# include <openenclave/enclave.h>
11# include <openenclave/log.h>
12# include <openenclave/tracee.h>
13#endif
14
15namespace ccf::pal
16{
17#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE)
18
19 static inline void initialize_enclave() {}
20
21 static inline void shutdown_enclave() {}
22
23 static inline bool is_outside_enclave(const void* ptr, std::size_t size)
24 {
25 return true;
26 }
27
28#else
29
30 static inline void initialize_enclave()
31 {
32 auto rc = oe_attester_initialize();
33 if (rc != OE_OK)
34 {
35 throw ccf::ccf_oe_attester_init_error(fmt::format(
36 "Failed to initialise evidence attester: {}", oe_result_str(rc)));
37 }
38 }
39
40 static inline void shutdown_enclave()
41 {
42 oe_attester_shutdown();
43 }
44
45 static bool is_outside_enclave(const void* ptr, size_t size)
46 {
47 return oe_is_outside_enclave(ptr, size);
48 }
49
50#endif
51}
Definition ccf_exception.h:36
Definition attestation.h:28
#define oe_result_str(x)
Definition virtual_enclave.h:52
constexpr oe_result_t OE_OK
Definition virtual_enclave.h:41