# 5G-IPAKA: An Improved Primary Authentication and Key Agreement Protocol for 5G Networks
## 4 Our Proposed 5G-IPAKA Protocol  
In order to overcome the above shortcomings of the latest version of the 5G AKA protocol, we propose the 5G-IPAKA protocol, which is illustrated in Figure 2.  
In Figure 2, the detail steps of the 5G-IPAKA protocol are shown, as follows:  
1. When the _SEAF_ initiates an authentication with the _UE_, the _UE_ sends \(SUCI\) to the _SEAF_;
2. Upon receiving \(SUCI\), the _SEAF_ generates \(RAND_{\textit{SN}}\) and then sends \(RAND_{\textit{SN}}\), \(SUCI\), and \(SNN\) to the _AUSF_, where \(RAND_{\textit{SN}}\) is an unpredictable challenge of the _SEAF_;
3. If the _SEAF_ is entitled to use \(\textit{SNN}\), then the _AUSF_ stores the receiving \(\textit{SNN}\) and sends \(SUCI\) and \(\textit{SNN}\) to the UDM;
4. The UDM invokes the _SIDF_ whether \(SUCI\) is received or not. Then, the _SIDF_ deconecals \(SUCI\) to gain \(SUPI\) before the UDM can process the request. Based on \(SUPI\), the UDM/ARPF chooses the authentication method;
5. When 5G-IPAKA is selected, the UDM/ARPF generates \(RAND\), calculates \(\textit{AUTN}\) and \(\textit{XRES*}\), and derives \(\textit{K}_{\textit{AUSF}}\), and then creates a 5G HE AV from \(RAND\), \(\textit{AUTN}\), \(\textit{XRES*}\), and \(\textit{K}_{\textit{AUSF}}\), where \(\textit{AUTN}=\textit{SQN}\oplus AK||\textit{AMF}||\textit{MAC}\), \(\textit{AK}=f_{5}(\textit{BK},\textit{RAND})\), \(\textit{MAC}=f_{1}(\textit{BK},\textit{SQN}||\textit{RAND}||\textit{AMF})\), \(\textit{CK}=f_{3}(\textit{BK},\textit{RAND})\), \(\textit{IK}=f_{4}(\textit{BK},\textit{RAND})\), \(\textit{XRES}=f_{2}(\textit{BK},\textit{RAND})\), \(\textit{XRES*}=\textit{KDF}(\textit{CK}||\textit{IK},\textit{SNN}||\textit{ RAND}||\textit{XRES})\), \(\textit{K}_{\textit{AUSF}}=\textit{KDF}(\textit{CK}||\textit{IK},\textit{SNN}|| \textit{SQN}\oplus\textit{AK})\), and \(\textit{BK}=\textit{KDF}(\textit{K},\textit{x}\cdot\textit{y}\cdot\textit{G}|| \textit{SNN})\) ;
6. The UDM sends the 5G HE AV to the _AUSF_ together with \(\textit{SUPI}\). When an _AKMA_ subscription is used, the UDM also sends _AKMA_ to the _AUSF_;  
Figure 2: Our proposed 5G-IPAKA protocol. The _AUSF_ stores the \(XRES*\) temporarily together with the received _SUPI_;
* The _AUSF_ generates a 5G AV from the 5G HE AV received from the UDM/ARPF by computing \(HXRES*\) from \(XRES*\), computing \(K_{SEAF}\) from \(K_{AUSF}\), replacing \(XRES*\) with \(HXRES*\), and replacing \(K_{AUSF}\) with \(K_{SEAF}\) in the 5G HE AV;
* The ASUF creates a 5G SE AV by adding \(SUPI\) to the 5G AV, then sends the 5G SE AV (i.e., \(RAND\), \(AUTN\), \(HXRES*\), \(K_{SEAF}\), and \(SUPI\)) together with \(RAND_{SN}\) to the _SEAF_;
* The _SEAF_ stores \(HXRES*\), computes \(MAC_{SN}\), and then sends \(RAND_{SN}\), \(RAND\), \(AUTN\), \(ngKSI\), \(ABBA\), and \(MAC_{SN}\) to the _UE_, where \(MAC_{SN}\) is a _MAC_ of the _SEAF_ and \(MAC_{SN}=HMAC(K_{SEAF},RAND_{SN}||RAND||AUTN||ngKSI||ABBA)\);
* In the _UE_, the ME forwards \(RAND\) and \(AUTN\) to the USIM. Upon receipt of \(RAND\) and \(AUTN\), the USIM first computes \(BK=KDF(K,x\cdot y\cdot G||SN)\) and the anonymity key \(AK=f_{5}(BK,RAND)\) and retrieves the sequence number \(SQN=(SQN\oplus AK)\oplus AK\). Next, the USIM computes \(XMAC=f_{1}(BK,SQN\ ||RAND||AMF)\) and compares this with \(MAC\) which is included in \(AUTN\). Then, the USIM verifies that the received \(SQN\) is in the correct range. If \(XMAC\) is the same as \(MAC\) and \(SQN\) is in the correct range, then the USIM computes a response \(RES=f_{2}(BK,RAND)\), \(CK=f_{3}(BK,RAND)\), and \(IK=f_{4}(BK,RAND)\), and then returns \(RES\), \(CK\), and \(IK\) to the ME. The ME then computes \(RES*=KDF(CK||IK,SNN||RAND||RES)\), \(K_{AUSF}\), and \(K_{SEAF}\). Finally, the ME verifies \(MAC_{SN}\) using \(K_{SEAF}\). If the verification fails, then the ME aborts;
* The _UE_ computes \(MAC_{UE2}\), and then sends \(RES*\) and \(MAC_{UE2}\) to the _SEAF_, where \(MAC_{UE2}=HMAC(K_{SEAF},RAND_{SN}||RES*)\) is another _MAC_ of the _UE_;
* The _SEAF_ verifies \(MAC_{UE2}\).