# A Secure and Efficient Authentication Scheme for Fog-Based Vehicular Ad Hoc Networks
## 4 Proposed Protocol
### Login and Authentication Phase  
In this phase, \(CS\), \(FN_{j}\), and \(V_{i}\) authenticate each other using their secret values and agree on a shared session key for secure communication. Figure 4 presents their interactions, and the details are provided below. **Step 1:**: Insert \(ID_{i}\) and \(PSW_{i}\) and compute \(M^{\prime}_{i}=h((h(ID_{i})\oplus PSW_{i})mods_{0})\). After computing, check whether \(M^{\prime}_{i}=M_{i}\); if not true, \(V_{i}\) will terminate the session and notify the user of the login failure. Then, \(V_{i}\) request the user to retry the login process. If true, \(V_{i}\) computes \(RPSW^{\prime}_{i}=h(ID_{i}\parallel PSW_{i}\parallel s_{0})\) and \(N_{i}=N^{*}_{i}\oplus h(RPSW^{\prime}_{i}\parallel M^{\prime}_{i})\). Next, \(V_{i}\) selects a random number, \(r_{1}\leq Z^{*}_{q}\), and calculates \(R_{1}=r_{1}P,R_{1}=r_{1}P_{pub},RID_{i}=PID_{i}\oplus h(R_{1})\), and \(Q_{i}=h(R_{1}\parallel N_{i}\parallel ID_{i}\parallel ID_{j})\), and \(V_{i}\) transmits \((D_{1}=R_{1},RID_{i},Q_{i},ID_{j})\) to \(FN_{j}\). **Step 2:**: \(FN_{j}\) verifies the freshness of the random number in \(D_{1}\) from \(V_{i}\) and selects a random number, \(r_{2}\in Z^{*}_{q}\), to calculate \(R_{2}=r_{2}P\) and \(L_{j}=h(N_{j}\parallel ID_{j}\parallel Q_{i})\). \(FN_{j}\) then transmits \((D_{2}=R_{1},RID_{i},R_{2},r_{2}R_{1},L_{j},ID_{j})\) to \(CS\). **Step 3:**: After receiving the authentication request from \(FN_{j}\), \(CS\) verifies the freshness of the random number in \(D_{2}\) from \(FN_{j}\) and computes \(R^{\prime}_{1}=sR_{1}\) and \(PID^{\prime}_{i}=RID_{i}\oplus h(R^{\prime}_{1})\). \(CS\) checks its database for items that correspond to \((PID^{\prime}_{i},x_{i})\) and \((ID^{\prime}_{j},y_{j})\). If \(CS\) does not find such items, it rejects the request and terminates the session. If \(CS\) finds the items, \(CS\) continues with additional computations as follows: - \(N^{\prime}_{i}=h(ID^{\prime}_{i}\parallel s\parallel x_{i})\) - \(N^{\prime}_{j}=h(ID_{j}\parallel s\parallel y_{j})\) - \(Q^{\prime}_{i}=h(R^{\prime}_{1}\parallel N^{\prime}_{i}\parallel ID^{\prime}_ {i}\parallel ID_{j})\) - \(L^{\prime}_{j}=h(N_{j}\parallel ID_{j}\parallel Q^{\prime}_{i})\). \(CS\) checks whether \(L^{\prime}_{j}=L_{j}\) is true, and if conditions are not true, \(CS\) will terminate the current session and request \(FN_{j}\) and \(V_{i}\) to retry the authentication process. Otherwise, \(CS\) randomly chooses \(r_{3}\in Z^{*}_{q}\), calculates \(R_{3}=r_{3}P\), and computes the following - \(R_{i-j-cs}=r_{3}\cdot(r_{2}R_{1})\) - \(K_{ij}=h(N_{i}\parallel R_{i-j-cs})\oplus h(N_{j}\parallel R_{i-j-cs})\) - \(SK_{i-j-cs}=h(h(N_{i}\parallel R_{i-j-cs})\parallel h(N_{j}\parallel R_{i}-j- cs)\) - \(Auth_{j}=h(h(N_{i}\parallel R_{i-j-cs})\parallel R_{i-j-cs}\)\). Then, \(CS\) transmits \((D_{3}=K_{ij},R_{3},r_{3}R_{1},Auth_{j})\) to \(FN_{j}\). **Step 4:**: After receiving the response from \(CS\), \(FN_{j}\) verifies the freshness of the random number in \(D_{3}\) from \(CS\) and computes \(R_{i-j-cs}=r_{2}\cdot(r_{3}R_{1}),h(N_{i}\parallel R_{i-j-cs})=K_{ij}\oplus h (N_{j}\parallel R_{i-j-cs}),SK_{i-j-cs}=h(h(N_{i}\parallel R_{i-j-cs})\parallel h (N_{j}\parallel R_{i-j-cs})\parallel R_{i-j-cs})\), and \(Auth^{\prime}_{j}=h(h(N_{i}\parallel R_{i-j-cs})\parallel R_{i-j-cs}\parallel SK _{i-j-cs})\). Then, \(FN_{j}\) verifies whether or not \(Auth^{\prime}_{j}=Auth_{j}\) is true, and if conditions are not true, \(FN_{j}\) will terminate the current session and notify \(CS\) of authentication failure. If true, \(FN_{j}\) computes \(Auth_{i}=h(Auth_{j}\parallel h(N_{j}\parallel R_{i-j-cs}))\) and transmits \((D_{4}=K_{ij},r_{2}R_{3},Auth_{i})\) to \(V_{i}\).