-
Notifications
You must be signed in to change notification settings - Fork 2
/
SGX_Print.cpp
81 lines (59 loc) · 1.35 KB
/
SGX_Print.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*!
*
* SGX_Print.cpp
*
* Copyright (c) 2020 IWATA Daiki
*
* This software is released under the MIT License.
* see http://opensource.org/licenses/mit-license
*
*/
#include "SGX_Print.hpp"
/* Check error conditions for loading enclave */
void print_error_message(sgx_status_t ret)
{
size_t idx = 0;
size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0];
for (idx = 0; idx < ttl; idx++) {
if(ret == sgx_errlist[idx].err) {
if(NULL != sgx_errlist[idx].sug)
printf("Info: %s\n", sgx_errlist[idx].sug);
printf("Error: %s\n", sgx_errlist[idx].msg);
break;
}
}
if (idx == ttl)
printf("Error code is 0x%X. Please refer to the \"Intel SGX SDK Developer Reference\" for more details.\n", ret);
}
void ocall_print_string(const char *str)
{
/* Proxy/Bridge will check the length and null-terminate
* the input string to prevent buffer overflow.
*/
printf("%s", str);
}
void OCALL_print(const char* str)
{
cout << "[OCALL] " << str << endl;
return;
}
void OCALL_cerror(const char* str)
{
cerr << "[OCALL] " << str << endl;
exit(-1);
}
void OCALL_print_uint8_t(uint8_t* str, size_t len)
{
cout << "[OCALL] " << str << endl;
return;
}
void OCALL_print_int(int val)
{
cout << "[OCALL] " << val << endl;
return;
}
void OCALL_print_double(double val)
{
cout << "[OCALL] " << val << endl;
return;
}