Skip to main content

A Python implementation of the COMP128 GSM authentication algorithms.

Project description

COMP128 algorithms for Python

This is a Python implementation of the COMP128 algorithms used in the GSM A3/A8 authentication process.

Usage example

from comp128.comp128v23 import Comp128v23
from comp128.comp128v1 import Comp128v1

ki = bytearray(bytes.fromhex("00112233445566778899AABBCCDDEEFF"))
rand = bytearray(bytes.fromhex("00112233445566778899AABBCCDDEEFF"))

v1_sres, v1_kc = Comp128v1().comp128v1(ki, rand)
v2_sres, v2_kc = Comp128v23().comp128v2(ki, rand)
v3_sres, v3_kc = Comp128v23().comp128v3(ki, rand)

print(f"v1 SRES: {v1_sres.hex()}, KC: {v1_kc.hex()}")
print(f"v2 SRES: {v2_sres.hex()}, KC: {v2_kc.hex()}")
print(f"v3 SRES: {v3_sres.hex()}, KC: {v3_kc.hex()}")

This should output:

v1 SRES: 04a66ba8, KC: f87eb8222cea3400
v2 SRES: 6fb9eb06, KC: 605d954ffdefe800
v3 SRES: 6fb9eb06, KC: 605d954ffdefea7f

Acknowledgements

This code is a Python conversion of the C source code of libosmocore. Full credit goes to the original authors:

  • Harald Welte
  • Kévin Redon
  • Sylvain Munaut

and also to Alexander Couzens for invaluable help and feedback during this conversion.

State of this project

This code is ready for use and has been tested to calculate correct authentication vectors both in unit-tests and in a real-world scenario when calculating 2G authentication vectors on the 38C3 GSM network.

As such, this project is considered "done" and will not receive any further updates unless a bug is found, or a future Python version breaks the code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comp128-1.0.0.tar.gz (88.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comp128-1.0.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file comp128-1.0.0.tar.gz.

File metadata

  • Download URL: comp128-1.0.0.tar.gz
  • Upload date:
  • Size: 88.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for comp128-1.0.0.tar.gz
Algorithm Hash digest
SHA256 44baec3364fce8c0f690fea7957c9a0046382731ff5a9ffa1a076f84ae5c9013
MD5 2b14d244acfacd35aff5d71fb31f50e8
BLAKE2b-256 31fb662a2b7ae497ad5c3de122937b79bf419f88b0352aa57192dcc362c2e831

See more details on using hashes here.

Provenance

The following attestation bundles were made for comp128-1.0.0.tar.gz:

Publisher: python-publish.yml on Takuto88/comp128-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comp128-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: comp128-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for comp128-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebf2637a6bfca3ecef40ef824d59676b61a7ee5e8c97c6ccdc2c240e9491f60b
MD5 3fc2b8593cf7a4d5db22e854da51fdd5
BLAKE2b-256 b1a0e73e9b0683ae8e63addb21dafed713e6cf18667e411647317d9302b3302e

See more details on using hashes here.

Provenance

The following attestation bundles were made for comp128-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on Takuto88/comp128-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page