# A TEE-Based Federated Privacy Protection Method: Proposal and Implementation
## 3 Method Introduction
### Introduction of the Privacy Protection Model
SSL/TLS provides confidentiality and data integrity between two communicating applications, therefore preventing man-in-the-middle attacks. The basic protocol of the TLS1.2 one-way handshake is shown in Figure 4.

In the above protocol, the certificate issued by the authority is used as the identity of the communication parties. Then, the client carries the protocol version and public key information to request the server certificate. The server returns the certificate and carries its negotiated secret key to the client. After the client verifies that the certificate is legal, the two parties begin to encrypt the following application data by using the negotiated secret key. Under mutual TLS, the server also needs to verify the client's certificate. However, in this scheme, it is necessary to prevent the participants from receiving the plaintext of the message outside Enclave. In other words, this scheme is designed to prevent the participants from obtaining the public key and other information in the certificate during the negotiation of the secret key. The purpose is to prevent the negotiated secret key from being leaked to any party, including the client and server. Therefore, further enhancements are required through RA-TLS [23]. With the support of a formal definition, we first describe the TLS1.2 handshake protocol and then extend it to the RA-TLS protocol. The TLS handshake protocol is as shown in Algorithm 2. In step 2, client \(C\) obtains the certificate from the server, which includes the public key \(K_{s}\), and the server stores the private key with the signature. In step 3, the client provides the client certificate and encrypts the randomly generated master secret (Master Secret) \(Secret_{s}\) by the server's public key, and then sends it back to the server. In step 4, the server uses its certificate private key to decrypt the master key, and in step 5, it derives the actual application encryption key. ```
1.\(C\to S:m_{1}=C,N_{c},Ver_{c},IDSession\)
2.\(S\to C:m_{2}=S,N_{a},Ver_{s},IDSession,CA(S,K_{s})\)
3.\(C\to S:m_{3}=IDSession,\{Ver_{c},Secret_{c},C,S\}_{ls\prime},CA(C,K_{c})\), \(\{H(g_{1}(m_{1},m_{2},Secret_{c},C,S))\}_{K_{s}-1}\)
4.\(S\to C:m_{4}=\{H(g_{2}(m_{1},m_{2},m_{3},Secret_{c},C,S))\}_{K_{s}}\)
5.\(C\to S:m_{5}=\{H(g_{3}(m_{1},m_{2},m_{3},m_{4},Secret_{c},C,S))\}_{K_{s}}\)
```
**Algorithm 2** TLS1.2 establishes a secure link process. Figure 4: Process of TLS1.2 establishing handshake. where \(K_{cs}=Master(Secret_{c},N_{s},N_{c})\); \(N_{c}\) and \(N_{s}\) represent the Nonce value, which are single-use numbers, such as auto-incrementing numbers; and Master represents the secret key derivation function. It can be found that the certificate private keys of the TLS1.2 client and server are kept separately, and each can know the master key and the final application data encryption key. Obviously, this does not meet the requirement that participants are not able to steal data. Therefore, with the support of RA-TLS, we must ensure that the certificate's private key cannot be obtained by anyone, including participants and third parties, so that we can use the key derivation function provided by Intel SGX to randomly generate the public and private keys of the participants' certificates inside the Enclave. At the same time, the certificate authority transmits its signature certificate to the TEE in advance and completes the issuance of the randomly generated certificate inside the TEE. The updated protocol is shown in Algorithm 3. ```
1.\(C\to S:gen(K_{c}),m_{1}=C,N_{c},Ver_{c},IDSession\)
2.\(S\to C:gen(K_{s}),m_{2}=S,N_{s},Ver_{s},IDSession,CA(S,K_{s})\)s
3.\(C\to S:m_{3}=IDSession,\{Ver_{c},Secret_{c},C,S\}_{ks},CA(C,K_{c},Report_{c})\), \(\{H(g_{1}(m_{1},m_{2},Secret_{c},C,S))\}_{K_{c}-1}\)
4.\(S\to C:m_{4}=\{H(g_{2}(m_{1},m_{2},m_{3},Secret_{c},C,S))\}_{ks}\)
5.\(C\to S:m_{5}=\{H(g_{3}(m_{1},m_{2},m_{3},m_{4},Secret_{c},C,S))\}_{ks}\)
```

**Algorithm 3**Process of RA-TLS1.2 establishing a secure link.