Skip to content

Commit 4b83850

Browse files
committed
Generate an OpenSSL configuration file at build time.
Both sample apps include a template from which an OpenSSL configuration file is be generated rather than copying one from the SGX SDK. Signed-off-by: Juan del Cuvillo <[email protected]>
1 parent c0b43e4 commit 4b83850

File tree

4 files changed

+75
-8
lines changed

4 files changed

+75
-8
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# OpenSSL example configuration file.
3+
# See https://docs.openssl.org/master/man5/config/ for more info.
4+
#
5+
# This is mostly being used for explicitly activating the FIPS
6+
# provider so the default provider is not activated implicitly.
7+
#
8+
9+
config_diagnostics = 1
10+
openssl_conf = openssl_init
11+
12+
[openssl_init]
13+
providers = provider_sect
14+
alg_section = algorithm_sect
15+
16+
[provider_sect]
17+
fips = fips_sect
18+
base = base_sect
19+
20+
[base_sect]
21+
activate = 1
22+
23+
[algorithm_sect]
24+
default_properties = fips=yes
25+

Linux/sgx/fips_test/sgx_t.mk

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ifeq ($(DEBUG), 1)
6363
endif
6464
endif
6565

66-
# Added to build with SgxSSL library
66+
# Added to build with the SGX-SSL library
6767
OPENSSL_LIBRARY_PATH := $(PACKAGE_LIB)/
6868
TSETJMP_LIB := -lsgx_tsetjmp
6969

@@ -88,7 +88,8 @@ else
8888
Trts_Library_Name := sgx_trts
8989
Service_Library_Name := sgx_tservice
9090
endif
91-
# tRTS library that provides the symbol get_fips_sym_addr()
91+
92+
# tRTS library that provides the symbol sgx_get_fips_sym_addr()
9293
SGXSSL_FIPS_TLIB = sgx_ossl_fips
9394

9495
ifeq ($(SGX_MODE), HW)
@@ -130,7 +131,12 @@ Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefau
130131

131132
Enclave_Test_Key := $(ENCLAVE_DIR)/enclave_private.pem
132133

133-
.PHONY: all clean
134+
# OpenSSL configuration file
135+
OPENSSLCONF:=openssl.cnf
136+
FIPSMODULECONF:=fipsmodule.cnf
137+
LIBDIR := lib64
138+
139+
.PHONY: all clean install_conf
134140

135141
all: enclave.signed.so
136142

@@ -161,15 +167,20 @@ enclave.so: $(ENCLAVE_DIR)/enclave_t.o $(Enclave_Cpp_Objects) $(Enclave_C_Object
161167
$(VCXX) $^ -o $@ $(Enclave_Link_Flags)
162168
@echo "LINK => $@"
163169

164-
enclave.signed.so: enclave.so
170+
enclave.signed.so: enclave.so install_conf
165171
ifeq ($(wildcard $(Enclave_Test_Key)),)
166172
@echo "There is no enclave test key <enclave_private.pem>."
167173
@echo "The project will generate a key <enclave_private.pem> for testing."
168174
@openssl genrsa -out $(Enclave_Test_Key) -3 3072
169175
endif
170176
@echo "SIGN => $@"
171177
$(SGX_ENCLAVE_SIGNER) sign -key $(Enclave_Test_Key) -enclave enclave.so -out $@ -config $(ENCLAVE_DIR)/enclave.config.xml
172-
@cp $(SGX_LIBRARY_PATH)/openssl.cnf .
178+
179+
install_conf:
180+
@echo "*** Installing OpenSSL configuration"
181+
@echo "install $(OPENSSLCONF) -> $(SGX_SDK)/$(LIBDIR)/$(OPENSSLCONF)"
182+
@cp -f $(OPENSSLCONF).tmpl $(OPENSSLCONF)
183+
echo ".include $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)" >> $(OPENSSLCONF)
173184

174185
clean:
175186
@rm -f enclave.* $(ENCLAVE_DIR)/enclave_t.* $(Enclave_Cpp_Objects) $(Enclave_C_Objects) $(Enclave_Test_Key)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# OpenSSL example configuration file.
3+
# See https://docs.openssl.org/master/man5/config/ for more info.
4+
#
5+
# This is mostly being used for explicitly activating the FIPS
6+
# provider so the default provider is not activated implicitly.
7+
#
8+
9+
config_diagnostics = 1
10+
openssl_conf = openssl_init
11+
12+
[openssl_init]
13+
providers = provider_sect
14+
alg_section = algorithm_sect
15+
16+
[provider_sect]
17+
fips = fips_sect
18+
base = base_sect
19+
20+
[base_sect]
21+
activate = 1
22+
23+
[algorithm_sect]
24+
default_properties = fips=yes
25+

Linux/sgx/test_app/sgx_t.mk

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $(error Cannot set DEBUG and SGX_PRERELEASE at the same time!!)
7474
endif
7575
endif
7676

77-
# Added to build with SgxSSL libraries
77+
# Added to build with the SGX-SSL library
7878
TSETJMP_LIB := -lsgx_tsetjmp
7979
OPENSSL_LIBRARY_PATH := $(PACKAGE_LIB)/
8080

@@ -130,6 +130,7 @@ SgxSSL_Link_Libraries := -L$(OPENSSL_LIBRARY_PATH) -Wl,--whole-archive -l$(SGXSS
130130
Security_Link_Flags := -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -pie
131131

132132
ifeq ($(FIPS), 1)
133+
# tRTS library that provides the symbol sgx_get_fips_sym_addr()
133134
SGXSSL_FIPS_TLIB = -lsgx_ossl_fips
134135
endif
135136

@@ -145,6 +146,11 @@ TestEnclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nod
145146

146147
Enclave_Test_Key := $(ENCLAVE_DIR)/TestEnclave_private_test.pem
147148

149+
# OpenSSL configuration file
150+
OPENSSLCONF:=openssl.cnf
151+
FIPSMODULECONF:=fipsmodule.cnf
152+
LIBDIR := lib64
153+
148154
.PHONY: all test
149155

150156
all: TestEnclave.signed.so
@@ -193,8 +199,8 @@ endif
193199
@echo "SIGN => $@"
194200
ifeq ($(FIPS), 1)
195201
@$(SGX_ENCLAVE_SIGNER) sign -key $(Enclave_Test_Key) -enclave TestEnclave.so -out $@ -config $(ENCLAVE_DIR)/TestEnclave.fips.config.xml
196-
cp $(SGX_LIBRARY_PATH)/openssl.cnf .
197-
cp $(SGX_LIBRARY_PATH)/fips.so .
202+
@cp -f $(OPENSSLCONF).tmpl $(OPENSSLCONF)
203+
echo ".include $(SGX_SDK)/$(LIBDIR)/$(FIPSMODULECONF)" >> $(OPENSSLCONF)
198204
else
199205
@$(SGX_ENCLAVE_SIGNER) sign -key $(Enclave_Test_Key) -enclave TestEnclave.so -out $@ -config $(ENCLAVE_DIR)/TestEnclave.config.xml
200206
endif

0 commit comments

Comments
 (0)