## 4 The Proposed 3-Tier AKA Mutual Authentication and Key Agreement (AKA) Protocol
### Authentication and Key Agreement Phase (Edge Device and Fog Node Authentication Protocol)
Then, it stores \(SK_{\delta_{d}\zeta_{z}}\) in its memory and computes a message to the fog node \(\zeta_{z}:M_{\delta_{d}\zeta_{z}}=E(T\parallel``\delta_{d}to\zeta_{z}\)\", \(SK_{\delta_{d}\zeta_{z}})\), where \(T\) is the timestamp at the current time of line 6 in Figure 6. Finally, \(\delta_{d}\) transmits \(M_{\delta_{d}\zeta_{z}}\) and \(proof_{\delta_{d}}\) to \(\zeta_{z}\). **Step 4:**: Fog node \(\zeta_{z}\) receives the message \(M_{\delta_{d}\zeta_{z}}\) and \(proof_{\delta_{d}}\) from edge device \(\delta_{d}\) to indicate that an edge device wishes to connect with the fog node \(\zeta_{z}\). At this point, the fog node depends on the 5G service provider \(u_{v}\) to validate the request and obtain a secret key to be used between the edge device and the fog node. Therefore, the fog node authenticates itself to the \(u_{v}\) by sending a self-authentication message \(proof\,Me=E(T,K_{\zeta_{z}})\) along with the value \(proof_{\delta_{d}}\) and the token \(O_{\zeta_{z}}\), as shown in lines 7 and 8 in Figure 6.
**Step 5:**: The 5G service provider receives the token \(O_{\zeta_{z}}\) by which it recognizes the sender \(\zeta_{z}\). It uses the secret key \(K_{\zeta_{z}}\) to verify the received \(proof\,Me\) and authenticate the fog node. Then, \(u_{v}\) decrypts the received \(foo_{\delta_{d}}\), checks the text \"\(\delta_{d}to\zeta_{z}\)\", and retrieves the session key \(SK_{\delta_{d}\zeta_{z}}\). Finally, \(u_{v}\) computes an \"OK\" response message \(R_{\zeta_{z}}=E(T\parallel SK_{\delta_{d}\zeta_{z}},K_{\zeta_{z}})\) and transmits \(R_{\zeta_{z}}\) to \(\zeta_{z}\), as shown in lines 9 and 10 from Figure 6. Note that \(u_{v}\) forgets \(O_{\delta_{d}},O_{\zeta_{z}}\), \(K_{\delta_{d}},K_{\zeta_{z}}\), \(SK_{\delta_{d}\zeta_{z}}\), \(proof\,Me\), and \(proof_{\delta_{d}}\) after sending \(R_{\zeta_{z}}\). **Step 6:**: Once the fog node \(\zeta_{z}\) receives the response message \(R_{\zeta_{z}}\) from the 5G service provider \(u_{v}\), it decrypts \(R_{\zeta_{z}}\), verifies the value of the timestamp to authenticate the 5G service provider \(u_{v}\), retrieves the session key \(SK_{\delta_{d}\zeta_{z}}\), and stores it in its memory. Then, in line 11 from Figure 6, \(\zeta_{z}\) decrypts the received message \(M_{\delta_{d}\zeta_{z}}\) (in line 6, in Figure 6) to recognize the string \"\(\delta_{d}to\zeta_{z}\)\" and the identity of the requesting edge device, who was \(\delta_{d}\). At this point, \(\zeta_{z}\) authenticates \(\delta_{d}\). In order for \(\zeta_{z}\) to authenticate itself to \(\delta_{d}\), it computes and sends the \"OK\" message \(M_{\zeta_{z}\delta_{d}}=E(T\parallel``\zeta_{z}to\delta_{d}\)\", \(SK_{\delta_{d}\zeta_{z}})\) to \(\delta_{d}\). **Step 7**: The edge device \(\delta_{d}\) decrypts the received message \(M_{\xi,\delta_{d}}\), using the session key \(SK_{\delta_{d}\xi,z}\), as shown in line 12 in Figure 6. The edge device \(\delta_{d}\) authenticates \(\zeta_{z}\) if the string literal is \"\(\zeta_{z}t\)\(o\delta_{d}\)\" and the retrieved timestamp \(T\) is within the time skew of the timestamp at line 6 in Figure 3:0 If successful, the mutual Authentication and Key Agreement process is completed. Note that the real identity of the edge device and the fog node were concealed during this protocol.