neels has uploaded this change for review. (
https://gerrit.osmocom.org/c/pysim/+/40094?usp=email )
Change subject: personalization: set default values
......................................................................
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
---
M pySim/esim/saip/personalization.py
1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/94/40094/1
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index a97706f..bb6eec3 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -103,6 +103,7 @@
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
@@ -275,6 +276,7 @@
name = 'ICCID'
min_len = 18
max_len = 20
+ default_value = '0' * 18
@classmethod
def validate_val(cls, val):
@@ -295,6 +297,7 @@
name = 'IMSI'
min_len = 6
max_len = 15
+ default_value = '00101' + ('0' * 10)
@classmethod
def apply_val(cls, pes: ProfileElementSequence, val):
@@ -462,6 +465,7 @@
allow_len = 8
rpad = 16
keyReference = None
+ default_value = '0' * allow_len
@classmethod
def apply_val(cls, pes: ProfileElementSequence, val):
@@ -488,6 +492,7 @@
rpad = 16
min_len = 4
max_len = 8
+ default_value = '0' * max_len
keyReference = None
@staticmethod
@@ -511,9 +516,10 @@
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
@@ -533,7 +539,7 @@
name = 'ADM1'
keyReference = 0x0A
-class Adm2(Pin):
+class Adm2(Adm1):
name = 'ADM2'
keyReference = 0x0B
@@ -557,6 +563,7 @@
class AlgorithmID(DecimalParam, AlgoConfig):
algo_config_key = 'algorithmID'
allow_len = 1
+ default_value = 1 # Milenage
@classmethod
def validate_val(cls, val):
@@ -573,6 +580,7 @@
name = 'K'
algo_config_key = 'key'
allow_len = int(128/8) # length in bytes (from BinaryParam)
+ default_value = '00' * allow_len
class Opc(K):
name = 'OPc'
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/40094?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2672fedcbc32cb7a6cb0c233a4a22112bd9aae03
Gerrit-Change-Number: 40094
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>