Skip to content

Commit e7bbc15

Browse files
committed
Linux 2.20 Open Source Gold Release
Supported the AEX (Asynchronous Enclave Exit) Notify feature. Supported Mbed-TLS Cryptography library (excluding SSL/TLS portion) in Enclave. Applied patches to OpenSSL 1.1.1t, fixed CVE-2023-1255, CVE-2023-0465 and CVE-2023-0466. Upgraded to Intel(R) Integrated Performance Primitives (IPP) Cryptography library version 2021.7. Upgraded Intel SGX Quote Verification Enclave to integrate updated SgxSSL. Enhanced the attestation local cache functionality by giving users the option to provide their own cache file. Enabled QPL/QCNL log in DCAP samples. Fixed bugs. Signed-off-by: Li, Xun <[email protected]>
1 parent 1efe23c commit e7bbc15

File tree

1,180 files changed

+48196
-48195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,180 files changed

+48196
-48195
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/linux/installer/bin/*.bin
2020

2121
# files downloaded in preparation phase
22-
Intel redistributable binary.txt
22+
BSD-3-Clause.txt
2323
Master_EULA_for_Intel_Sw_Development_Products.pdf
2424
external/ippcp_internal/inc/ippcp.h
2525
external/ippcp_internal/inc/ippcpdefs.h

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
[submodule "ipp-crypto"]
1313
path = external/ippcp_internal/ipp-crypto
1414
url = https://github.com/intel/ipp-crypto.git
15-
branch = ipp-crypto_2021_3
15+
branch = ipp-crypto_2021_7
1616
[submodule "external/protobuf/protobuf_code"]
1717
path = external/protobuf/protobuf_code
1818
url = https://github.com/protocolbuffers/protobuf.git
1919
branch = 3.20.x
2020
[submodule "external/sgx-emm/emm_src"]
2121
path = external/sgx-emm/emm_src
2222
url = https://github.com/intel/sgx-emm.git
23+
[submodule "external/mbedtls/mbedtls_code"]
24+
path = external/mbedtls/mbedtls_code
25+
url = https://github.com/Mbed-TLS/mbedtls.git

Linux_SGXEclipsePlugin/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $DELETE_CURRENT_ECLIPSE - Delete current eclipse or not. Generally this variable
66

77
The following plugins are pre-requisites to be installed in Eclipse before trying to build the plugin.
88

9-
1. Eclipse IDE for C/C++ Developers 4.7.3.20180308-1800 (tested_version)
9+
1. Eclipse IDE for C/C++ Developers 4.21.0.20210910-1417 (tested_version)
1010
2. Eclipse PDE Plug-in Developer Resources 3.13.3.v20180301-11 (tested_version)
1111

1212
run ./build.sh from command line under current directory.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The [intel-sgx-ssl](https://github.com/intel/intel-sgx-ssl) project provides a f
5151

5252

5353
This repository provides a reference implementation of a Launch Enclave for 'Flexible Launch Control' under [psw/ae/ref_le](psw/ae/ref_le). The reference LE implementation can be used as a basis for enforcing different launch control policy by the platform developer or owner. To build and try it by yourself, please refer to the [ref_le.md](psw/ae/ref_le/ref_le.md) for details.
54+
**NOTE**: The reference LE is only workable with [linux-sgx-driver](https://github.com/intel/linux-sgx-driver) and is planned to be deprecated starting from Intel(R) SGX release 2.20.
5455

5556
License
5657
-------
@@ -73,7 +74,7 @@ Quick Start with Docker and Docker Compose
7374
$ cd docker/build && ./build_compose_run.sh
7475
```
7576

76-
- Use prebuilt PSW and SDK downloaded from 01.org. See this [README](linux/installer/docker/README.md) for details.
77+
- Build and deploy SGX exclave applications using prebuilt PSW and SDK downloaded from 01.org. See this [README](linux/installer/docker/README.md) for details.
7778
```
7879
$ cd linux/installer/docker && ./build_compose_run.sh
7980
```
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
/*
2+
* Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in
12+
* the documentation and/or other materials provided with the
13+
* distribution.
14+
* * Neither the name of Intel Corporation nor the names of its
15+
* contributors may be used to endorse or promote products derived
16+
* from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
*/
31+
32+
33+
#include <stdio.h>
34+
#include <string.h>
35+
#include <assert.h>
36+
37+
# include <unistd.h>
38+
# include <pwd.h>
39+
# define MAX_PATH FILENAME_MAX
40+
#include <time.h>
41+
#include "powers_of_two.h"
42+
#include "sgx_urts.h"
43+
#include "App.h"
44+
#include "Enclave_u.h"
45+
46+
/* Global EID shared by multiple threads */
47+
sgx_enclave_id_t global_eid = 0;
48+
49+
typedef struct _sgx_errlist_t {
50+
sgx_status_t err;
51+
const char *msg;
52+
const char *sug; /* Suggestion */
53+
} sgx_errlist_t;
54+
55+
/* Error code returned by sgx_create_enclave */
56+
static sgx_errlist_t sgx_errlist[] = {
57+
{
58+
SGX_ERROR_UNEXPECTED,
59+
"Unexpected error occurred.",
60+
NULL
61+
},
62+
{
63+
SGX_ERROR_INVALID_PARAMETER,
64+
"Invalid parameter.",
65+
NULL
66+
},
67+
{
68+
SGX_ERROR_OUT_OF_MEMORY,
69+
"Out of memory.",
70+
NULL
71+
},
72+
{
73+
SGX_ERROR_ENCLAVE_LOST,
74+
"Power transition occurred.",
75+
"Please refer to the sample \"PowerTransition\" for details."
76+
},
77+
{
78+
SGX_ERROR_INVALID_ENCLAVE,
79+
"Invalid enclave image.",
80+
NULL
81+
},
82+
{
83+
SGX_ERROR_INVALID_ENCLAVE_ID,
84+
"Invalid enclave identification.",
85+
NULL
86+
},
87+
{
88+
SGX_ERROR_INVALID_SIGNATURE,
89+
"Invalid enclave signature.",
90+
NULL
91+
},
92+
{
93+
SGX_ERROR_OUT_OF_EPC,
94+
"Out of EPC memory.",
95+
NULL
96+
},
97+
{
98+
SGX_ERROR_NO_DEVICE,
99+
"Invalid SGX device.",
100+
"Please make sure SGX module is enabled in the BIOS, and install SGX driver afterwards."
101+
},
102+
{
103+
SGX_ERROR_MEMORY_MAP_CONFLICT,
104+
"Memory map conflicted.",
105+
NULL
106+
},
107+
{
108+
SGX_ERROR_INVALID_METADATA,
109+
"Invalid enclave metadata.",
110+
NULL
111+
},
112+
{
113+
SGX_ERROR_DEVICE_BUSY,
114+
"SGX device was busy.",
115+
NULL
116+
},
117+
{
118+
SGX_ERROR_INVALID_VERSION,
119+
"Enclave version was invalid.",
120+
NULL
121+
},
122+
{
123+
SGX_ERROR_INVALID_ATTRIBUTE,
124+
"Enclave was not authorized.",
125+
NULL
126+
},
127+
{
128+
SGX_ERROR_ENCLAVE_FILE_ACCESS,
129+
"Can't open enclave file.",
130+
NULL
131+
},
132+
};
133+
134+
/* Check error conditions for loading enclave */
135+
void print_error_message(sgx_status_t ret)
136+
{
137+
size_t idx = 0;
138+
size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0];
139+
140+
for (idx = 0; idx < ttl; idx++) {
141+
if(ret == sgx_errlist[idx].err) {
142+
if(NULL != sgx_errlist[idx].sug)
143+
printf("Info: %s\n", sgx_errlist[idx].sug);
144+
printf("Error: %s\n", sgx_errlist[idx].msg);
145+
break;
146+
}
147+
}
148+
149+
if (idx == ttl)
150+
printf("Error code is 0x%X. Please refer to the \"Intel SGX SDK Developer Reference\" for more details.\n", ret);
151+
}
152+
153+
/* Initialize the enclave:
154+
* Call sgx_create_enclave to initialize an enclave instance
155+
*/
156+
int initialize_enclave(void)
157+
{
158+
sgx_status_t ret = SGX_ERROR_UNEXPECTED;
159+
160+
/* Call sgx_create_enclave to initialize an enclave instance */
161+
/* Debug Support: set 2nd parameter to 1 */
162+
ret = sgx_create_enclave(ENCLAVE_FILENAME, SGX_DEBUG_FLAG, NULL, NULL, &global_eid, NULL);
163+
if (ret != SGX_SUCCESS) {
164+
print_error_message(ret);
165+
return -1;
166+
}
167+
168+
return 0;
169+
}
170+
171+
/* OCall functions */
172+
void ocall_print_string(const char *str)
173+
{
174+
/* Proxy/Bridge will check the length and null-terminate
175+
* the input string to prevent buffer overflow.
176+
*/
177+
printf("%s", str);
178+
}
179+
180+
181+
/* Application entry */
182+
int SGX_CDECL main(int argc, char *argv[])
183+
{
184+
(void)(argc);
185+
(void)(argv);
186+
187+
188+
/* Initialize the enclave */
189+
if(initialize_enclave() < 0){
190+
printf("Enter a character before exit ...\n");
191+
getchar();
192+
return -1;
193+
}
194+
195+
// We want to run a program for a really long time by
196+
// searching for powers of two between 0 and max_value.
197+
// Our initial max_value guess for something that will
198+
// take about 60 seconds is 0xffff.
199+
uint64_t max_value = 0xffff;
200+
time_t t1 = 0, t2 = 0;
201+
uint32_t count = 0;
202+
203+
// Find out what max value takes more than 60 seconds when running
204+
// outside the enclave.
205+
while ((t2 - t1) < 60)
206+
{
207+
if ((t2 - t1) < 30)
208+
max_value *= 4;
209+
else
210+
max_value *= 2;
211+
212+
t1 = time(NULL);
213+
count = count_powers_of_two(0, max_value);
214+
t2 = time(NULL);
215+
printf("There are %u powers of two between 0 and %p (calculated outside the enclave)\n", count, (void*)max_value);
216+
printf("\tIt took %u seconds to compute\n", (uint32_t)(t2 - t1));
217+
fflush(stdout);
218+
}
219+
220+
// Now we have a good idea of something that should take at least 60 seconds
221+
// Make an ECALL for the same function with AEX Enabled. The function
222+
// will also count the number of times it its AEX handler was called back.
223+
count = 0;
224+
uint64_t aex_count = 0;
225+
t1 = time(NULL);
226+
sgx_status_t status = count_powers_of_two_with_aex(global_eid, 0, max_value, &count, &aex_count);
227+
t2 = time(NULL);
228+
if (status != SGX_SUCCESS)
229+
{
230+
printf("count_powers_of_two_with_aex returned %#x\n", status);
231+
print_error_message(status);
232+
return -1;
233+
}
234+
printf("There are %u powers of two between 0 and %p (calculated inside the enclave)\n", count, (void*)max_value);
235+
printf("\tIt took %u seconds to compute\n", (uint32_t)(t2 - t1));
236+
printf("\tWe counted %lu async enclave exits during this time period. \n", aex_count);
237+
238+
/* Destroy the enclave */
239+
sgx_destroy_enclave(global_eid);
240+
241+
printf("Info: SampleAEXNotify successfully returned.\n");
242+
243+
return 0;
244+
}
245+

