# 5G-IPAKA: An Improved Primary Authentication and Key Agreement Protocol for 5G Networks
## 4 Our Proposed 5G-IPAKA Protocol
If the verification fails, then the _SEAF_ aborts. Otherwise, the _SEAF_ computes \(HRES*=SHA256(RAND||RES*)\) and compares this with \(HXRES*\). If they coincide, then the _SEAF_ considers the authentication as successful from the serving network point of view. If not, then the _SEAF_ considers the authentication as unsuccessful;
* The _SEAF_ sends the received \(RES*\) to the _AUSF_;
* The _AUSF_ compares the received \(RES*\) with the stored \(XRES*\). If \(RES*\) and \(XRES*\) are equal, then the _AUSF_ considers the authentication as successful from the home network point of view. Then, the _AUSF_ informs the UDM about the authentication result;
* The _AUSF_ indicates to the _SEAF_ whether the authentication was successful or not from the home network point of view (i.e., \(Result\)). In step 11, if \(XMAC\) and \(MAC\) are different, then the _UE_ directly discards the first received message of the _UE_ without responding to a \"_MAC_ failure\" indication, so the _HN_ will initiate a new authentication procedure towards the _UE_ when the _HN_ does not receive an authentication response message or a synchronization failure message within a certain period of time. In step 11, if \(SQN\) is not in the correct range, then the USIM computes \(AUTS=SQN_{\textit{UE}}\oplus AK^{*}||MAC-S\), and then sends \(AUTS\) with a \"synchronization failure\" indication to the ME, where \(AK^{*}=f_{5}^{*}(BK,RAND)\) and \(MAC-S=f_{1}^{*}(BK,\ SQN_{\textit{UE}}||RAND||AMF_{0})\). Then, the ME computes \(MAC_{UE2}=HMAC(K_{SEAF},RAND_{SN}\ ||Syncf||AUTS)\), and then sends \(AUTS\) and \(MAC_{UE2}\) with a \"synchronization failure\" indication to the _SEAF_, where \(Syncf=\)\"Synchronization failure\". Further, the _SEAF_ verifies \(MAC_{UE2}\); if the verification fails then the _SEAF_ aborts, otherwise the _SEAF_ sends \(RAND\) and \(AUTS\) with a \"synchronization failure\" indication to the _AUSF_. Finally, the ASUF sends \(RAND\) and \(AUTS\) with a \"synchronization failure\" indication to the UDM/ARPF;  
Note that the fields not specifically explained in the above steps are the same as Figure 1. Compared with the latest version of the 5G AKA protocol, the main improvements of our proposed 5G-IPAKA protocol are as follows:* **Replace the pre-shared key between the _UE_ and the _HN_ with a derivation key of the pre-shared key. In detail, \(K\) is replaced with \(\textit{BK}=\textit{KDF}(K,x\cdot y\cdot G||SNN)\) on the _UE_ and the _HN_;
* **Add the challenge-response mechanism for the SN. ** Firstly, \(\textit{RAND}_{\textit{SN}}\) is added to the first send message of the _SEAF_ as a challenge and is added to the second received message of the _SEAF_ as a response. Then, \(\textit{RAND}_{\textit{SN}}\) is added to the second send message of the _SEAF_ as a challenge and is added to the third received message of the _SEAF_ as a response (i.e., \(\textit{RAND}_{\textit{SN}}\) in \(\textit{MAC}_{\textit{UE},2}\));
* **Add the mutual authentication and key confirmation between the _UE_ and the _SN_. Firstly, \(\textit{K}_{\textit{SEAF}}\) and \(\textit{SUPI}\) are moved to the second sent message of the _AUSF_ from the last sent message of the _AUSF_. Then, the _UE_ and the _SN_ perform a mutual authentication and key confirmation process based on \(\textit{MAC}_{\textit{SN}}\) and \(\textit{MAC}_{\textit{UE},2}\), which are generated by using \(\textit{K}_{\textit{SEAF}}\);
* **Replace the _MAC_ failure procedure with the timeout mechanism on the _HN_. If \(\textit{XMAC}\) in the received _AUTN_ and _MAC_ calculated locally by the _UE_ are different, then the _UE_ directly discards the first received message of the _UE_ without responding to a \"_MAC_ failure\" indication, so the _HN_ will initiate a new authentication procedure towards the _UE_ when the _HN_ does not receive an authentication response message or a synchronization failure message within a certain period of time.