Skip to content

Commit 070657f

Browse files
authored
Upgrade to OpenSSL 3.0.17
Upgrade the SGX-SSL library to utilize OpenSSL 3.0.17 while leaving OpenSSL 3.1.6 to provide FIPS support. Signed-off-by: Juan del Cuvillo <juan.b.del.cuvillo@intel.com>
1 parent 1f99dd7 commit 070657f

File tree

11 files changed

+87
-181
lines changed

11 files changed

+87
-181
lines changed

.github/workflows/c-cpp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2323
- name: download SDK
24-
run: wget https://download.01.org/intel-sgx/sgx-linux/2.24/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.24.100.3.bin
24+
run: wget https://download.01.org/intel-sgx/sgx-linux/2.26/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.26.100.0.bin
2525
- name: install SDK
2626
run: chmod +x *.bin; echo yes | ./sgx_linux_x64_sdk_2.*.bin
2727
- name: download OpenSSL code
28-
run: wget https://www.openssl.org/source/openssl-3.1.6.tar.gz --directory-prefix=openssl_source/
28+
run: wget https://www.openssl.org/source/openssl-3.0.17.tar.gz --directory-prefix=openssl_source/
2929
- name: build SGXSSL
3030
run: source sgxsdk/environment; cd Linux; make all; DEBUG=1 make all
3131
- name: run unit test in SIM

.github/workflows/codeql.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ jobs:
6767

6868
- run: |
6969
echo "Run, Build Application using script"
70-
wget https://download.01.org/intel-sgx/sgx-linux/2.24/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.24.100.3.bin;
70+
wget https://download.01.org/intel-sgx/sgx-linux/2.26/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.26.100.0.bin;
7171
chmod +x *.bin; echo yes | ./sgx_linux_x64_sdk_2.*.bin;
72-
wget https://www.openssl.org/source/openssl-3.1.6.tar.gz --directory-prefix=openssl_source/;
72+
wget https://www.openssl.org/source/openssl-3.0.17.tar.gz --directory-prefix=openssl_source/;
73+
wget https://www.openssl.org/source/openssl-3.1.6.tar.gz --directory-prefix=openssl_source/;
7374
source sgxsdk/environment; cd Linux; make sgxssl_no_mitigation
7475
7576
- name: Perform CodeQL Analysis

Linux/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
include buildenv.mk
3232
include sgx/buildenv.mk
3333
LINUX_SGX_BUILD ?= 0
34+
FIPS ?= 0
3435
EMPTY_SRC = check_lvi_toolset
3536
.PHONY: sgxssl sgxssl_no_mitigation clean install uninstall
3637

Linux/build_openssl.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
SGXSSL_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3737
echo $SGXSSL_ROOT
3838

39-
OPENSSL_VERSION=`ls $SGXSSL_ROOT/../openssl_source/*3.1.*.tar.gz | head -1 | grep -o '[^/]*$' | sed -s -- 's/\.tar\.gz//'`
40-
if [ "$OPENSSL_VERSION" == "" ]
39+
OPENSSL_VERSION=`ls $SGXSSL_ROOT/../openssl_source/*3.0.*.tar.gz | head -1 | grep -o '[^/]*$' | sed -s -- 's/\.tar\.gz//'`
40+
if [ "$OPENSSL_VERSION" == "" ]
4141
then
42-
echo "In order to run this script, OpenSSL tar.gz package must be located in openssl_source/ directory."
42+
echo "In order to run this script, the OpenSSL tar.gz package must be located in the openssl_source/ directory."
4343
exit 1
4444
fi
4545
echo $OPENSSL_VERSION

Linux/sgx/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ ifneq ($(CRYPTO_ONLY), 1)
6464

6565
ifeq ($(LINUX_SGX_BUILD), 0)
6666
ifneq ($(NO_THREADS), 1)
67-
# Don't build the test app by default in FIPS mode since it depends on
68-
# the FIPS provider.
69-
# Execute the install target first.
67+
# Don't build the test app in FIPS mode since it depends on the FIPS provider,
68+
# which is not ready yet.
7069
ifneq ($(FIPS), 1)
7170
$(MAKE) -C $(TEST_DIR) all
7271
endif

Linux/sgx/libsgx_tsgxssl/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ endif
8787
endif
8888

8989
ifeq ($(FIPS), 1)
90-
SGXSSL_ADDTIONAL_EDL_PATH=$(PACKAGE_INC)/filefunc
90+
SGXSSL_ADDITIONAL_EDL_PATH=$(PACKAGE_INC)/filefunc
9191
else
92-
SGXSSL_ADDTIONAL_EDL_PATH=$(PACKAGE_INC)/nofilefunc
92+
SGXSSL_ADDITIONAL_EDL_PATH=$(PACKAGE_INC)/nofilefunc
9393
endif
9494

