C46 Exp3
C46 Exp3
PART A
(PART A: TO BE REFFERED BY STUDENTS)
A.3 Outcomes: Student will be able to implement security algorithms for mobile
communication network. (LO-4)
A.5 Theory:
Authentication verifies identity and validity of SIM card to the network and ensures
that subscriber has access to the network.
Term used
Ki= individual subscriber authentication key, it is 32 bit number and present
only in SIM card and stored in authentication center.
RAND= random 128 bit number generated by AUC (authentication center)
when network request to authenticate the subscribers.
SRES (signed responses) = 32 bit crypto variable used in authentication process.
Kc = 64 bit cipher key.
MS is challenged by given RAND by the network.
Security in GSM
Three algorithms have been specified to provide security services in GSM.
Algorithm A3 is used for authentication, A5 for encryption, and A8 for the
generation of a cipher key.
Subscriber Authentication
For subscriber authentication algorithm used is A3
1. A3 algorithm is inbuilt inside SIM and AUC, Input for A3 is Ki and RAND
2. Ki=Stored inside SIM(kiis encrypted inside SIM card) and not share on network
and also present in AUC of MSC.
3. Before a subscriber can use any service from the GSM network, he or she must be
authenticated. Authentication is based on the SIM, which stores the individual
authentication key Ki, the user identification IMSI, and the algorithm used for
authentication A3.
4. When user want to access GSM network IMSI number from SIM send to MSC
then HLR then to AUC.
5. Now AUC check IMSI number is present or not and identify associated Ki value
(Ki is fixed), in this procedure AUC generate RAND number which is different
for every new user request.
6. AUC using authentication algorithm A3(input to A3 are ki and RAND) calculate
SRES as output of A3 and AUC using algorithm A8 of cipher generation (input to
A8 are ki and RAND) calculate Kcand send these SRES, Kc and RAND to HLR
then from HLR to MSC. These three terms SRES, Kc and RAND are called as
triplet.
7. MSC now send only RAND value to MS
8. MS using algorithm A3 (input to A3 is Ki and RAND)calculate SRES and using
algorithm A8 calculate Kc and send these SRES and kc to MSC
9. MSC check SRES receive from MS and Network are same or not. If both are same
user is authenticated and connection is set up.
Encryption
1. To ensure privacy, all messages containing user-related information are
encrypted in GSM over the air interface.
2. After authentication, MS and BSS can start using encryption by applying the
cipher key Kc
3. Kc is generated using the individual key Ki and a random value by applying
the algorithm A8. Note that the SIM in the MS and the network both calculate
the same Kc based on the random value RAND. The key Kc itself is not
transmitted over the air interface.
4. MS and BTS can now encrypt and decrypt data using the algorithm
A5andthe cipher key Kc. As Figure shows, Kc should be a 64 bit key –
which is not very strong, but is at least a good protection against
simple eavesdropping. However, the publication of A3 and A8 on the
internet showed that in certain implementations 10 of the 64 bits are
always set to 0, so that the real length of the key is thus only 54
consequently, the encryption is much weaker.
5. Note: An eavesdropping attack, also known as a sniffing or snooping attack,
is a theft of information as it is transmitted over a network by a computer,
smart-phone, or another connected device. The attack takes advantage of
unsecured network communications to access data as it is being sent or
received by its user. Eavesdropping is the act of intercepting communications
between two points.
import random
k=random.getrandbits(128)
m=random.getrandbits(128)
kb=bin(k)[2:]
mb=bin(m)[2:]
kbl=kb[0:64]
kbr=kb[64:]
mbl=mb[0:64]
mbr=mb[64:]
a1=int(kbl,2)^int(mbr,2)
a2=int(kbr,2)^int(mbl,2)
a3=a1^a2
a4=bin(a3)[2:].zfill(64)
a5=a4[0:32]
a6=a4[32:]
a7=int(a5,2)^int(a6,2)
print("128 Bit Key = ",kb)
print("128 Random Bits Generated = ",mb)
print("RES/SRES = ",bin(a7)[2:].zfill(len(a5)))
011101110110111010100010110101000111010001
0000010011110000001000011001001111111000100
RES/SRES=11110110110100000010111110001101
PART B
(PART B: TO BE COMPLETED BY STUDENTS)
(Students must submit the soft copy as per following segments within two hours of
the practical. The soft copy must be uploaded on the ERP or emailed to the
concerned lab in charge faculties at the end of the practical in case the there is no
ERP access available)
Roll No.: C46 Name:Pravin Dattatray Gholap
Grade :
Q.1: Source Code (students need to implement GSM Security Algorithm using any programming
language like Java, Python, etc)
ANS:
A3:
import random
#Dividing the binary key and number into left and right halves
keyBinaryLeft = keyBinary[0:64]
keyBinaryRight = keyBinary[64:]
numberBinaryLeft = numberBinary[0:64]
numberBinaryRight = numberBinary [64:]
#Performing bitwise XOR operation between the left half of key and the right half of number
result1 = int(keyBinaryLeft, 2)^int(numberBinaryRight, 2)
#Performing bitwise XOR operation between the right half of key and the left half of number
#Performing bitwise XOR operation between the results of resulti and result2
result3 = result1^result2
result4 = bin(result3)[2:].zfill(64)
result5 = result4[0:32]
result6 = result4[32:]
A5:
import random
# Shift registers
register_1 += [int(bit) for bit in frame_binary]
register_2 += [int(bit) for bit in frame_binary]
register_3 += [int(bit) for bit in frame_binary]
A8:
def a8_algorithm(secret_key, rand):
"""
A8 Algorithm implementation for GSM
:param secret_key: 64-bit secret key (Ki)
:param rand: 128-bit random number (RAND)
:return: 64-bit cipher key (Ki)
"""
# XOR each bit of the secret key with the corresponding bit of the random number
cipher_key = secret_key ^ rand
return cipher_key
# Example usage
secret_key = 0x0011223344556677 # Replace with the actual secret key
rand_number = 0x0123456789ABCDEF0123456789ABCDEF # Replace with the actual random
number
A5
A8
Q.3: List out various elements of GSM architecture and explain in brief function of each element.
Ans:
GSM architecture comprises several key elements: