###### Abstract  
Device-to-Device (D2D) communications will be used as an underlay technology in the Fifth Generation mobile network (5G), which will make network services of multiple Service Providers (SP) available anywhere. The end users will be allowed to access and share services using their User Equipments (UEs), and thus they will require seamless and secured connectivity. At the same time, Mobile Network Operators (MNOs) will use the UE to offload traffic and push contents closer to users relying on D2D communications network. This raises security concerns at different levels of the system architecture and highlights the need for robust authentication and authorization mechanisms to provide secure services access and sharing between D2D users. Therefore, this paper proposes a D2D level security solution that comprises two security protocols, namely, the D2D Service security (DDSec) and the D2D Attributes and Capability security (DDACap) protocols, to provide security for access, caching and sharing data in network-assisted and non-network-assisted D2D communications scenarios. The proposed solution applies Identity-based Encryption (IBE), Elliptic Curve Integrated Encryption Scheme (ECIES) and access control mechanisms for authentication and authorization procedures. We formally verified the proposed protocols using ProVerif and applied pi calculus. We also conducted a security analysis of the proposed protocols. 20212010680810390/electronics1013160810390/electronics1013160810390/electronics1013160810390/electronics222 May 202122 July 20212 July 202125 July 202125 July 202125 July 202130  
user experience by pushing contents to the edge closer to the users [8]. The UE will act as a data consumer as well as a helper in content distribution and delivery [9]. 5G will make network services available anywhere from multiple Service Providers (SPs), and end users will be allowed to access and share the services. This raises new security concerns in the forms of securing data access and sharing that need to be addressed. One of the challenges for Mobile Network Operators (MNOs) is to provide security and session continuity as users access different networks and third-party services. There is a lack of an efficient multi-purpose mechanism that addresses the authentication and authorization of D2D users in different coverage scenarios to access services from SPs. Moreover, there is a need of security mechanisms that allow the user to cache, share data and delegate their access right to other users. These security solutions must consider security at the network, service and D2D levels in 5G [2]. Federated authentication and authorization can be used to provide flexible security management, accurate tracking of relevant UE data and seamless connectivity [10; 11], whereby the MNO/SP can delegate some security and access management to a third-party or the UE [10]. 5G non-standalone networks are being deployed, while 5G standardization is now on phase 2 Rel-17 [12], but D2D communications was never standardized for any previous mobile network generations, and it is still the case. However, the legacy system specified some ProSe functionalities and also being considered in many 5G applications [7; 13; 14; 15]. D2D security has been investigated in related work (e.g., [16; 17; 18; 19]), but these research efforts did not consider 5G's new use cases such as multiple shareholders, tactile Internet, edge and third-party services [2]. This implies that existing protocols cannot be trusted to address rising security challenges based on the new use cases, such as securing data access, caching and sharing, as well as authorization and user's access right delegation for D2D users in 5G. Therefore, we propose a D2D level security solution, consisting of D2D Service security (DDSec) and D2D Attributes and Capability security (DDACap) protocols that provide authentication and authorization in network- and non-network-assisted scenarios, respectively, enabling two UEs in proximity to access, cache and share data in different scenarios.