mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-29 10:49:13 +03:00
pySim.esim.saip: Add ProfileElementOpt{USIM,ISIM} classes
Change-Id: Iebff2e767baa19f272eeddc62d7d5b3a8f665db5
This commit is contained in:
@@ -270,7 +270,9 @@ class ProfileElement:
|
|||||||
'pinCodes': ProfileElementPin,
|
'pinCodes': ProfileElementPin,
|
||||||
'telecom': ProfileElementTelecom,
|
'telecom': ProfileElementTelecom,
|
||||||
'usim': ProfileElementUSIM,
|
'usim': ProfileElementUSIM,
|
||||||
|
'opt-usim': ProfileElementOptUSIM,
|
||||||
'isim': ProfileElementISIM,
|
'isim': ProfileElementISIM,
|
||||||
|
'opt-isim': ProfileElementOptISIM,
|
||||||
'akaParameter': ProfileElementAKA,
|
'akaParameter': ProfileElementAKA,
|
||||||
}
|
}
|
||||||
"""Construct an instance from given raw, DER encoded bytes."""
|
"""Construct an instance from given raw, DER encoded bytes."""
|
||||||
@@ -575,6 +577,19 @@ class ProfileElementUSIM(ProfileElement):
|
|||||||
f = File('ef-imsi', self.decoded['ef-imsi'])
|
f = File('ef-imsi', self.decoded['ef-imsi'])
|
||||||
return dec_imsi(b2h(f.stream.getvalue()))
|
return dec_imsi(b2h(f.stream.getvalue()))
|
||||||
|
|
||||||
|
class ProfileElementOptUSIM(ProfileElement):
|
||||||
|
type = 'opt-usim'
|
||||||
|
|
||||||
|
def __init__(self, decoded: Optional[dict] = None):
|
||||||
|
super().__init__()
|
||||||
|
if decoded:
|
||||||
|
self.decoded = decoded
|
||||||
|
return
|
||||||
|
# provide some reasonable defaults for a MNO-SD
|
||||||
|
self.decoded = OrderedDict()
|
||||||
|
self.decoded['optusim-header'] = { 'mandated': None, 'identification': None}
|
||||||
|
self.decoded['templateID'] = str(oid.ADF_USIMopt_not_by_default_v2)
|
||||||
|
|
||||||
class ProfileElementISIM(ProfileElement):
|
class ProfileElementISIM(ProfileElement):
|
||||||
type = 'isim'
|
type = 'isim'
|
||||||
|
|
||||||
@@ -594,6 +609,20 @@ class ProfileElementISIM(ProfileElement):
|
|||||||
def adf_name(self) -> str:
|
def adf_name(self) -> str:
|
||||||
return b2h(self.decoded['adf-isim'][0][1]['dfName'])
|
return b2h(self.decoded['adf-isim'][0][1]['dfName'])
|
||||||
|
|
||||||
|
class ProfileElementOptISIM(ProfileElement):
|
||||||
|
type = 'opt-isim'
|
||||||
|
|
||||||
|
def __init__(self, decoded: Optional[dict] = None):
|
||||||
|
super().__init__()
|
||||||
|
if decoded:
|
||||||
|
self.decoded = decoded
|
||||||
|
return
|
||||||
|
# provide some reasonable defaults for a MNO-SD
|
||||||
|
self.decoded = OrderedDict()
|
||||||
|
self.decoded['optisim-header'] = { 'mandated': None, 'identification': None}
|
||||||
|
self.decoded['templateID'] = str(oid.ADF_ISIMopt_not_by_default_v2)
|
||||||
|
|
||||||
|
|
||||||
class ProfileElementAKA(ProfileElement):
|
class ProfileElementAKA(ProfileElement):
|
||||||
type = 'akaParameter'
|
type = 'akaParameter'
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class SaipTest(unittest.TestCase):
|
|||||||
"""Test that DER-encoding of PE created by "empty" constructor works without raising exception."""
|
"""Test that DER-encoding of PE created by "empty" constructor works without raising exception."""
|
||||||
for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom,
|
for cls in [ProfileElementMF, ProfileElementPuk, ProfileElementPin, ProfileElementTelecom,
|
||||||
ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA, ProfileElementSD,
|
ProfileElementUSIM, ProfileElementISIM, ProfileElementAKA, ProfileElementSD,
|
||||||
ProfileElementSSD]:
|
ProfileElementSSD, ProfileElementOptUSIM, ProfileElementOptISIM]:
|
||||||
with self.subTest(cls.__name__):
|
with self.subTest(cls.__name__):
|
||||||
pes = ProfileElementSequence()
|
pes = ProfileElementSequence()
|
||||||
inst = cls()
|
inst = cls()
|
||||||
|
|||||||
Reference in New Issue
Block a user