Key derivation

Comp128-2

COMP128: the GSM SIM authentication algorithm, whose version 1 is broken and kept for reference

unverified Root API only Copyleft feature
Unverified tier.

Source found and wired, correctness not fully proven. Root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.

About Comp128-2

Comp128-2 is one of 3 COMP128 variants in the NextSSL registry, a key derivation function. It uses a 16-byte (128-bit) key, a 12-byte (96-bit) output and a 16-byte salt. NextSSL lists it in the unverified tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).

Overview

COMP128 is the authentication algorithm used on GSM SIM cards to produce authentication responses and session keys. NextSSL carries three versions, and COMP128-1 is marked broken.

COMP128 takes a 128-bit challenge and a 128-bit key and produces a short response and session key through a fixed table-driven construction. Version 1 is the one used in early GSM networks, and versions 2 and 3 were later designs. Functions like this one are specified by 3GPP and run inside mobile operator networks, so they are rarely used outside that setting.

NextSSL lists the three variants comp128-1, comp128-2, comp128-3, each with a 16-byte key and 12-byte output. COMP128-1 is marked broken because published attacks recovered the key from the SIM algorithm's output. Interoperability with a network requires following the specification exactly, including byte order and input layout. NextSSL keeps this entry for research and test vectors, and the registry does not record a review of its design.

COMP128 belongs to the telecom authentication family rather than general-purpose cryptography. Use it only for compatibility with legacy SIMs, and use AES-based or 3GPP algorithms for new work. For general key derivation, HKDF or another standard function is the usual choice. Functions like this one are specified by 3GPP and run inside mobile operator networks, so they are rarely used outside that setting.

History

1998–1998
  1. COMP128-1 reverse engineered and broken by Briceno, Goldberg and Wagner

How it works

  1. The 128-bit challenge is expanded through a fixed sequence of table lookups and permutations.
  2. The output is split into a short response and a session key.
  3. The response is returned to the network, and the session key is kept on the SIM.

Security notes

COMP128-1 is broken, and the other two versions are unverified. Do not use COMP128 for new authentication systems.

Typical uses

GSM SIM authentication researchCompatibility with legacy SIMsNot recommended for new systems

Sizes

FieldBytesMeaning
key16Secret key
out12Output
salt16Salt
info0Info

Use it

from nextssl_demo import NextSSL

root = NextSSL(root=True)   # tier 'unverified' is reachable from the root API only
okm = root.call("kdf", "comp128-2", None, ikm, salt, b"context", 32)[0]

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Other COMP128 variants

2

Frequently asked questions

What is Comp128-2?

Comp128-2 is a KDF in the COMP128 family. COMP128 is the authentication algorithm used on GSM SIM cards to produce authentication responses and session keys.

What are the Comp128-2 sizes?

In NextSSL, Comp128-2 uses: key 16 bytes, output 12 bytes.

Is Comp128-2 safe to use?

Comp128-2 is in the unverified tier. Source found and wired, correctness not fully proven. Root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).

What other COMP128 variants are there?

NextSSL also registers comp128-1, comp128-3 in the COMP128 family.