dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41480?usp=email )
Change subject: card_key_provider: remove method _verify_get_data from base class ......................................................................
card_key_provider: remove method _verify_get_data from base class
The method _verify_get_data was intended to be used to verify the user input before it further processed but ended up to be a simple check that only checks the name of the key column very basically.
Unfortunately it is difficult to generalize the check code as the concrete implementation of those checks is highly format dependent. With the advent of eUICCs, we now have two data formats with different lookup keys, so a static list with valid lookup keys is also no longer up to the task.
After all it makes not much sense to keep this method, so let's remove it.
(From the technical perspective, the key column is not limitied to any specif field. In theory it would even be possible to use the KI as lookup key as well, even though it would not make sense in practice)
Related: SYS#7725 Change-Id: Ibf5745fb8a4f927397adff33900731524715d6a9 --- M pySim/card_key_provider.py 1 file changed, 0 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/80/41480/1
diff --git a/pySim/card_key_provider.py b/pySim/card_key_provider.py index 0827b70..cdd871f 100644 --- a/pySim/card_key_provider.py +++ b/pySim/card_key_provider.py @@ -132,26 +132,6 @@ class CardKeyProvider(abc.ABC): """Base class, not containing any concrete implementation."""
- VALID_KEY_FIELD_NAMES = ['ICCID', 'EID', 'IMSI' ] - - # check input parameters, but do nothing concrete yet - def _verify_get_data(self, fields: List[str] = [], key: str = 'ICCID', value: str = "") -> Dict[str, str]: - """Verify multiple fields for identified card. - - Args: - fields : list of valid field names such as 'ADM1', 'PIN1', ... which are to be obtained - key : look-up key to identify card data, such as 'ICCID' - value : value for look-up key to identify card data - Returns: - dictionary of {field, value} strings for each requested field from 'fields' - """ - - if key not in self.VALID_KEY_FIELD_NAMES: - raise ValueError("Key field name '%s' is not a valid field name, valid field names are: %s" % - (key, str(self.VALID_KEY_FIELD_NAMES))) - - return {} - def get_field(self, field: str, key: str = 'ICCID', value: str = "") -> Optional[str]: """get a single field from CSV file using a specified key/value pair""" fields = [field] @@ -186,8 +166,6 @@ self.crypt = CardKeyFieldCryptor(transport_keys)
def get(self, fields: List[str], key: str, value: str) -> Dict[str, str]: - super()._verify_get_data(fields, key, value) - self.csv_file.seek(0) cr = csv.DictReader(self.csv_file) if not cr: