# Enabling Trustworthy Multicast Wireless Services through D2D Communications in 5G Networks
## 4 The Proposed eCMS-sD2D Protocol
Among all the eligible configurations (i.e., those in which all UE, belonging to the MG, receive all data), the eNB finally selects the one that guarantees the maximization of system data rate. Please refer to the D2D-enhanced CMS with single frequency solution presented in [5] for more details on the implementation of this step. Once the multicast and D2D configuration is defined, the operations aimed at securing D2D communications are carried out. Security mechanisms described in the following are inspired by [10]. _Step 4--Keys distribution_  
In order to protect privacy of registered UE, the eNB computes a pseudo-identity (PID) for each of them. For each \(UE_{k}\) that registered with the network using its real ID (\(RID_{k}\)), the eNB computes a pseudo-identity as: \(PID_{k}=H_{0}(RID_{k})\), where \(H_{0}\) is a secure hash function, chosen and published by the eNB. In order to protect the privacy of the users and not increase the total overhead, the eNB never distributes the PIDs to the users, but each of them has to compute its PID autonomously, using the same function of the eNB (i.e., \(H_{0}\)). Then, through a secure control channel, the eNB sends to the D2D users their private and public keys. It obtains the first key by choosing \(x_{i}\in Z_{q}^{*}\) (i.e., a set of integers with a prime number \(q\) of elements) and computes the second key as \(X_{i}=g^{x_{i}}\), where \(g\) is the fixed primitive element of \(Z_{q}^{*}\) used as generator/base. Note that \(H_{0}\), \(q\), \(g\), \(H_{1}\), and the symmetric encryption algorithm \(Enc_{key}()\) (the last two will be mentioned in the future steps) are all security parameters chosen and published by the eNB. _Step 5--D2D initialization_  
After receiving the keys, the D2D receiver (in the following indicated by \(UE_{i}\)) sends an initialization message to the eNB. This message is composed by:  
\[PID_{i}||P_{i}||z||h[(x_{i}^{+}\oplus\text{p}\text{q}\text{q})]||h[(x_{i}^{+} \oplus\text{p}\text{q}\text{q})||PID_{i}||z]], \tag{7}\]  
where:  
* \(P_{i}\) is the index of the portion of data that the user requires to receive. Indeed, too large data can be divided into multiple portions, each identified by a specific index. The eNB keeps track of the portions of data sent to each user to avoid data retransmissions. * \(||\) is the operator used to concatenate strings;
* \(z\) is the first public key for generating the secret key \(k_{c}\) that will be used for data encryption and decryption. It is computed as \(z=g^{c}\), where \(c\in Z_{q}^{*}\) is randomly chosen by \(UE_{i}\);
* \(h[(x_{i}^{+}\oplus\text{p}\text{q}\text{q})||h[(x_{i}^{+}\oplus\text{p}\text{ q})||PID_{i}||z]]\) is the \(HMAC_{x_{i}}(PID_{i}||P_{i}||z]\). Generally, the \(HMAC_{k}(m)\) is used to guarantee the integrity and authentication of the message \(m\). It is based on the use of any cryptographic hash function \(h\) applied to a combination of the original message \(m\) and the secret key \(k\). In Equation (7), \(x_{i}^{+}\) is the key padded out to size, _opad_ and _ipad_ are specified padding constants. In the remainder of the paper, \(h[(k^{+}\oplus\text{p}\text{q}\text{q})||h[(k^{+}\oplus\text{p}\text{q} \text{q})||m]]\) will be expressed as \(h(\bullet,k)\), where \(\bullet\) denotes the message attached by the HMAC and \(k\) is the secret key hashed together with the message. Note that \(x_{i}\) is only known by the sender \(UE_{i}\) and the receiver eNB. In all future steps, the verification of the HMAC will always be performed by the recipients of the messages to verify message integrity and authentication, hence, from here on, this procedure will be omitted. _Step 6--D2D pair announcement_  
After receiving the initialization message, the eNB authenticates the requesting user in the normal cellular communication mode, obtaining its RID and checking if it is registered. In the positive case, the eNB has to inform both D2D devices involved in the direct communication of their imminent communication.