LTE Authentication. Delving Into The Underlying Crypto - by Sudheesh Singanamalla - Uwcse-Ictd - Medium
LTE Authentication. Delving Into The Underlying Crypto - by Sudheesh Singanamalla - Uwcse-Ictd - Medium
LTE Authentication
Sudheesh Singanamalla · Follow
Published in uwcse-ictd
7 min read · Feb 19, 2020
Listen Share
Authentication refers to the idea of validating the identity of a user or a device trying
to access the resources provided by a given service and Authorization helps in
controlling the access to these resources. In the case of LTE and wireless networks,
authentication is used to enable a user device such as a mobile phone or an IoT
device to connect to the network and use the resources provided by the network
such as calling, Internet/data services or messaging services. Authorization is used
to check if the user connected to the network can actually be granted services. For
example:
Authentication: Check if the user device with the SIM card is actually owned by
the network to which it is trying to connect to
Authorization: Check if the user has sufficient credit balance to access the data
services at 1 MBps.
LTE networks use the Evolved Packet System Authentication and Key Agreement
(EPS-AKA) procedure for bidirectionally authenticating the user i.e. authenticating
the user to the network and the network to the user.
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 1/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
Let’s break this image down into the parts that we really need. Each USIM card
produced by the network operator contains a cryptographic key, Ki,which is also
known to the network operator and stored in the HSS. To authenticate, this key is
used to:
1. Have the UE authenticate the network: Why? This is to prove that the UE is
indeed speaking to the network to which it is supposed to be talking to in the
first place
2. Have the network authenticate the UE: Why? This is to ensure that the UE who
has actually paid for the network service and belongs to the network is the one
who receives access to it.
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 2/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
from the UE is an Identity Response which contains the mobile identity (IMSI) value
thereby completing the Attach request phase of the protocol.
Authentication Information Request and Response
After receiving the Identity Response, The MME sends a diameter (S6a) message
called Authentication Information Request (AIR) from the MME to the HSS
Open in app and
Sign up sends
Sign In
the corresponding mobile identity. The HSS on receiving this information computes
is responsible for:
The response from the HSS to the MME i.e. Authentication Information Answer (AIA)
contains the authentication information which includes a random byte array
denoted by RAND, the expected response from the UE to the MME denoted by
XRES, the authentication response denoted by AUTN, and a shared key called the
Key Access Security Management Entries denoted by Kasme.
So how are these values generated? Let’s dig deeper into the HSS to see what
happens to create this Authentication Information Answer (AIA) response.
On receiving the request, the HSS checks for the existence of a database record
corresponding to the subscriber and retrieves the Ki, OPc values. For simplicity
reasons, let us assume that the network operator knows the last used SQN number,
we look into how to obtain this value in a later blog post.
1. The HSS then generates a 16 byte random value and stores it in RAND.
2. The AMF, Ki, SQN and RAND values are fed into the Milenage algorithm which
generates the responses for AUTN, Anonymity Key (AK), Cipher Key (CK),
Integrity Key (IK) and an expected response XRES.
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 3/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
3. Another set of algorithms use the generated AK, CK, IK from the Milenage
algorithm to compute Kasme.
How does Milenage Really work?
Milenage consists of a series of functions denoted by f1, f2, f3, f4, f5 according to
the 3GPP specification. These are also sometimes written in open source cores as f1
and f2345 denoting the execution of each of the functions f2,f3,f4,f5 and collectively
returning a response.
The function f1 takes OPc, Ki, RAND, SQN and AMF values and performs:
1. For each byte of RAND, OPc performs a XOR operation and stores the result into
a temporary value (TMP1).
3. Expand the byte arrays of SQN, AMF to 128 bits i.e. creating `SQN || AMF || SQN ||
AMF` and storing it in TMP2
4. Perform TMP2 xor OPc and rotate it by a constant r1 i.e. 8 bytes (0x40)
7. AES128 encrypt TMP3 using Key Ki and assign the value to TMP1
9. The first 8 bytes of the F1_RES correspond to MAC_A which is a 64 bit network
authentication code.
10. The second 8 bytes of the F1_RES correspond to MAC_S which is a 64 bit
resynchronization authentication code.
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 4/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
The function f2345, uses the OPc, Ki, RAND, to generate XRES, CK, IK, AK. The
function has constants r2, r3, r4, and r5 corresponding to the constant of bytes to
rotate the array. In addition there are constants c2, c3, c4, and c5 which are
constants used in different functions. This is done by:
4. Additionally xor the last byte i.e. 15 index, with a constant c1 and rotate by r2=0
7. AES128 encrypt TMP1 using key Ki and store the result in TMP3
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 5/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
9. The result of f5 is the first 6 bytes of TMP3 i.e. TMP3 bytes 0–5 which is AK
10. The result of f2 is the last 8 bytes of TMP3 i.e. TMP3 bytes 8–15 which is XRES
11. Perform TMP2 xor OPc and assign the result to TMP1 with r3 = 4 bytes
14. AES128 encrypt TMP1 using key Ki and copy the result into CK
15. For f3, Perform xor of CK with OPc and assign the result to final value of CK
16. Similar to step 6, perform the TMP2 xor OPc and assign the result to TMP1 with
r4=8 bytes and xor with a constant c4=4.
19. AES128 encrypt TMP1 using key Ki and copy the result into IK
20. For f4, Perform xor of IK with OPc and assign the result to final value of IK
After computing the MAC_A, MAC_S, AK, IK, CK, and XRES. The AUTN value is
obtained by concatenating the SQN xor AK, with AMF and MAC_A value.
Note: The MAC_S value is used in case of synchronization failures of SQN. We will cover
this in a later blog post.
The results of milenage and other information i.e. AUTN, SQN, XRES, CK, IK, AK
along with PLMN are used to compute the Kasme value by doing:
1. k = CK || IK
The Authentication Information Answer contains the AUTN, RAND, Kasme, XRES
which is sent by the HSS to the MME as a diameter response.
The UE computes a new AUTN value and compares it to the value that has been
provided in an effort to authenticate the network to the UE. Once the UE
successfully validates the network it is communicating with, it generates a RES
which is sent as an Authentication Response to the MME. The MME validates if the
response provided RES matches the expected response XRES and sends a
successful/unsuccessful authentication message to the UE. The UE is now
authenticated and attached to the network.
The UE further computes the Kasme values to compute the necessary AK, CK, IK
keys used for encryption and integrity checks in further communications.
Images from the 3GPP spec ETSI TS 135 205 v 13.0.0 (2016–01) Universal Mobile
Telecommunications System. Specification of the Milenage Algorithm set.
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 7/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
Follow
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 8/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 9/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 10/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
11
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 11/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 12/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 13/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
53
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 14/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
6.6K 53
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 15/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 16/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
7.9K 80
Lists
New_Reading_List
174 stories · 33 saves
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 17/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
Unbecoming
55K 856
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 18/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 19/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
29K 523
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 20/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
16.8K 270
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 21/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
If You Want to Be a Creator, Delete All (But Two) Social Media Platforms
In October 2022, during the whole Elon Musk debacle, I finally deleted Twitter from my phone.
Around the same time, I also logged out of…
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 22/23
7/27/2023 LTE Authentication. Delving into the underlying crypto… | by Sudheesh Singanamalla | uwcse-ictd | Medium
35K 797
https://medium.com/uw-ictd/lte-authentication-2d0810a061ec 23/23