SampleCode/SampleAEXNotify/App/App.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in
12+
* the documentation and/or other materials provided with the
13+
* distribution.
14+
* * Neither the name of Intel Corporation nor the names of its
15+
* contributors may be used to endorse or promote products derived
16+
* from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
*/
31+
32+
33+
#ifndef _APP_H_
34+
#define _APP_H_
35+
36+
#include <assert.h>
37+
#include <stdio.h>
38+
#include <stdlib.h>
39+
#include <stdarg.h>
40+
41+
#include "sgx_error.h" /* sgx_status_t */
42+
#include "sgx_eid.h" /* sgx_enclave_id_t */
43+
44+
#ifndef TRUE
45+
# define TRUE 1
46+
#endif
47+
48+
#ifndef FALSE
49+
# define FALSE 0
50+
#endif
51+
52+
# define TOKEN_FILENAME "enclave.token"
53+
# define ENCLAVE_FILENAME "enclave.signed.so"
54+
55+
extern sgx_enclave_id_t global_eid; /* global enclave id */
56+
57+
#endif /* !_APP_H_ */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<EnclaveConfiguration>
2+
<ProdID>0</ProdID>
3+
<ISVSVN>0</ISVSVN>
4+
<StackMaxSize>0x40000</StackMaxSize>
5+
<HeapMaxSize>0x100000</HeapMaxSize>
6+
<TCSNum>10</TCSNum>
7+
<TCSPolicy>1</TCSPolicy>
8+
<EnableAEXNotify>1</EnableAEXNotify>
9+
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
10+
<DisableDebug>0</DisableDebug>
11+
<MiscSelect>0</MiscSelect>
12+
<MiscMask>0xFFFFFFFF</MiscMask>
13+
</EnclaveConfiguration>

0 commit comments

Comments
 (0)