Skip to content

Commit 8a22317

Browse files
committed
Linux 2.22 Open Source Gold Release
Upgraded to OpenSSL 3.0.10. Added interoperable RA-TLS support which follows CCC design. Enhanced Protect File System performance and added additional dependency `libsgx_pthread.a`. Added the Constant Time instruction Decoder (CTD) into the default AEX-Notify mitigation handler in order to prevent the introduction of any additional subtle sidechannel leakages within the default handler. Added Mistletoe 3 mitigations to the IPP Cryptography Library to the AES-ECB, AESGCM, and AES-CMAC algorithms. These have been incorporated transparently into the `sgx_tcrypto` library. Resigned all Intel® SGX Architecture Enclaves. Upgraded Intel SGX Quote Verification Enclave to integrate OpenSSL/SgxSSL 3.0.10. Added Attestation Library support for Intel(R) TDX Migration TD. Added Rust wrapper for low-level Quote Generation APIs. Enabled `SE_TRACE` log in release binary. Updated Rust QVL wrapper to use native Rust structure for quote verification collateral. Added a limitation in the DCAP QVL to only allow the user to set the QvE load policy once. Fixed bugs. Signed-off-by: Li, Xun <xun.li@intel.com>
1 parent 8be98b1 commit 8a22317

File tree

135 files changed

+3752
-2316
lines changed

Some content is hidden

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

135 files changed

+3752
-2316
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@
2323
[submodule "external/mbedtls/mbedtls_code"]
2424
path = external/mbedtls/mbedtls_code
2525
url = https://github.com/Mbed-TLS/mbedtls.git
26+
[submodule "external/cbor/libcbor"]
27+
path = external/cbor/libcbor
28+
url = https://github.com/PJK/libcbor.git

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ preparation:
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
5656
cd external/protobuf/protobuf_code && git apply ../sgx_protobuf.patch >/dev/null 2>&1 || git apply ../sgx_protobuf.patch --check -R
5757
./external/sgx-emm/create_symlink.sh
58-
@# download prebuilt binaries
58+
cd external/mbedtls/mbedtls_code && git apply ../sgx_mbedtls.patch >/dev/null 2>&1 || git apply ../sgx_mbedtls.patch --check -R
59+
cd external/cbor && cp -r libcbor sgx_libcbor
60+
cd external/cbor/libcbor && git apply ../raw_cbor.patch >/dev/null 2>&1 || git apply ../raw_cbor.patch --check -R
61+
cd external/cbor/sgx_libcbor && git apply ../sgx_cbor.patch >/dev/null 2>&1 || git apply ../sgx_cbor.patch --check -R
5962
./download_prebuilt.sh
6063
./external/dcap_source/QuoteGeneration/download_prebuilt.sh
6164

README.md

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ Introduction
3636
------------
3737
Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for application developers seeking to protect select code and data from disclosure or modification.
3838

39-
The Linux\* Intel(R) SGX software stack is comprised of the Intel(R) SGX driver, the Intel(R) SGX SDK, and the Intel(R) SGX Platform Software (PSW). The Intel(R) SGX SDK and Intel(R) SGX PSW are hosted in the [linux-sgx](https://github.com/01org/linux-sgx) project.
39+
The Linux\* Intel(R) SGX software stack is comprised of the Intel(R) SGX driver, the Intel(R) SGX SDK, and the Intel(R) SGX Platform Software (PSW). The Intel(R) SGX SDK and Intel(R) SGX PSW are hosted in the [linux-sgx](https://github.com/intel/linux-sgx) project.
4040

4141
The [SGXDataCenterAttestationPrimitives](https://github.com/intel/SGXDataCenterAttestationPrimitives/) project maintains an out-of-tree driver for the Linux\* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete. It is used on the platforms with *Flexible Launch Control* and *Intel(R) AES New Instructions* support and could support both Elliptic Curve Digital Signature algorithm (ECDSA) based attestation and Enhanced Privacy Identification (EPID) based attestation.
4242

4343
**Note**: Ice Lake Xeon-SP (and the future Xeon-SP platforms) doesn't support EPID attestation.
4444

45-
The [linux-sgx-driver](https://github.com/01org/linux-sgx-driver) project hosts the other out-of-tree driver for the Linux\* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete. It is used to support Enhanced Privacy Identification (EPID) based attestation on the platforms without *Flexible Launch Control*.
45+
The [linux-sgx-driver](https://github.com/intel/linux-sgx-driver) project hosts the other out-of-tree driver for the Linux\* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete. It is used to support Enhanced Privacy Identification (EPID) based attestation on the platforms without *Flexible Launch Control*.
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

@@ -63,8 +63,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
6363

6464
Documentation
6565
-------------
66-
- [Intel(R) SGX for Linux\* OS](https://01.org/intel-softwareguard-extensions) project home page on [01.org](https://01.org)
67-
- [Intel(R) SGX Programming Reference](https://software.intel.com/sites/default/files/managed/7c/f1/332831-sdm-vol-3d.pdf)
66+
- [Intel(R) SGX for Linux\* OS](https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html) project home page on [Intel Developer Zone](https://www.intel.com/content/www/us/en/developer/overview.html)
67+
- [Intel(R) SGX Programming Reference](https://www.intel.com/content/dam/develop/external/us/en/documents/329298-002-629101.pdf)
6868

6969
Quick Start with Docker and Docker Compose
7070
-----------------------------------------
@@ -82,26 +82,24 @@ $ cd linux/installer/docker && ./build_compose_run.sh
8282
Build and Install the Intel(R) SGX Driver
8383
-----------------------------------------
8484
Follow the [README.md](https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/master/driver/linux/README.md) in the [SGXDataCenterAttestationPrimitives](https://github.com/intel/SGXDataCenterAttestationPrimitives/) project to build and install the Intel(R) SGX driver.
85-
**NOTE**: The above Intel(R) SGX driver requires *Flexible Launch Control* and *Intel(R) AES New Instructions* support. If your platform doesn't meet the requirement, please follow the instructions in the [linux-sgx-driver](https://github.com/01org/linux-sgx-driver) project to build and install this version of Intel(R) SGX driver.
85+
**NOTE**: The above Intel(R) SGX driver requires *Flexible Launch Control* and *Intel(R) AES New Instructions* support. If your platform doesn't meet the requirement, please follow the instructions in the [linux-sgx-driver](https://github.com/intel/linux-sgx-driver) project to build and install this version of Intel(R) SGX driver.
8686

8787
Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
8888
-------------------------------------------------------
8989
### Prerequisites:
9090
- Ensure that you have one of the following required operating systems:
91-
* Ubuntu\* 18.04 LTS Desktop 64bits
92-
* Ubuntu\* 18.04 LTS Server 64bits
9391
* Ubuntu\* 20.04 LTS Desktop 64bits
9492
* Ubuntu\* 20.04 LTS Server 64bits
9593
* Ubuntu\* 22.04 LTS Server 64bits
96-
* Red Hat Enterprise Linux Server release 8.6 64bits
97-
* CentOS Stream 8 64bits
94+
* Red Hat Enterprise Linux Server release 9.2 64bits
95+
* CentOS Stream 9 64bits
9896
* CentOS 8.3 64bits
9997
* SUSE Linux Enterprise Server 15.4 64bits
10098
* Anolis OS 8.6 64bits
10199
* Debian 10 64bits
102100

103101
- Use the following command(s) to install the required tools to build the Intel(R) SGX SDK:
104-
* On Ubuntu 18.04 and Debian 10:
102+
* On Debian 10:
105103
```
106104
$ sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python3 libssl-dev git cmake perl
107105
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
@@ -110,13 +108,17 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
110108
```
111109
$ sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python-is-python3 libssl-dev git cmake perl
112110
```
113-
* On Red Hat Enterprise Linux 8.6:
111+
* On Red Hat Enterprise Linux 9.2:
114112
```
115113
$ sudo yum groupinstall 'Development Tools'
116114
$ sudo yum install ocaml ocaml-ocamlbuild wget python3 openssl-devel git cmake perl
117-
$ sudo alternatives --set python /usr/bin/python3
118115
```
119-
* On CentOS Stream 8 and CentOS 8.3:
116+
* On CentOS Stream 9:
117+
```
118+
$ sudo dnf group install 'Development Tools'
119+
$ sudo dnf install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python3
120+
```
121+
* On CentOS 8.3:
120122
```
121123
$ sudo dnf group install 'Development Tools'
122124
$ sudo dnf --enablerepo=powertools install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python3
@@ -145,11 +147,15 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
145147
```
146148
$ sudo apt-get install libssl-dev libcurl4-openssl-dev protobuf-compiler libprotobuf-dev debhelper cmake reprepro unzip pkgconf libboost-dev libboost-system-dev libboost-thread-dev lsb-release libsystemd0
147149
```
148-
* On Red Hat Enterprise Linux 8.6:
150+
* On Red Hat Enterprise Linux 9.2:
149151
```
150152
$ sudo yum install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
151153
```
152-
* On CentOS Stream 8 and CentOS 8.3:
154+
* On CentOS Stream 9:
155+
```
156+
$ sudo dnf install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
157+
```
158+
* On CentOS 8.3:
153159
```
154160
$ sudo dnf --enablerepo=powertools install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
155161
```
@@ -249,7 +255,7 @@ You can find the tools and libraries generated in the `build/linux` directory.
249255
$ make
250256
```
251257
- To build the Intel(R) SGX PSW installer, enter the following command:
252-
* On Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
258+
* On Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
253259
```
254260
$ make deb_psw_pkg
255261
```
@@ -262,7 +268,7 @@ You can find the tools and libraries generated in the `build/linux` directory.
262268
```
263269
$ make deb_psw_pkg DEBUG=1
264270
```
265-
* On Red Hat Enterprise Linux 8.6, CentOS Stream 8, CentOS 8.3, Anolis OS 8.6 and SUSE Linux Enterprise Server 15.4:
271+
* On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6 and SUSE Linux Enterprise Server 15.4:
266272
```
267273
$ make rpm_psw_pkg
268274
```
@@ -282,10 +288,6 @@ You can find the tools and libraries generated in the `build/linux` directory.
282288
**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. The local package repository is not signed, you need to trust it for the purpose of development.
283289
284290
- To add the local Debian package repository to the system repository configuration, append the following line to /etc/apt/sources.list. You need to replace PATH_TO_LOCAL_REPO with the proper path on your system:
285-
* On Ubuntu 18.04:
286-
```
287-
deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO bionic main
288-
```
289291
* On Ubuntu 20.04:
290292
```
291293
deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO focal main
@@ -312,7 +314,7 @@ You can find the tools and libraries generated in the `build/linux` directory.
312314
**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.
313315
314316
- 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:
315-
* On Red Hat Enterprise Linux 8.6, CentOS Stream 8, CentOS 8.3, Anolis OS 8.6:
317+
* On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6:
316318
```
317319
$ sudo yum-config-manager --add-repo file://PATH_TO_LOCAL_REPO
318320
```
@@ -321,11 +323,11 @@ You can find the tools and libraries generated in the `build/linux` directory.
321323
$ sudo zypper addrepo PATH_TO_LOCAL_REPO LOCAL_REPO_ALIAS
322324
```
323325
- To ignore the gpgcheck when you install the package, enter the following command:
324-
* On Red Hat Enterprise Linux 8.6, CentOS Stream 8, CentOS 8.3, Anolis OS 8.6:
326+
* On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6:
325327
```
326328
$ sudo yum --nogpgcheck install <package>
327329
```
328-
* On SUSE Linux Enterprise Server 15.5:
330+
* On SUSE Linux Enterprise Server 15.4:
329331
```
330332
$ sudo zypper --no-gpg-checks install <package>
331333
```
@@ -334,28 +336,31 @@ Install the Intel(R) SGX SDK
334336
------------------------
335337
### Prerequisites
336338
- Ensure that you have one of the following operating systems:
337-
* Ubuntu\* 18.04 LTS Desktop 64bits
338-
* Ubuntu\* 18.04 LTS Server 64bits
339339
* Ubuntu\* 20.04 LTS Desktop 64bits
340340
* Ubuntu\* 20.04 LTS Server 64bits
341341
* Ubuntu\* 22.04 LTS Server 64bits
342-
* Red Hat Enterprise Linux Server release 8.6 64bits
343-
* CentOS Stream 8 64bits
342+
* Red Hat Enterprise Linux Server release 9.2 64bits
343+
* CentOS Stream 9 64bits
344344
* CentOS 8.3 64bits
345345
* SUSE Linux Enterprise Server 15.4 64bits
346346
* Anolis OS 8.6 64bits
347347
* Debian 10 64bits
348348
- Use the following command to install the required tool to use Intel(R) SGX SDK:
349-
* On Ubuntu 18.04 and Debian 10:
349+
* On Debian 10:
350350
```
351351
$ sudo apt-get install build-essential python3
352-
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
352+
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3
353353
```
354354
* On Ubuntu 20.04 and Ubuntu 22.04:
355355
```
356356
$ sudo apt-get install build-essential python-is-python3
357357
```
358-
* On Red Hat Enterprise Linux 8.6, CentOS Stream 8, CentOS 8.3 and Anolis OS 8.6:
358+
* On Red Hat Enterprise Linux 9.2 and CentOS Stream 9:
359+
```
360+
$ sudo yum groupinstall 'Development Tools'
361+
$ sudo yum install python3
362+
```
363+
* On CentOS 8.3 and Anolis OS 8.6:
359364
```
360365
$ sudo yum groupinstall 'Development Tools'
361366
$ sudo yum install python3
@@ -421,13 +426,11 @@ Install the Intel(R) SGX PSW
421426
----------------------------
422427
### Prerequisites
423428
- Ensure that you have one of the following operating systems:
424-
* Ubuntu\* 18.04 LTS Desktop 64bits
425-
* Ubuntu\* 18.04 LTS Server 64bits
426429
* Ubuntu\* 20.04 LTS Desktop 64bits
427430
* Ubuntu\* 20.04 LTS Server 64bits
428431
* Ubuntu\* 22.04 LTS Server 64bits
429-
* Red Hat Enterprise Linux Server release 8.6 64bits
430-
* CentOS Stream 8 64bits
432+
* Red Hat Enterprise Linux Server release 9.2 64bits
433+
* CentOS Stream 9 64bits
431434
* CentOS 8.3 64bits
432435
* SUSE Linux Enterprise Server 15.4 64bits
433436
* Anolis OS 8.6 64bits
@@ -437,15 +440,19 @@ Install the Intel(R) SGX PSW
437440
- Configure the system with the **Intel SGX hardware enabled** option and install Intel(R) SGX driver in advance.
438441
See the earlier topic, *Build and Install the Intel(R) SGX Driver*, for information on how to install the Intel(R) SGX driver.
439442
- Install the library using the following command:
440-
* On Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
443+
* On Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
441444
```
442445
$ sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
443446
```
444-
* On Red Hat Enterprise Linux 8.6:
447+
* On Red Hat Enterprise Linux 9.2:
445448
```
446449
$ sudo yum install openssl-devel libcurl-devel protobuf-devel
447450
```
448-
* On CentOS Stream 8 and CentOS 8.3:
451+
* On CentOS Stream 9:
452+
```
453+
$ sudo dnf install libcurl-devel protobuf-devel
454+
```
455+
* On CentOS 8.3:
449456
```
450457
$ sudo dnf --enablerepo=powertools install libcurl-devel protobuf-devel
451458
```
@@ -463,7 +470,7 @@ The SGX PSW provides 3 services: launch, EPID-based attestation, and algorithm a
463470
464471
#### Using the local repo(recommended)
465472
466-
| |Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and Debian 10|Red Hat Enterprise Linux 8.6, CentOS Stream 8 and CentOS 8.3| SUSE Linux Enterprise Server 15|
473+
| |Ubuntu 20.04, Ubuntu 22.04 and Debian 10|Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3 and Anolis OS 8.6| SUSE Linux Enterprise Server 15|
467474
| ------------ | ------------ | ------------ | ------------ |
468475
|launch service |apt-get install libsgx-launch libsgx-urts|yum install libsgx-launch libsgx-urts|zypper install libsgx-launch libsgx-urts|
469476
|EPID-based attestation service|apt-get install libsgx-epid libsgx-urts|yum install libsgx-epid libsgx-urts|zypper install libsgx-epid libsgx-urts|
@@ -484,11 +491,11 @@ apt-get dist-upgrade -o Dpkg::Options::="--force-overwrite"
484491
```
485492
#### Configure the installation
486493
Some packages are configured with recommended dependency on other packages that are not required for certain usage. For instance, the background daemon is not required for container usage. It will be installed by default, but you can drop it by using the additional option during the installation.
487-
* On Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
494+
* On Ubuntu 20.04, Ubuntu 22.04 and Debian 10:
488495
```
489496
--no-install-recommends
490497
```
491-
* On Red Hat Enterprise Linux 8.6, CentOS Stream 8, CentOS 8.3 and Anolis OS 8.6:
498+
* On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3 and Anolis OS 8.6:
492499
```
493500
--setopt=install_weak_deps=False
494501
```

SampleCode/Cxx17SGXDemo/Enclave/TrustedLibrary/Libcxx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ void ecall_cxx17_gcd_lcm() {
846846

847847
void print_map(std::string_view comment, const auto& data)
848848
{
849-
printf("%s", comment);
849+
printf("%s", comment.data());
850850
for (auto [k, v] : data)
851851
printf(" %d(%c)", k, v);
852852
printf("\n");
@@ -967,7 +967,7 @@ void ecall_cxx17_string_view() {
967967

968968
for (int y{}, p{}; y != 3; ++y, p = ((p + 1) % 4)) {
969969
for (int x{}; x != 16; ++x)
970-
printf("%s", unicode[p]);
970+
printf("%s", unicode[p].data());
971971
printf("\n");
972972
}
973973
}

SampleCode/LocalAttestation/App/UntrustedEnclaveMessageExchange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ATTESTATION_STATUS send_request_ocall(uint32_t session_id, secure_message_t* req
108108
ATTESTATION_STATUS end_session_ocall(uint32_t session_id)
109109
{
110110
sgx_status_t ret;
111-
uint32_t retcode;
111+
uint32_t retcode = (uint32_t) INVALID_SESSION;
112112

113113
ret = end_session(responder_enclave_id, &retcode, session_id);
114114
if (ret != SGX_SUCCESS || retcode != SGX_SUCCESS)

SampleCode/LocalAttestation/AppResponder/CPTask.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ int process_close_req(int clientfd, SESSION_CLOSE_REQ * close_req)
258258
return -1;
259259

260260
// send back response
261+
memset(&close_ack, 0, sizeof(FIFO_MSG));
261262
close_ack.header.type = FIFO_DH_CLOSE_RESP;
262263
close_ack.header.size = 0;
263264

SampleCode/LocalAttestation/EnclaveInitiator/EnclaveMessageExchange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ ATTESTATION_STATUS send_request_receive_response(dh_session_t *session_info,
317317
ATTESTATION_STATUS close_session(dh_session_t *session_info)
318318
{
319319
sgx_status_t status;
320-
uint32_t retstatus;
320+
uint32_t retstatus = (uint32_t) ATTESTATION_SE_ERROR;
321321

322322
if(!session_info)
323323
{

SampleCode/SampleAEXNotify/Enclave/Enclave.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ void count_powers_of_two_with_aex(uint64_t low, uint64_t high, uint32_t* count,
9090
sgx_aex_mitigation_node_t node;
9191

9292
sgx_register_aex_handler(&node, my_aex_notify_handler, (const void*)args);
93-
sgx_set_ssa_aexnotify(1);
9493

9594
const uint32_t local_count = count_powers_of_two(low,high);
9695
*count = local_count;
9796

98-
sgx_set_ssa_aexnotify(0);
9997
sgx_unregister_aex_handler(my_aex_notify_handler);
10098

10199
*aex_count = g_aex_count;

SampleCode/SampleAttestedTLS/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ build: $(SGXSSL_HEADER_CHECK)
5151
$(MAKE) -C client
5252
$(MAKE) -C non_enc_client
5353

54-
tdx: $(SGXSSL_HEADER_CHECK)
54+
tdx:
5555
$(MAKE) -C server_tdx
56+
$(MAKE) -C non_enc_client
5657

5758
clean:
5859
$(MAKE) -C server clean

SampleCode/SampleAttestedTLS/client/enc/openssl_client.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ int communicate_with_server(SSL* ssl)
8383
if (error == SSL_ERROR_WANT_WRITE)
8484
continue;
8585
t_print(TLS_CLIENT "Failed! SSL_write returned %d\n", error);
86-
ret = bytes_written;
86+
if (bytes_written == 0) ret = -1;
87+
else ret = bytes_written;
8788
goto done;
8889
}
8990

@@ -103,12 +104,16 @@ int communicate_with_server(SSL* ssl)
103104
continue;
104105

105106
t_print(TLS_CLIENT "Failed! SSL_read returned error=%d\n", error);
106-
ret = bytes_read;
107+
if (bytes_read == 0) ret = -1;
108+
else ret = bytes_read;
107109
break;
108110
}
109111

110112
t_print(TLS_CLIENT " %d bytes read\n", bytes_read);
111113
// check to to see if received payload is expected
114+
// Note that if you just want to use client here but server from other
115+
// applications, you need to ignore this check, SERVER_PAYLOAD_SIZE
116+
// need to be adjusted.
112117
if ((bytes_read != SERVER_PAYLOAD_SIZE) ||
113118
(memcmp(SERVER_PAYLOAD, buf, bytes_read) != 0))
114119
{
@@ -136,7 +141,7 @@ int communicate_with_server(SSL* ssl)
136141
int create_socket(char* server_name, char* server_port)
137142
{
138143
int sockfd = -1;
139-
struct sockaddr_in dest_sock;
144+
struct sockaddr_in dest_sock;
140145
int res = -1;
141146

142147
sockfd = socket(AF_INET, SOCK_STREAM, 0);
@@ -204,14 +209,14 @@ int launch_tls_client(char* server_name, char* server_port)
204209

205210
// specify the verify_callback for custom verification
206211
SSL_CTX_set_verify(ssl_client_ctx, SSL_VERIFY_PEER, &verify_callback);
207-
t_print(TLS_CLIENT "load cert and key\n");
212+
t_print(TLS_CLIENT "load cert and key\n");
208213
if (load_tls_certificates_and_keys(ssl_client_ctx, cert, pkey) != 0)
209214
{
210215
t_print(TLS_CLIENT
211216
" unable to load certificate and private key on the client\n");
212217
goto done;
213218
}
214-
219+
215220
if ((ssl_session = SSL_new(ssl_client_ctx)) == nullptr)
216221
{
217222
t_print(TLS_CLIENT

0 commit comments

Comments
 (0)