## 5 Modeling of the Proposed Protocols
### DDACap Protocol  
The proposed DDACap protocol is modeled using \(\mathit{UE}_{B}\) and \(\mathit{UE}_{C}\) entities based on the system model presented in Section 3 and a non-network-assisted D2D scenario with the same assumptions and security requirements as DDSec protocol in Section 5.1. The UEs would be allowed to access and share data even in the scenarios where certain roaming agreements do not apply, out of coverage and during a disaster situation. The UEs use some security context from DDSec if it applies to the scenario, however they are still capable of generating their own cryptographic primitives and security parameters such as timestamps and tokens. After \(\mathit{UE}_{A}\) shares the data and delegates its capabilities to \(\mathit{UE}_{B}\), \(\mathit{UE}_{B}\) can use the similar security attributes and capabilities for user and data object to cache and share the data with \(\mathit{UE}_{C}\) without the assistance of the network. For \(\mathit{UE}_{B}\) to share the data with \(\mathit{UE}_{C}\), both entities do not have to be on the same security level. \(\mathit{UE}_{B}\) and \(\mathit{UE}_{C}\) can use the proposed DDACap protocol for authentication and authorization of data caching and sharing. The overview of the DDACap protocol execution involves \(\mathit{UE}_{B}\) and \(\mathit{UE}_{C}\). The protocol initiation can be performed by the interested UE or the UE with data. In this case, \(\mathit{UE}_{B}\) with data initiates the direct communication by sending beacon signals with advertisement message and \(U\!E_{C}\) in proximity responds with interest messages. When the messages are evaluated and the signal has exceeded the predetermined metric threshold, both UEs start to communicate directly. The control signal and the data are exchanged over share data channels. The protocol messages exchange is between \(U\!E_{B}\) and \(U\!E_{C}\) for Scenario D in Figure 3 (Section 4.2), as illustrated in Figure 5, similarly with reference to notations in Table 1 and described as follows. Msg1 UEB \(\rightarrow\) UEC: ({AdvMsg})  
\(U\!E_{B}\) sends beacons signals with an advertisement message \(AdvMsg\) by broadcasting to the D2D users in proximity which includes \(U\!E_{C}\). It includes its pseudonym ID (\(U\!B\)), data name \(DataName\), logical address \(nAdd\), its public key \(PK_{U\!E_{B}}\) and hash of its public key \(hash(PK_{U\!E_{B}})\) signed with its private key \(SK_{U\!E_{B}}\), the hash is used for integrity and message authentication. Msg2 UEC \(\rightarrow\)UEB: ({IntMsg},{PKUEB})  
\(U\!E_{C}\) sends an interest message \(IntMsg\) to \(U\!E_{B}\) by replying \(AdvMsg\). It includes its pseudonym ID (\(U\!C\)), data name \(DataName\) of its interest, public key \(PK_{U\!E_{C}}\) and its hash \((hash(PK_{U\!E_{C}})\) signed with its private key \(SK_{U\!E_{C}}\) and encrypted with \(U\!E_{B}\)'s public key \(PK_{U\!E_{B}}\) hoping to make a direct communication. Msg3.UEB\(\rightarrow\)UEC: ({PubMedMg},{PKUEC})  
When \(U\!E_{B}\) receives Message 2, it responds with publish message \(PubMedMsg\). \(U\!E_{B}\) generates a nonce \(Rand\_rb\) as authentication challenges, a timestamp \(Ts_{3}\) for freshness and replay protection, pseudonym ID of \(DataName\) (\(D1\)) and hash of the whole message \(h\!PublM\!sg\) =\(hash(U\!B,D1,Rand\_rb,Ts_{1})\) signed with its private key \(SK_{U\!E_{B}}\). \(U\!E_{B}\) sends the \(PubMedMsg\) message that includes (\(UB\)), \(D1\), \(Rand\_rb\), \(Ts_{3}\) and \(h\!PublM\!sg\) as an authentication request encrypted with \(U\!E_{C}\)'s public key \(PK_{U\!E_{C}}\). Msg4.UEC\(\rightarrow\)UEB: ({CookUp},{PKUEB})  
Both UEs evaluate the received messages to establish direct communication over dedicated channels. Then, \(U\!E_{C}\) responds with \(LookUp\) message that includes its ID (\(U\!C\)), the data name \(D1\), new nonce \(rand\_rc\), nonce \(Rand\_rb\), a timestamp \(Ts_{4}\) and hash of the whole message \(hash(UC,D1,Rand\_rb,Rand\_rc,Ts_{4})\) signed by its private key \(SK_{U\!E_{C}}\).