Skip to content

Commit c3a5b03

Browse files
authored
Merge branch 'master' into master
2 parents 6e53f50 + d3bcf99 commit c3a5b03

File tree

836 files changed

+10229
-91439
lines changed

Some content is hidden

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

836 files changed

+10229
-91439
lines changed

License.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ http://www.eclipse.org/legal/epl-v10.html
3737

3838
==============================================================
3939

40-
libsgx_le.signed.so, libsgx_pce.signed.so, libsgx_pve.signed.so, libsgx_qe.signed.so, libsgx_pse_pr.signed.so and libsgx_pse_op.signed.so are licensed as Intel redistributable binary firmware and other blobs.
40+
libsgx_le.signed.so, libsgx_pce.signed.so, libsgx_pve.signed.so, libsgx_qe.signed.so, libsgx_pse_pr.signed.so, libsgx_pse_pr_2.signed.so and libsgx_pse_op.signed.so are licensed as Intel redistributable binary firmware and other blobs.
4141

4242

4343
Copyright (c) Intel Corporation.

Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<EnclaveConfiguration>
22
<ProdID>0</ProdID>
33
<ISVSVN>0</ISVSVN>
4-
<StackMinSize>0x1000</StackMinSize>
4+
<StackMinSize>0x2000</StackMinSize>
55
<StackMaxSize>0x40000</StackMaxSize>
66
<HeapMinSize>0x1000</HeapMinSize>
77
<HeapInitSize>0x1000000</HeapInitSize>

Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -124,74 +124,21 @@ void print_error_message(sgx_status_t ret)
124124
}
125125

126126
/* Initialize the enclave:
127-
* Step 1: retrive the launch token saved by last transaction
128-
* Step 2: call sgx_create_enclave to initialize an enclave instance
129-
* Step 3: save the launch token if it is updated
127+
* Call sgx_create_enclave to initialize an enclave instance
130128
*/
131129
int initialize_enclave(void)
132130
{
133-
char token_path[MAX_PATH] = {'\0'};
134-
sgx_launch_token_t token = {0};
135131
sgx_status_t ret = SGX_ERROR_UNEXPECTED;
136-
int updated = 0;
137-
/* Step 1: retrive the launch token saved by last transaction */
138-
139-
/* try to get the token saved in $HOME */
140-
const char *home_dir = getpwuid(getuid())->pw_dir;
141-
if (home_dir != NULL &&
142-
(strlen(home_dir)+strlen("/")+sizeof(TOKEN_FILENAME)+1) <= MAX_PATH) {
143-
/* compose the token path */
144-
strncpy(token_path, home_dir, strlen(home_dir));
145-
strncat(token_path, "/", strlen("/"));
146-
strncat(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME)+1);
147-
} else {
148-
/* if token path is too long or $HOME is NULL */
149-
strncpy(token_path, TOKEN_FILENAME, sizeof(TOKEN_FILENAME));
150-
}
151-
152-
FILE *fp = fopen(token_path, "rb");
153-
if (fp == NULL && (fp = fopen(token_path, "wb")) == NULL) {
154-
printf("Warning: Failed to create/open the launch token file \"%s\".\n", token_path);
155-
}
156-
printf("token_path: %s\n", token_path);
157-
if (fp != NULL) {
158-
/* read the token from saved file */
159-
size_t read_num = fread(token, 1, sizeof(sgx_launch_token_t), fp);
160-
if (read_num != 0 && read_num != sizeof(sgx_launch_token_t)) {
161-
/* if token is invalid, clear the buffer */
162-
memset(&token, 0x0, sizeof(sgx_launch_token_t));
163-
printf("Warning: Invalid launch token read from \"%s\".\n", token_path);
164-
}
165-
}
166132

167-
/* Step 2: call sgx_create_enclave to initialize an enclave instance */
133+
/* Call sgx_create_enclave to initialize an enclave instance */
168134
/* Debug Support: set 2nd parameter to 1 */
169-
170-
ret = sgx_create_enclave($(ENCLAVENAME)_FILENAME, SGX_DEBUG_FLAG, &token, &updated, &global_eid, NULL);
135+
ret = sgx_create_enclave($(ENCLAVENAME)_FILENAME, SGX_DEBUG_FLAG, NULL, NULL, &global_eid, NULL);
171136

172137
if (ret != SGX_SUCCESS) {
173138
print_error_message(ret);
174-
if (fp != NULL) fclose(fp);
175-
176139
return -1;
177140
}
178141