9595
SGX_EDL_FILE := $(PACKAGE_INC)/sgx_tsgxssl.edl
@@ -122,27 +122,27 @@ $(shell mkdir -p $(OBJDIR))
122122
all: $(TRUSTED_LIB)
123123

124124
######## sgx_tsgxssl Objects ########
125-
sgx_tsgxssl_t.c: $(SGX_EDGER8R) $(SGX_EDL_FILE)
126-
$(SGX_EDGER8R) --header-only --trusted $(SGX_EDL_FILE) --search-path $(SGX_SDK_INC) --search-path $(SGXSSL_ADDTIONAL_EDL_PATH)
125+
sgx_tsgxssl_t.h: $(SGX_EDGER8R) $(SGX_EDL_FILE)
126+
$(SGX_EDGER8R) --header-only --trusted $(SGX_EDL_FILE) --search-path $(SGX_SDK_INC) --search-path $(SGXSSL_ADDITIONAL_EDL_PATH)
127127
@echo "GEN => $@"
128128

129129
sgx_tsgxssl_t.o: sgx_tsgxssl_t.c
130130
$(VCC) $(Sgx_tssl_C_Flags) -c $< -o $@
131131
@echo "CC <= $<"
132132

133-
$(OBJDIR)/%.o : %.cpp sgx_tsgxssl_t.c
133+
$(OBJDIR)/%.o : %.cpp sgx_tsgxssl_t.h
134134
$(VCXX) $(Sgx_tssl_Cpp_Flags) -c $< -o $@
135135
@echo "CXX <= $<"
136136

137-
$(OBJDIR)/%.o : %.c sgx_tsgxssl_t.c
137+
$(OBJDIR)/%.o : %.c sgx_tsgxssl_t.h
138138
$(VCC) $(Sgx_tssl_C_Flags) -c $< -o $@
139139
@echo "CC <= $<"
140140

141141
$(OBJDIR)/%.o : %.S
142142
$(VCC) $(Common_C_Cpp_Flags) -c $< -o $@
143143
@echo "CC <= $<"
144144

145-
$(TRUSTED_LIB): sgx_tsgxssl_t.c $(Sgx_tssl_Cpp_Objects) $(Sgx_tssl_C_Objects) $(Sgx_tssl_S_Objects)
145+
$(TRUSTED_LIB): sgx_tsgxssl_t.h $(Sgx_tssl_Cpp_Objects) $(Sgx_tssl_C_Objects) $(Sgx_tssl_S_Objects)
146146
ar rcs $(TRUSTED_LIB) $(Sgx_tssl_Cpp_Objects) $(Sgx_tssl_C_Objects) $(Sgx_tssl_S_Objects)
147147
@echo "LINK => $@"
148148
@cp $@ $(PACKAGE_LIB)/$(TRUSTED_LIB)

Linux/sgx/libsgx_tsgxssl/texceptions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sgx_trts_exception.h>
3434
#include <sgx_cpuid.h>
3535
#include <stdlib.h>
36+
#include <string.h>
3637

3738
#include "tcommon.h"
3839

