personalization: set default values

For all ConfigurableParameter subclasses, set a default_value.

This is useful for user interaction, to prefill an input field that
indicates a valid input to modify to taste.

Related: SYS#6768
Change-Id: I2672fedcbc32cb7a6cb0c233a4a22112bd9aae03
This commit is contained in:
Neels Hofmeyr
2025-03-01 03:58:31 +01:00
parent 311bd5acd4
commit ed3b721669

View File

@@ -115,6 +115,7 @@ class ConfigurableParameter:
min_len = None
max_len = None
allow_len = None # a list of specific lengths
default_value = None
def __init__(self, input_value=None):
self.input_value = input_value # the raw input value as given by caller
@@ -316,6 +317,7 @@ class Iccid(DecimalParam):
name = 'ICCID'
min_len = 18
max_len = 20
default_value = '0' * 18
@classmethod
def validate_val(cls, val):
@@ -336,6 +338,7 @@ class Imsi(DecimalParam):
name = 'IMSI'
min_len = 6
max_len = 15
default_value = '00101' + ('0' * 10)
@classmethod
def apply_val(cls, pes: ProfileElementSequence, val):
@@ -495,6 +498,7 @@ class Puk(DecimalHexParam):
allow_len = 8
rpad = 16
keyReference = None
default_value = '0' * allow_len
@classmethod
def apply_val(cls, pes: ProfileElementSequence, val):
@@ -521,6 +525,7 @@ class Pin(DecimalHexParam):
rpad = 16
min_len = 4
max_len = 8
default_value = '0' * max_len
keyReference = None
@staticmethod
@@ -544,9 +549,10 @@ class Pin(DecimalHexParam):
class Pin1(Pin):
name = 'PIN1'
default_value = '0' * 4 # PIN are usually 4 digits
keyReference = 0x01
class Pin2(Pin):
class Pin2(Pin1):
name = 'PIN2'
keyReference = 0x81
@@ -566,7 +572,7 @@ class Adm1(Pin):
name = 'ADM1'
keyReference = 0x0A
class Adm2(Pin):
class Adm2(Adm1):
name = 'ADM2'
keyReference = 0x0B
@@ -589,6 +595,7 @@ class AlgoConfig(ConfigurableParameter):
class AlgorithmID(DecimalParam, AlgoConfig):
algo_config_key = 'algorithmID'
allow_len = 1
default_value = 1 # Milenage
@classmethod
def validate_val(cls, val):
@@ -604,6 +611,7 @@ class K(BinaryParam, AlgoConfig):
name = 'K'
algo_config_key = 'key'
allow_len = 128 // 8 # length in bytes (from BinaryParam)
default_value = '00' * allow_len
class Opc(K):
name = 'OPc'
@@ -616,6 +624,7 @@ class MilenageRotationConstants(BinaryParam, AlgoConfig):
name = 'MilenageRotation'
algo_config_key = 'rotationConstants'
allow_len = 5 # length in bytes (from BinaryParam)
default_value = '0a 0b 0c 0d 0e'
@classmethod
def validate_val(cls, val):
@@ -639,6 +648,7 @@ class MilenageXoringConstants(BinaryParam, AlgoConfig):
name = 'MilenageXOR'
algo_config_key = 'xoringConstants'
allow_len = 80 # length in bytes (from BinaryParam)
default_value = ' '.join(('00' * 16,) * 5)
class TuakNumberOfKeccak(IntegerParam, AlgoConfig):
"""Number of iterations of Keccak-f[1600] permutation as recomended by Section 7.2 of 3GPP TS 35.231"""
@@ -646,3 +656,4 @@ class TuakNumberOfKeccak(IntegerParam, AlgoConfig):
algo_config_key = 'numberOfKeccak'
min_val = 1
max_val = 255
default_value = '1'