179-
/* Step 3: save the launch token if it is updated */
180-
181-
if (updated == FALSE || fp == NULL) {
182-
/* if the token is not updated, or file handler is invalid, do not perform saving */
183-
if (fp != NULL) fclose(fp);
184-
return 0;
185-
}
186-
187-
/* reopen the file with write capablity */
188-
fp = freopen(token_path, "wb", fp);
189-
if (fp == NULL) return 0;
190-
size_t write_num = fwrite(token, 1, sizeof(sgx_launch_token_t), fp);
191-
if (write_num != sizeof(sgx_launch_token_t))
192-
printf("Warning: Failed to save launch token to \"%s\".\n", token_path);
193-
fclose(fp);
194-
195142
return 0;
196143
}
197144

Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#endif
1919

2020

21-
# define TOKEN_FILENAME "enclave.token"
2221
# define $(ENCLAVENAME)_FILENAME "$(enclaveName).signed.so"
2322

2423
extern sgx_enclave_id_t global_eid; /* global enclave id */

Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c++/sgx_t_static.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ lib$(enclaveName).sgx.static.lib.a: $(TRUSTED_DIR)/$(enclaveName)_t.h $($(Enclav
103103
@echo "LINK => $@"
104104

105105
clean:
106-
@rm -f $(enclaveName).* $(TRUSTED_DIR)/$(enclaveName)_t.* $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects)
106+
@rm -f lib$(enclaveName).* $(TRUSTED_DIR)/$(enclaveName)_t.* $($(EnclaveName)_Cpp_Objects) $($(EnclaveName)_C_Objects)

Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXTrustedStaticLibrary/makefiles/c/sgx_t_static.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ lib$(enclaveName).sgx.static.lib.a: $(TRUSTED_DIR)/$(enclaveName)_t.h $($(Enclav
9393
@echo "LINK => $@"
9494

9595
clean:
96-
@rm -f $(enclaveName).* $(TRUSTED_DIR)/$(enclaveName)_t.* $($(EnclaveName)_C_Objects)
96+
@rm -f lib$(enclaveName).* $(TRUSTED_DIR)/$(enclaveName)_t.* $($(EnclaveName)_C_Objects)

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,19 @@ sdk_install_pkg: sdk
4747
psw_install_pkg: psw
4848
./linux/installer/bin/build-installpkg.sh psw
4949

50+
deb_sgx_urts_pkg: psw
51+
./linux/installer/deb/libsgx-urts/build.sh
52+
5053
deb_sgx_enclave_common_pkg: psw
5154
./linux/installer/deb/libsgx-enclave-common/build.sh
5255

5356
deb_sgx_enclave_common_dev_pkg:
5457
./linux/installer/deb/libsgx-enclave-common-dev/build.sh
5558

59+
deb_pkg: deb_sgx_urts_pkg deb_sgx_enclave_common_pkg deb_sgx_enclave_common_dev_pkg
60+
@$(RM) -f ./linux/installer/deb/*.deb ./linux/installer/deb/*.ddeb
61+
cp `find ./linux/installer/deb/ -name "*.deb" -o -name "*.ddeb"` ./linux/installer/deb/
62+
5663
clean:
5764
@$(MAKE) -C sdk/ clean
5865
@$(MAKE) -C psw/ clean

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,16 @@ $ make sdk_install_pkg DEBUG=1
135135
To build the Intel(R) SGX PSW installer, enter the following command:
136136
- On Ubuntu 16.04 and Ubuntu 18.04:
137137
```
138-
$ make deb_sgx_enclave_common_pkg
138+
$ make deb_pkg
139139
```
140-
You can find the generated Intel(R) SGX PSW installer ``libsgx-enclave-common_${version}-${revision}_amd64.deb`` located under `linux/installer/deb/libsgx-enclave-common`, where `${version}` refers to the version number and the `${revision}` refers to the revision number of the package.
140+
You can find the generated Intel(R) SGX PSW installer ``libsgx-urts_${version}-${revision}_amd64.deb`` and ``libsgx-enclave-common_${version}-${revision}_amd64.deb`` located under `linux/installer/deb`, where `${version}` refers to the version number and the `${revision}` refers to the revision number of the package.
141141
**Note**: On Ubuntu 18.04, besides the Intel(R) SGX PSW installer, the above command generates another debug symbol package named ``libsgx-enclave-common-dbgsym_${version}-${revision}_amd64.ddeb`` for debug purpose. On Ubuntu 16.04, if you want to keep debug symbols in the Intel(R) SGX PSW installer, before building the Intel(R) SGX PSW, you need to export an environment variable to ensure the debug symbols not stripped:
142142
```
143143
$ export DEB_BUILD_OPTIONS="nostrip"
144144
```
145145
**Note**: The above command builds the Intel(R) SGX PSW with default configuration firstly and then generates the target PSW Installer. To build the Intel(R) SGX PSW Installer without optimization and with full debug information kept in the tools and libraries, enter the following command:
146146
```
147-
$ make deb_sgx_enclave_common_pkg DEBUG=1
147+
$ make deb_pkg DEBUG=1
148148
```
149149
- On Red Hat Enterprise Linux 7.4 and CentOS 7.5:
150150
- On Fedora 27:
@@ -158,7 +158,7 @@ To build the Intel(R) SGX PSW installer, enter the following command:
158158
```
159159
$ make psw_install_pkg DEBUG=1
160160
```
161-
To build the Intel(R) SGX PSW development installer, enter the following command:
161+
To build the Intel(R) SGX PSW development installer separately, enter the following command:
162162
- On Ubuntu 16.04 and Ubuntu 18.04:
163163
```
164164
$ make deb_sgx_enclave_common_dev_pkg
@@ -279,30 +279,30 @@ Install the Intel(R) SGX PSW
279279
Download source code from [dynamic-application-loader-host-interface](https://github.com/01org/dynamic-application-loader-host-interface) project. In the source code folder, build and install the `JHI` service using the following commands:
280280
* On Ubuntu 16.04 and Ubuntu 18.04:
281281
```
282-
$ sudo apt-get install uuid-dev libxml2-dev cmake pkg-config
282+
$ sudo apt-get install uuid-dev libxml2-dev cmake pkg-config libsystemd-dev
283283
$ cmake .;make;sudo make install;sudo systemctl enable jhi
284284
```
285285
* On Red Hat Enterprise Linux 7.4, CentOS 7.5 and Fedora 27:
286286
```
287-
$ sudo yum install libuuid-devel libxml2-devel cmake pkgconfig
287+
$ sudo yum install libuuid-devel libxml2-devel cmake pkgconfig systemd-devel
288288
$ cmake .;make;sudo make install;sudo ldconfig;sudo systemctl enable jhi
289289
```
290290
* On SUSE Linux Enterprise Server 12:
291291
```
292-
$ sudo zypper install libuuid-devel libxml2-devel cmake pkg-config
292+
$ sudo zypper install libuuid-devel libxml2-devel cmake pkg-config systemd-devel
293293
$ cmake .;make;sudo make install;sudo ldconfig;sudo systemctl enable jhi
294294
```
295295

296296
### Install the Intel(R) SGX PSW
297297
To install the Intel(R) SGX PSW, invoke the installer with root privilege:
298298
- On Ubuntu 16.04 and Ubuntu 18.04:
299299
```
300-
$ cd linux/installer/deb/libsgx-enclave-common
301-
$ sudo dpkg -i ./libsgx-enclave-common_${version}-${revision}_amd64.deb
300+
$ cd linux/installer/deb
301+
$ sudo dpkg -i ./libsgx-urts_${version}-${revision}_amd64.deb ./libsgx-enclave-common_${version}-${revision}_amd64.deb
302302
```
303303
**NOTE**: To debug with sgx-gdb on Ubuntu 16.04, you need to ensure the Intel(R) SGX PSW is built under the condition that the environment variable ``DEB_BUILD_OPTIONS="nostrip"`` is set. On Ubuntu 18.04, you need to install the debug package by entering the following command:
304304
```
305-
$ cd linux/installer/deb/libsgx-enclave-common
305+
$ cd linux/installer/deb
306306
$ sudo dpkg -i ./libsgx-enclave-common-dbgsym_${version}-${revision}_amd64.ddeb
307307
```
308308
- On Red Hat Enterprise Linux 7.4 and CentOS 7.5:

SampleCode/Cxx11SGXDemo/App/App.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,11 @@ void print_error_message(sgx_status_t ret)
159159
*/
160160
int initialize_enclave(void)
161161
{
162-
sgx_launch_token_t token = {0};
163162
sgx_status_t ret = SGX_ERROR_UNEXPECTED;
164-
int updated = 0;
165163

166164
/* Call sgx_create_enclave to initialize an enclave instance */
167165
/* Debug Support: set 2nd parameter to 1 */
168-
ret = sgx_create_enclave(ENCLAVE_FILENAME, SGX_DEBUG_FLAG, &token, &updated, &global_eid, NULL);
166+
ret = sgx_create_enclave(ENCLAVE_FILENAME, SGX_DEBUG_FLAG, NULL, NULL, &global_eid, NULL);
169167
if (ret != SGX_SUCCESS) {
170168
print_error_message(ret);
171169
return -1;

SampleCode/Cxx11SGXDemo/Makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,20 @@ endif
178178
endif
179179

180180

181-
.PHONY: all run
181+
.PHONY: all run target
182+
all: .config_$(Build_Mode)_$(SGX_ARCH)
183+
@$(MAKE) target
182184

183185
ifeq ($(Build_Mode), HW_RELEASE)
184-
all: .config_$(Build_Mode)_$(SGX_ARCH) $(App_Name) $(Enclave_Name)
186+
target: $(App_Name) $(Enclave_Name)
185187
@echo "The project has been built in release hardware mode."
186188
@echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave."
187189
@echo "To sign the enclave use the command:"
188190
@echo " $(SGX_ENCLAVE_SIGNER) sign -key <your key> -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)"
189191
@echo "You can also sign the enclave using an external signing tool."
190192
@echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW."
191193
else
192-
all: .config_$(Build_Mode)_$(SGX_ARCH) $(App_Name) $(Signed_Enclave_Name)
194+
target: $(App_Name) $(Signed_Enclave_Name)
193195
ifeq ($(Build_Mode), HW_DEBUG)
194196
@echo "The project has been built in debug hardware mode."
195197
else ifeq ($(Build_Mode), SIM_DEBUG)
@@ -209,34 +211,38 @@ ifneq ($(Build_Mode), HW_RELEASE)
209211
@echo "RUN => $(App_Name) [$(SGX_MODE)|$(SGX_ARCH), OK]"
210212
endif
211213

214+
.config_$(Build_Mode)_$(SGX_ARCH):
215+
@rm -f .config_* $(App_Name) $(Enclave_Name) $(Signed_Enclave_Name) $(App_Cpp_Objects) App/Enclave_u.* $(Enclave_Cpp_Objects) Enclave/Enclave_t.*
216+
@touch .config_$(Build_Mode)_$(SGX_ARCH)
217+
212218
######## App Objects ########
213219

214-
App/Enclave_u.c: $(SGX_EDGER8R) Enclave/Enclave.edl
220+
App/Enclave_u.h: $(SGX_EDGER8R) Enclave/Enclave.edl
215221
@cd App && $(SGX_EDGER8R) --untrusted ../Enclave/Enclave.edl --search-path ../Enclave --search-path $(SGX_SDK)/include
216222
@echo "GEN => $@"
217223

224+
App/Enclave_u.c: App/Enclave_u.h
225+
218226
App/Enclave_u.o: App/Enclave_u.c
219227
@$(CC) $(SGX_COMMON_CFLAGS) $(App_C_Flags) -c $< -o $@
220228
@echo "CC <= $<"
221229

222-
App/%.o: App/%.cpp
230+
App/%.o: App/%.cpp App/Enclave_u.h
223231
@$(CXX) $(SGX_COMMON_CXXFLAGS) $(App_Cpp_Flags) -c $< -o $@
224232
@echo "CXX <= $<"
225233

226234
$(App_Name): App/Enclave_u.o $(App_Cpp_Objects)
227235
@$(CXX) $^ -o $@ $(App_Link_Flags)
228236
@echo "LINK => $@"
229237

230-
.config_$(Build_Mode)_$(SGX_ARCH):
231-
@rm -f .config_* $(App_Name) $(Enclave_Name) $(Signed_Enclave_Name) $(App_Cpp_Objects) App/Enclave_u.* $(Enclave_Cpp_Objects) Enclave/Enclave_t.*
232-
@touch .config_$(Build_Mode)_$(SGX_ARCH)
233-
234238
######## Enclave Objects ########
235239

236-
Enclave/Enclave_t.c: $(SGX_EDGER8R) Enclave/Enclave.edl
240+
Enclave/Enclave_t.h: $(SGX_EDGER8R) Enclave/Enclave.edl
237241
@cd Enclave && $(SGX_EDGER8R) --trusted ../Enclave/Enclave.edl --search-path ../Enclave --search-path $(SGX_SDK)/include
238242
@echo "GEN => $@"
239243

244+
Enclave/Enclave_t.c: Enclave/Enclave_t.h
245+
240246
Enclave/Enclave_t.o: Enclave/Enclave_t.c
241247
@$(CC) $(SGX_COMMON_CFLAGS) $(Enclave_C_Flags) -c $< -o $@
242248
@echo "CC <= $<"
@@ -245,6 +251,8 @@ Enclave/%.o: Enclave/%.cpp
245251
@$(CXX) $(SGX_COMMON_CXXFLAGS) $(Enclave_Cpp_Flags) -c $< -o $@
246252
@echo "CXX <= $<"
247253

254+
$(Enclave_Cpp_Objects): Enclave/Enclave_t.h
255+
248256
$(Enclave_Name): Enclave/Enclave_t.o $(Enclave_Cpp_Objects)
249257
@$(CXX) $^ -o $@ $(Enclave_Link_Flags)
250258
@echo "LINK => $@"

0 commit comments

Comments
 (0)