# 5G-IPAKA: An Improved Primary Authentication and Key Agreement Protocol for 5G Networks
## 2 Overview of the 5G AKA Protocol  
According to [2; 3; 4], the steps of the latest version of the 5G AKA protocol in the 3 GPP standard version v17.4.0 of TS 33.501 are illustrated in Figure 1.  
In Figure 1, the universal subscriber identity module (_USIM_) and the mobile equipment (_ME_) are located in the user equipment (_UE_), and the security anchor function (_SEAF_) is located in the _SN_. The authentication server function (_AUSF_), the unified data management (UDM), the authentication credential repository and processing function (_ARPE_), and the subscriber identity de-concealing function (_SIDF_) are located in the home network (_HN_). The messages between the _SN_ and the _HN_ are usually protected. The detailed steps of the latest version of the 5G AKA protocol are as follows:  
1. When the _SEAF_ initiates an authentication with the _UE_, the _UE_ sends _SUCI_ to the _SEAF_, where the _UE_ includes the ME and the USIM. _SUCI_ denotes a _SUCI_ of the _UE_ and _SUCI_\(=x\cdot G||\{SUPI\}_{EK}||MAC_{UE}\), where \(SUPI\) denotes the subscription permanent identifier (_SUPI_) of the _UE_, \(x\cdot G\) and \(x\) are an ephemeral public-private key pair of the _UE_ for Diffie-Hellman exchange, \(y\cdot G\) and \(y\) are the ephemeral public-private key pair of the _HN_ for Diffie-Hellman exchange, \(EK||ICB||MK=KDF(x\cdot y\cdot G)\) and \(MAC_{UE}=HMAC(MK,\{SUPI\}_{EK})\), \(EK\) is an encryption key, \(ICB\) is an initial counter block (_ICB_), _MK_ is a message authentication code (_MAC_) key, \(MAC_{UE}\) is a _MAC_ of the _UE_, \(KDF()\) is a key derivation function, and \(HMAC()\) is a hash function for computing _MAC_;
2. Upon receiving _SUCI_, the _SEAF_ sends _SUCI_ and _SNN_ to the _AUSF_. _SNN_ denotes the serving network name (_SNN_) of the _SN_;  
Figure 1: The steps of the latest version of the 5G AKA protocol. If the \(SEAF\) is entitled to use \(SNN\), then the \(AUSF\) stores the receiving \(SNN\) and sends \(SUCI\) and \(SNN\) to the UDM;
4. The UDM invokes the \(SIDF\) regardless of whether \(SUCI\) is received. Then, the \(SIDF\) de-conceals \(SUCI\) to gain \(SUPI\) before the UDM can process the request. Based on \(SUPI\), the UDM/ARPF chooses the authentication method;
5. When 5G AKA is selected, the UDM/ARPF generates \(RAND\), calculates \(AUTN\) and \(XRES*\), and derives \(K_{AUSF}\), and then creates a 5G home environment authentication vector (5G HE AV) from \(RAND\), \(AUTN\), \(XRES*\), and \(K_{AUSF}\). \(RAND\) is an unpredictable challenge of the \(HN\). \(AUTN\) is an authentication token of the \(HN\) and \(AUTN=SQN\oplus AK||AMF||MAC\), where \(SQN\) is a fresh sequence number generated by the \(HN\), \(AK\) is an anonymity key and \(AK=f_{5}(K,RAND)\), \(AMF\) is the authentication management field (\(AMF\)) and the separation bit of the \(AMF\) is set 1, \(MAC\) is a \(MAC\) of the \(HN\) and \(MAC=f_{1}(K,SQN||RAND||AMF)\), \(K\) is a long-term key between the \(UE\) and the \(HN\), \(f_{1}()\) is a message authentication function, and \(f_{5}()\) is a key-generating function. Here, \(XRES*=KDF(CK||IK,SNN\ ||RAND||XRES)\), where \(CK\) is a cipher key and \(CK=f_{3}(K,RAND)\), \(IK\) is an integrity key and \(IK=f_{4}(K,RAND)\), \(XRES\) is an expected response and \(XRES=f_{2}(K,RAND)\), \(f_{2}()\) is a message authentication function, and \(f_{3}()\) and \(f_{4}()\) are two key-generating functions. \(K_{AUSF}\) is a key derived from \(CK\) and \(IK\), and \(K_{AUSF}=KDF(CK||IK,SNN||SQN\oplus AK)\);
6. The UDM sends the 5G HE AV to the \(AUSF\) together with \(SUPI\). When an authentication and key management for applications (\(AKMA\)) subscription is used, the UDM also sends \(AKMA\) to the \(AUSF\). \(AKMA\) denotes the \(AKMA\) indication and routing indicator;
7. The \(AUSF\) stores the \(XRES*\) temporarily together with the received \(SIPI\);
8.