personalization: set some typical parameter names

These names better match what humans expect to read, for example "PIN1"
instead of "Pin1".

(We still fall back to the __class__.__name__ if a subclass omits a
specific name, see the ConfigurableParameter init.)

Change-Id: I31f390d634e58c384589c50a33ca45d6f86d4e10
This commit is contained in:
Neels Hofmeyr
2025-03-07 21:19:45 +01:00
parent 9605041660
commit 311bd5acd4

View File

@@ -313,6 +313,7 @@ class BinaryParam(ConfigurableParameter):
class Iccid(DecimalParam):
"""ICCID Parameter. Input: string of decimal digits.
If the string of digits is only 18 digits long, add a Luhn check digit."""
name = 'ICCID'
min_len = 18
max_len = 20
@@ -331,6 +332,8 @@ class Iccid(DecimalParam):
class Imsi(DecimalParam):
"""Configurable IMSI. Expects value to be a string of digits. Automatically sets the ACC to
the last digit of the IMSI."""
name = 'IMSI'
min_len = 6
max_len = 15
@@ -506,9 +509,11 @@ class Puk(DecimalHexParam):
f" cannot find pukCode with keyReference={cls.keyReference}")
class Puk1(Puk):
name = 'PUK1'
keyReference = 0x01
class Puk2(Puk):
name = 'PUK2'
keyReference = 0x81
class Pin(DecimalHexParam):
@@ -538,9 +543,11 @@ class Pin(DecimalHexParam):
+ f' {cls.get_name()} cannot find pinCode with keyReference={cls.keyReference}')
class Pin1(Pin):
name = 'PIN1'
keyReference = 0x01
class Pin2(Pin):
name = 'PIN2'
keyReference = 0x81
@classmethod
@@ -556,9 +563,11 @@ class Pin2(Pin):
+ f' {cls.get_name()} cannot find pinCode with keyReference={cls.keyReference} in {naa=}')
class Adm1(Pin):
name = 'ADM1'
keyReference = 0x0A
class Adm2(Pin):
name = 'ADM2'
keyReference = 0x0B
class AlgoConfig(ConfigurableParameter):
@@ -592,16 +601,19 @@ class AlgorithmID(DecimalParam, AlgoConfig):
class K(BinaryParam, AlgoConfig):
"""use validate_val() from BinaryParam, and apply_val() from AlgoConfig"""
name = 'K'
algo_config_key = 'key'
allow_len = 128 // 8 # length in bytes (from BinaryParam)
class Opc(K):
name = 'OPc'
algo_config_key = 'opc'
class MilenageRotationConstants(BinaryParam, AlgoConfig):
"""rotation constants r1,r2,r3,r4,r5 of Milenage, Range 0..127. See 3GPP TS 35.206 Sections 2.3 + 5.3.
Provided as octet-string concatenation of all 5 constants. Expects a bytes-like object of length 5, with
each byte in the range of 0..127. The default value by 3GPP is '4000204060' (hex notation)"""
name = 'MilenageRotation'
algo_config_key = 'rotationConstants'
allow_len = 5 # length in bytes (from BinaryParam)
@@ -624,11 +636,13 @@ class MilenageXoringConstants(BinaryParam, AlgoConfig):
00000000000000000000000000000004
00000000000000000000000000000008
"""
name = 'MilenageXOR'
algo_config_key = 'xoringConstants'
allow_len = 80 # length in bytes (from BinaryParam)
class TuakNumberOfKeccak(IntegerParam, AlgoConfig):
"""Number of iterations of Keccak-f[1600] permutation as recomended by Section 7.2 of 3GPP TS 35.231"""
name = 'KECCAK-N'
algo_config_key = 'numberOfKeccak'
min_val = 1
max_val = 255