0% found this document useful (0 votes)
9 views3 pages

GSM Security Algorithms Implementation

Uploaded by

rashsarvade02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

GSM Security Algorithms Implementation

Uploaded by

rashsarvade02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment No.

Problem Statement : Implementation of GSM security algorithms (A3/A5/A8)

Code : # A3 Algorithm (Authentication)

def a3(rand, ki):


# Simple example of an A3 algorithm (not secure)
return (rand + ki) % 256 # Simulated response

# A5 Algorithm (Encryption)
def a5(plaintext, key):
key_length = len(key)
encrypted = []

for i in range(len(plaintext)):
[Link](chr(ord(plaintext[i]) ^ ord(key[i %
key_length])))

return ''.join(encrypted)

# A8 Algorithm (Session Key Generation)


def a8(rand, ki):
# Simple example of an A8 algorithm (not secure)
return (rand + ki) % 256 # Simulated session key

# Example values
rand = 42 # Random number from the network
ki = 123 # User's secret key

# Authentication using A3
authentication_response = a3(rand, ki)
print(f"A3 Authentication Response: {authentication_response}")

# Generate session key using A8


session_key = a8(rand, ki)
print(f"A8 Session Key: {session_key}")

# Simulate encryption using A5


plaintext = "Hello GSM"
encrypted_message = a5(plaintext, str(session_key))
print(f"Encrypted Message: {encrypted_message}")

# Decrypt the message (for demonstration)


decrypted_message = a5(encrypted_message, str(session_key))
print(f"Decrypted Message: {decrypted_message}")

You might also like