Skip to content

Commit 6bb988f

Browse files
committed
Linux 2.15 Open Source Gold Release
Upgraded Intel(R) Integrated Performance Primitives Cryptography library to version 2021 update 3. Upgraded Intel(R) SGX Architecture Enclaves based on new IPP crypto library. Added software prevention of fault injection attacks. Upgraded to GNU Binutils 2.36.1. Stopped providing ld.gold (developers should use ld instead). Supported Google Protobuf C++. Enabled C++14 within SGX SDK. Added SM2/3/4 Samples. Fixed bugs. Signed-off-by: Zhang Lili <lili.z.zhang@intel.com>
1 parent 6b8d2d1 commit 6bb988f

File tree

665 files changed

+15152
-3482
lines changed

Some content is hidden

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

665 files changed

+15152
-3482
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
# files downloaded in preparation phase
2222
Intel redistributable binary.txt
2323
Master_EULA_for_Intel_Sw_Development_Products.pdf
24-
external/ippcp_internal/
24+
external/ippcp_internal/inc/ippcp.h
25+
external/ippcp_internal/inc/ippcpdefs.h
26+
external/ippcp_internal/inc/ippversion.h
27+
external/ippcp_internal/inc/sgx_ippcp.h
28+
external/ippcp_internal/license/
2529
external/toolset/
2630
psw/ae/data/prebuilt/README.md
2731
redist.txt

.gitmodules

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
[submodule "ipp-crypto"]
1313
path = external/ippcp_internal/ipp-crypto
1414
url = https://github.com/intel/ipp-crypto.git
15-
branch = ipp-crypto_2020_update3
15+
branch = ipp-crypto_2021_3
16+
[submodule "external/protobuf/protobuf_code"]
17+
path = external/protobuf/protobuf_code
18+
url = https://github.com/protocolbuffers/protobuf.git
19+
branch = 3.14.x

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ preparation:
5353
git submodule update --init --recursive
5454
./external/dcap_source/QuoteVerification/prepare_sgxssl.sh nobuild
5555
cd external/openmp/openmp_code && git apply ../0001-Enable-OpenMP-in-SGX.patch >/dev/null 2>&1 || git apply ../0001-Enable-OpenMP-in-SGX.patch --check -R
56+
cd external/protobuf/protobuf_code && git apply ../sgx_protobuf.patch >/dev/null 2>&1 || git apply ../sgx_protobuf.patch --check -R
5657
@# download prebuilt binaries
5758
./download_prebuilt.sh
5859
./external/dcap_source/QuoteGeneration/download_prebuilt.sh

README.md

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ The [linux-sgx-driver](https://github.com/01org/linux-sgx-driver) project hosts
4646

4747
The [intel-device-plugins-for-kubernetes](https://github.com/intel/intel-device-plugins-for-kubernetes) project enables users to run container applications running Intel(R) SGX enclaves in Kubernetes clusters. It also gives instructions how to set up ECDSA based attestation in a cluster.
4848

49+
50+
The [intel-sgx-ssl](https://github.com/intel/intel-sgx-ssl) project provides a full-strength general purpose cryptography library for Intel(R) SGX enclave applications. It is based on the underlying OpenSSL* Open Source project. Intel(R) SGX provides a build combination to build out a SGXSSL based SDK as [below](#build-the-intelr-sgx-sdk-and-intelr-sgx-sdk-installer). Users could also utilize this cryptography library in SGX enclave applications seperately.
51+
52+
4953
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.
5054

5155
License
@@ -87,10 +91,8 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
8791
* Ubuntu\* 18.04 LTS Server 64bits
8892
* Ubuntu\* 20.04 LTS Desktop 64bits
8993
* Ubuntu\* 20.04 LTS Server 64bits
90-
* Red Hat Enterprise Linux Server release 7.6 64bits
9194
* Red Hat Enterprise Linux Server release 8.2 64bits
9295
* CentOS 8.2 64bits
93-
* Fedora 31 Server 64bits
9496

9597
- Use the following command(s) to install the required tools to build the Intel(R) SGX SDK:
9698
* On Ubuntu 18.04:
@@ -101,7 +103,7 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
101103
```
102104
$ sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python-is-python3 libssl-dev git cmake perl
103105
```
104-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2:
106+
* On Red Hat Enterprise Linux 8.2:
105107
```
106108
$ sudo yum groupinstall 'Development Tools'
107109
$ sudo yum install ocaml ocaml-ocamlbuild wget python2 openssl-devel git cmake perl
@@ -113,19 +115,14 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
113115
$ sudo dnf --enablerepo=PowerTools install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python2
114116
$ sudo alternatives --set python /usr/bin/python2
115117
```
116-
* On Fedora 31:
117-
```
118-
$ sudo yum groupinstall 'C Development Tools and Libraries'
119-
$ sudo yum install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget python rpm-build git cmake perl
120-
```
121-
**Note**: To build Intel(R) SGX SDK, gcc version is required to be 7.3 or above and glibc version is required to be 2.27 or above. For Red Hat Enterprise Linux 7.6, you may need to update gcc and glibc version manually.
118+
**Note**: To build Intel(R) SGX SDK, gcc version is required to be 7.3 or above and glibc version is required to be 2.27 or above.
122119
- Use the following command to install additional required tools and latest Intel(R) SGX SDK Installer to build the Intel(R) SGX PSW:
123120
1) To install the additional required tools:
124121
* On Ubuntu 18.04 and Ubuntu 20.04:
125122
```
126123
$ sudo apt-get install libssl-dev libcurl4-openssl-dev protobuf-compiler libprotobuf-dev debhelper cmake reprepro unzip
127124
```
128-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2 and Fedora 31:
125+
* On Red Hat Enterprise Linux 8.2:
129126
```
130127
$ sudo yum install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils
131128
```
@@ -234,7 +231,7 @@ You can find the tools and libraries generated in the `build/linux` directory.
234231
```
235232
$ make deb_psw_pkg DEBUG=1
236233
```
237-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2, CentOS 8.2 and Fedora 31:
234+
* On Red Hat Enterprise Linux 8.2 and CentOS 8.2:
238235
```
239236
$ make rpm_psw_pkg
240237
```
@@ -278,12 +275,12 @@ You can find the tools and libraries generated in the `build/linux` directory.
278275
**Note**: The above command builds the local package repository. If you want to use it, you need to add it to the system repository configuration. Since the local package repository is not signed with GPG, you should ignore the gpgcheck when installing the packages.
279276
280277
- To add the local RPM package repository to the system repository configuration, you can use the following command. You need to replace PATH_TO_LOCAL_REPO with the proper path on your system:
281-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2, CentOS 8.2, Fedora 31:
278+
* On Red Hat Enterprise Linux 8.2 and CentOS 8.2:
282279
```
283280
$ sudo yum-config-manager --add-repo file://PATH_TO_LOCAL_REPO
284281
```
285282
- To ignore the gpgcheck when you install the package, enter the following command:
286-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2, CentOS 8.2, Fedora 31:
283+
* On Red Hat Enterprise Linux 8.2 and CentOS 8.2:
287284
```
288285
$ sudo yum --nogpgcheck install <package>
289286
```
@@ -296,25 +293,19 @@ Install the Intel(R) SGX SDK
296293
* Ubuntu\* 18.04 LTS Server 64bits
297294
* Ubuntu\* 20.04 LTS Desktop 64bits
298295
* Ubuntu\* 20.04 LTS Server 64bits
299-
* Red Hat Enterprise Linux Server release 7.6 64bits
300296
* Red Hat Enterprise Linux Server release 8.2 64bits
301297
* CentOS 8.2 64bits
302-
* Fedora 31 Server 64bits
303298
- Use the following command to install the required tool to use Intel(R) SGX SDK:
304299
* On Ubuntu 18.04 and Ubuntu 20.04:
305300
```
306301
$ sudo apt-get install build-essential python
307302
```
308-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2 and CentOS 8.2:
303+
* On Red Hat Enterprise Linux 8.2 and CentOS 8.2:
309304
```
310305
$ sudo yum groupinstall 'Development Tools'
311306
$ sudo yum install python2
312307
$ sudo alternatives --set python /usr/bin/python2
313308
```
314-
* On Fedora 31:
315-
```
316-
$ sudo yum groupinstall 'C Development Tools and Libraries'
317-
```
318309
319310
### Install the Intel(R) SGX SDK
320311
To install the Intel(R) SGX SDK, invoke the installer, as follows:
@@ -330,7 +321,7 @@ NOTE: You need to set up the needed environment variables before compiling your
330321
### Test the Intel(R) SGX SDK Package with the Code Samples
331322
- Compile and run each code sample in Simulation mode to make sure the package works well:
332323
```
333-
$ cd SampleCode/LocalAttestation
324+
$ cd ${sgx-sdk-install-path}/SampleCode/LocalAttestation
334325
$ make SGX_MODE=SIM
335326
$ cd bin
336327
$ ./app
@@ -344,7 +335,7 @@ See the earlier topic, *Build and Install the Intel(R) SGX Driver*, for informat
344335
See the later topic, *Install Intel(R) SGX PSW*, for information on how to install the PSW package.
345336
- Compile and run each code sample in Hardware mode, Debug build, as follows:
346337
```
347-
$ cd SampleCode/LocalAttestation
338+
$ cd ${sgx-sdk-install-path}/SampleCode/LocalAttestation
348339
$ make
349340
$ cd bin
350341
$ ./app
@@ -360,10 +351,8 @@ Install the Intel(R) SGX PSW
360351
* Ubuntu\* 18.04 LTS Server 64bits
361352
* Ubuntu\* 20.04 LTS Desktop 64bits
362353
* Ubuntu\* 20.04 LTS Server 64bits
363-
* Red Hat Enterprise Linux Server release 7.6 64bits
364354
* Red Hat Enterprise Linux Server release 8.2 64bits
365355
* CentOS 8.2 64bits
366-
* Fedora 31 Server 64bits
367356
- Ensure that you have a system with the following required hardware:
368357
* 6th Generation Intel(R) Core(TM) Processor or newer
369358
- Configure the system with the **Intel SGX hardware enabled** option and install Intel(R) SGX driver in advance.
@@ -373,7 +362,7 @@ Install the Intel(R) SGX PSW
373362
```
374363
$ sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
375364
```
376-
* On Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2 and Fedora 31:
365+
* On Red Hat Enterprise Linux 8.2:
377366
```
378367
$ sudo yum install openssl-devel libcurl-devel protobuf-devel
379368
```
@@ -387,7 +376,7 @@ The SGX PSW provides 3 services: launch, EPID-based attestation, and algorithm a
387376
388377
#### Using the local repo(recommended)
389378
390-
| |Ubuntu 18.04 and Ubuntu 20.04|Red Hat Enterprise Linux 7.6, Red Hat Enterprise Linux 8.2, CentOS 8.2, Fedora 31|
379+
| |Ubuntu 18.04 and Ubuntu 20.04|Red Hat Enterprise Linux 8.2, CentOS 8.2|
391380
| ------------ | ------------ | ------------ |
392381
|launch service |apt-get install libsgx-launch libsgx-urts|yum install libsgx-launch libsgx-urts|
393382
|EPID-based attestation service|apt-get install libsgx-epid libsgx-urts|yum install libsgx-epid libsgx-urts|

SampleCode/Cxx14SGXDemo/App/App.cpp

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
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+
#include <stdio.h>
33+
#include <string.h>
34+
#include <assert.h>
35+
36+
# include <unistd.h>
37+
# include <pwd.h>
38+
# define MAX_PATH FILENAME_MAX
39+
40+
#include "sgx_urts.h"
41+
#include "App.h"
42+
#include "Enclave_u.h"
43+
44+
/* Global EID shared by multiple threads */
45+
sgx_enclave_id_t global_eid = 0;
46+
47+
typedef struct _sgx_errlist_t {
48+
sgx_status_t err;
49+
const char *msg;
50+
const char *sug; /* Suggestion */
51+
} sgx_errlist_t;
52+
53+
/* Error code returned by sgx_create_enclave */
54+
static sgx_errlist_t sgx_errlist[] = {
55+
{
56+
SGX_ERROR_UNEXPECTED,
57+
"Unexpected error occurred.",
58+
NULL
59+
},
60+
{
61+
SGX_ERROR_INVALID_PARAMETER,
62+
"Invalid parameter.",
63+
NULL
64+
},
65+
{
66+
SGX_ERROR_OUT_OF_MEMORY,
67+
"Out of memory.",
68+
NULL
69+
},
70+
{
71+
SGX_ERROR_ENCLAVE_LOST,
72+
"Power transition occurred.",
73+
"Please refer to the sample \"PowerTransition\" for details."
74+
},
75+
{
76+
SGX_ERROR_INVALID_ENCLAVE,
77+
"Invalid enclave image.",
78+
NULL
79+
},
80+
{
81+
SGX_ERROR_INVALID_ENCLAVE_ID,
82+
"Invalid enclave identification.",
83+
NULL
84+
},
85+
{
86+
SGX_ERROR_INVALID_SIGNATURE,
87+
"Invalid enclave signature.",
88+
NULL
89+
},
90+
{
91+
SGX_ERROR_OUT_OF_EPC,
92+
"Out of EPC memory.",
93+
NULL
94+
},
95+
{
96+
SGX_ERROR_NO_DEVICE,
97+
"Invalid SGX device.",
98+
"Please make sure SGX module is enabled in the BIOS, and install SGX driver afterwards."
99+
},
100+
{
101+
SGX_ERROR_MEMORY_MAP_CONFLICT,
102+
"Memory map conflicted.",
103+
NULL
104+
},
105+
{
106+
SGX_ERROR_INVALID_METADATA,
107+
"Invalid enclave metadata.",
108+
NULL
109+
},
110+
{
111+
SGX_ERROR_DEVICE_BUSY,
112+
"SGX device was busy.",
113+
NULL
114+
},
115+
{
116+
SGX_ERROR_INVALID_VERSION,
117+
"Enclave version was invalid.",
118+
NULL
119+
},
120+
{
121+
SGX_ERROR_INVALID_ATTRIBUTE,
122+
"Enclave was not authorized.",
123+
NULL
124+
},
125+
{
126+
SGX_ERROR_ENCLAVE_FILE_ACCESS,
127+
"Can't open enclave file.",
128+
NULL
129+
},
130+
{
131+
SGX_ERROR_NDEBUG_ENCLAVE,
132+
"The enclave is signed as product enclave, and can not be created as debuggable enclave.",
133+
NULL
134+
},
135+
};
136+
137+
/* Check error conditions for loading enclave */
138+
void print_error_message(sgx_status_t ret)
139+
{
140+
size_t idx = 0;
141+
size_t ttl = sizeof sgx_errlist/sizeof sgx_errlist[0];
142+
143+
for (idx = 0; idx < ttl; idx++) {
144+
if(ret == sgx_errlist[idx].err) {
145+
if(NULL != sgx_errlist[idx].sug)
146+
printf("Info: %s\n", sgx_errlist[idx].sug);
147+
printf("Error: %s\n", sgx_errlist[idx].msg);
148+
break;
149+
}
150+
}
151+
152+
if (idx == ttl)
153+
printf("Error: Unexpected error occurred.\n");
154+
}
155+
156+
/* Initialize the enclave:
157+
* Call sgx_create_enclave to initialize an enclave instance
158+
*/
159+
int initialize_enclave(void)
160+
{
161+
sgx_status_t ret = SGX_ERROR_UNEXPECTED;
162+
163+
/* Call sgx_create_enclave to initialize an enclave instance */
164+
/* Debug Support: set 2nd parameter to 1 */
165+
ret = sgx_create_enclave(ENCLAVE_FILENAME, SGX_DEBUG_FLAG, NULL, NULL, &global_eid, NULL);
166+
if (ret != SGX_SUCCESS) {
167+
print_error_message(ret);
168+
return -1;
169+
}
170+
171+
return 0;
172+
}
173+
174+
/* OCall functions */
175+
void ocall_print_string(const char *str)
176+
{
177+
/* Proxy/Bridge will check the length and null-terminate
178+
* the input string to prevent buffer overflow.
179+
*/
180+
printf("%s", str);
181+
}
182+
183+
184+
/* Application entry */
185+
int SGX_CDECL main(int argc, char *argv[])
186+
{
187+
(void)(argc);
188+
(void)(argv);
189+
190+
191+
/* Initialize the enclave */
192+
if(initialize_enclave() < 0){
193+
printf("Enter a character before exit ...\n");
194+
getchar();
195+
return -1;
196+
}
197+
198+
199+
/* Utilize trusted libraries */
200+
ecall_libcxx_functions();
201+
202+
/* Destroy the enclave */
203+
sgx_destroy_enclave(global_eid);
204+
205+
printf("Info: Cxx14DemoEnclave successfully returned.\n");
206+
207+
//printf("Enter a character before exit ...\n");
208+
//getchar();
209+
return 0;
210+
}
211+

0 commit comments

Comments
 (0)