README.md

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/intel/intel-sgx-ssl/badge)](https://securityscorecards.dev/viewer/?uri=github.com/intel/intel-sgx-ssl)
22

3-
Intel® Software Guard Extensions SSL
3+
Intel® Software Guard Extensions SSL (SGX SSL)
44
================================================
55

66
Introduction
77
------------
88
The Intel® Software Guard Extensions SSL (Intel® SGX SSL) cryptographic library is intended to provide cryptographic services for Intel® Software Guard Extensions (SGX) enclave applications.
99
The Intel® SGX SSL cryptographic library is based on the underlying OpenSSL* Open Source project, providing a full-strength general purpose cryptography library.
1010

11-
This branch supports OpenSSL version 3.1.*, but works in 1.1.1 compatible mode.
11+
This branch supports the OpenSSL 3.0 series, but works in 1.1.1 compatible mode.
1212

1313
License
1414
-------
@@ -22,10 +22,11 @@ Documentation
2222
* [Windows developer guide](Windows/package/docs/Intel(R)%20Software%20Guard%20Extensions%20SSL%20Library%20Windows%20Developer%20Guide.pdf)
2323

2424

25-
Build Intel® SGX SSL package
26-
----------------------------
27-
Windows
28-
----------------------------
25+
Building the Intel® SGX SSL package
26+
-----------------------------------
27+
28+
## Windows
29+
2930
### Prerequisites
3031
- Microsoft Visual Studio 2019
3132
- Perl
@@ -34,53 +35,72 @@ Windows
3435

3536
(Note: Perl, NASM need to be included in machine's PATH variable)
3637

37-
To build Intel® SGX SSL package in Windows OS:
38-
1. Download OpenSSL package into openssl_source/ directory. (tar.gz package, e.g. openssl-3.1.*.tar.gz)
39-
2. Download and install latest SGX SDK from [Intel Developer Zone](https://software.intel.com/en-us/sgx-sdk/download). You can find installation guide from the same website.
38+
### Building
39+
40+
To build the Intel® SGX SSL package in Windows OS:
41+
1. Download the OpenSSL package into the openssl_source/ directory. (tar.gz package, e.g. openssl-3.0.*.tar.gz)
42+
2. Download and install the latest SGX SDK from [Intel Developer Zone](https://software.intel.com/en-us/sgx-sdk/download). You can find the installation guide in the same website.
4043
3. Change the directory to the SGXSSL path and enter the following command:
4144
```
42-
build_all.cmd <OPENSSL_VERSION> [default == openssl-3.1.0]
45+
build_all.cmd <OPENSSL_VERSION> [default == openssl-3.0.17]
4346
```
44-
This will build the Intel® SGX SSL libraries (libsgx_tsgxssl.lib, libsgx_usgxssl.lib, libsgx_tsgxssl_crypto.lib), which can be found in package/lib/{Win32|X64}/{debug|release}/. And the version with CVE-2020-0551 Mitigation enabled can be found in package/lib/X64/{CVE-2020-0551-CF-Release|CVE-2020-0551-Load-Release}/.
47+
This builds the Intel® SGX SSL libraries (libsgx_tsgxssl.lib, libsgx_usgxssl.lib, libsgx_tsgxssl_crypto.lib) that can be found in package/lib/{Win32|X64}/{debug|release}/. The version with CVE-2020-0551 mitigation enabled can be found in package/lib/X64/{CVE-2020-0551-CF-Release|CVE-2020-0551-Load-Release}/.
48+
49+
## Linux
4550

46-
Linux
47-
----------------------------
4851
### Prerequisites
4952
- Perl
5053
- Toolchain with mitigation (refer to [SGX Linux README](https://github.com/intel/linux-sgx/blob/master/README.md))
51-
- Intel(R) SGX Linux latest release, including SDK, PSW, and driver
54+
- Intel(R) SGX Linux latest release, including SDK and PSW.
5255

53-
To build Intel® SGX SSL package in Linux OS:
54-
=======
55-
1. Download OpenSSL 3.1.* package into openssl_source/ directory. (tar.gz package, e.g. openssl-3.1.*.tar.gz)
56-
2. Download and install latest SGX SDK from [01.org](https://download.01.org/intel-sgx/latest/). You can find the installation guide in the same website.
56+
### Building
57+
58+
To build the Intel® SGX SSL package in Linux OS:
59+
1. Download the OpenSSL 3.0.* package into openssl_source/ directory. (tar.gz package, e.g. openssl-3.0.*.tar.gz)
60+
2. Download and install the latest SGX SDK from [01.org](https://download.01.org/intel-sgx/latest/). You can find the installation guide in the same website.
5761
3. Source SGX SDK's environment variables.
58-
4. Cd to Linux/ directory and run:
62+
4. Change into the Linux/ directory and run:
5963
```
6064
make all test
6165
```
62-
This will build and test the Intel® SGX SSL libraries (libsgx_tsgxssl.a, libsgx_usgxssl.a, libsgx_tsgxssl_crypto.a), which can be found in package/lib64/. And the Intel® SGX SSL trusted libraries (libsgx_tsgxssl.lib, libsgx_tsgxssl_crypto.lib) with CVE-2020-0551 Mitigation enabled can be found in package/lib64/{cve_2020_0551_cf|cve_2020_0551_load}/.
66+
This builds and tests the Intel® SGX SSL libraries (libsgx_tsgxssl.a, libsgx_usgxssl.a, libsgx_tsgxssl_crypto.a), which can be found in package/lib64/. The Intel® SGX SSL trusted libraries (libsgx_tsgxssl.lib, libsgx_tsgxssl_crypto.lib) with CVE-2020-0551 mitigation enabled can be found in package/lib64/{cve_2020_0551_cf|cve_2020_0551_load}/.
6367

6468
### Available `make` flags:
6569
- DEBUG={1,0}: Libraries build mode, with debug symbols or without. Default ``0``.
6670
- NO_THREADS={1,0}: Enable ``no-threads`` in the OpenSSL's build configuration options. Default ``0``.
6771
- SGX_MODE={HW,SIM}: User can take ``SIM`` to run the unit test on non-SGX platform if necessary. Default ``HW``.
6872
- DESTDIR=\<PATH\>: Directory realpath to install Intel® SGX SSL libraries in. Default ``/opt/intel/sgxssl/``.
6973
- VERBOSE={1,0}: Makefile verbose mode. Print compilation commands before executing it. Default ``0``.
70-
- OSSL3ONLY={1,0}: USE only OpenSSL 3.x APIs, and legacy functions will not be valid. Default ``0``.
74+
- OSSL3ONLY={1,0}: Use only OpenSSL 3.x APIs, and legacy functions will not be valid. Default ``0``.
75+
- FIPS={1,0}: Use the OpenSSL FIPS provider as an experimental feature. Default ``0``.
7176

7277
To install Intel® SGX SSL libraries in Linux OS, run:
7378
```
7479
make all test
7580
sudo make install
7681
```
7782

78-
Note for Version 3.*
79-
--------------------
80-
To use the trusted cryptography library with SGX SSL/OpenSSL 3.*, it possibly needs to increase the value in the enclave signing configuration XML file:
83+
## Note for Version 3.*
84+
85+
To use the trusted cryptography library with SGX SSL/OpenSSL 3.*, especially for the multithreaded enclaves, you may need to increase the enclave heap size adjusting the enclave signing configuration XML file:
8186
```
8287
...
8388
<HeapMaxSize>...</HeapMaxSize>
8489
...
8590
```
86-
, especially for the enclave with multithreads.
91+
92+
## OpenSSL FIPS Provider
93+
94+
As an experimental feature, the SGX SDK supports building the SGX SSL library using the OpenSSL FIPS provider, instead of the default provider. Note: This feature is only supported on Linux and OpenSSL 3.1.6. You must download two separate OpenSSL packages: one from the OpenSSL 3.0 series and one for OpenSSL 3.1.6.
95+
To build and install the Intel® SGX SSL package and the OpenSSL FIPS provider run:
96+
97+
```
98+
make all FIPS=1
99+
sudo make install
100+
```
101+
102+
You may build and run one or both test programs that utilize the FIPS provider. The `FIPS=1` option must be specified; otherwise, a linker error will occur.
103+
```
104+
make test FIPS=1
105+
make fips_test FIPS=1
106+
```

openssl_source/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ fips:
6262
mkdir -p $(OSSL_FIPS_INSTALL_DIR)
6363
mkdir -p $(OSSL_FIPS_BUILD_DIR)
6464
tar xvf $(OPENSSL_VERSION).tar.gz -C $(OSSL_FIPS_SOURCE_DIR) --strip-components=1 > /dev/null
65-
cd $(OSSL_FIPS_BUILD_DIR) && $(OSSL_FIPS_SOURCE_DIR)/Configure enable-fips --prefix=$(OSSL_FIPS_INSTALL_DIR) && \
65+
cd $(OSSL_FIPS_BUILD_DIR) && $(OSSL_FIPS_SOURCE_DIR)/Configure enable-fips --with-rand-seed=rdcpu --prefix=$(OSSL_FIPS_INSTALL_DIR) && \
6666
$(MAKE) -j$(shell getconf _NPROCESSORS_ONLN) && $(MAKE) install_fips
6767

6868
# Install the FIPS provider and its configuration file in the SGX SDK location
6969
install:
70-
ifeq ($(OSSL_FIPS_INSTALL_DIR_SET), 0)
71-
$(error "Missing directory : $(OSSL_FIPS_INSTALL_DIR). Have you built the FIPS module yet?")
72-
endif
70+
ifeq ($(OSSL_FIPS_INSTALL_DIR_SET), 1)
7371
@echo "*** Installing FIPS module"
7472
@echo "install $(FIPSMODULE) -> $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULE)"
7573
cp -f $(OSSL_FIPS_INSTALL_DIR)/$(LIBDIR)/ossl-modules/$(FIPSMODULE) $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULE).new
@@ -80,7 +78,8 @@ endif
8078
@echo "install $(FIPSMODULECONF) -> $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)"
8179
echo "module-filename = $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULE)" >> $(OSSL_FIPS_INSTALL_DIR)/ssl/$(FIPSMODULECONF)
8280
cp -f $(OSSL_FIPS_INSTALL_DIR)/ssl/$(FIPSMODULECONF) $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)
83-
chmod 744 $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)
81+
chmod 644 $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)
82+
endif
8483

8584
# Remove the FIPS provider and configuration file from the SGX SDK location
8685
uninstall:
@@ -90,7 +89,7 @@ uninstall:
9089

9190
@echo "*** Uninstalling FIPS module configuration"
9291
@echo "uninstall $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)"
93-
rm -rf $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)
92+
rm -f $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)
9493

9594
clean:
9695
ifeq ($(OSSL_FIPS_BUILD_DIR_SET), 1)

openssl_source/o_fopen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# endif
2626
# endif
2727

28-
#include "internal/e_os.h"
28+
#include "e_os.h"
2929
#include "internal/cryptlib.h"
3030

3131
#if !defined(OPENSSL_NO_STDIO)

0 commit comments

Comments
 (0)