mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
Get rid of [now] superfluous HexAdapter
With the introduction of using osmocom.construct.{Bytes,GreedyBytes}
in Change-Id I1c8df6350c68aa408ec96ff6cd1e405ceb1a4fbb we don't have a
need for wrapping each instance of Bytes or GreedyBytes into a
HexAdapter anymore. The osmocom.construct.{Bytes,GreedyBytes} will
automatically perform the related hex-string-to-bytes conversion if
needed - and during printing we have osmocom.utils.JsonEncoder that
makes sure to convert any bytes type to a hex-string.
Change-Id: I9c77e420c314f5e74458628dc4e767eab6d97123
This commit is contained in:
72
pySim/cat.py
72
pySim/cat.py
@@ -24,8 +24,8 @@ from construct import Int8ub, Int16ub, Byte, BitsInteger
|
|||||||
from construct import Struct, Enum, BitStruct, this
|
from construct import Struct, Enum, BitStruct, this
|
||||||
from construct import Switch, GreedyRange, FlagsEnum
|
from construct import Switch, GreedyRange, FlagsEnum
|
||||||
from osmocom.tlv import TLV_IE, COMPR_TLV_IE, BER_TLV_IE, TLV_IE_Collection
|
from osmocom.tlv import TLV_IE, COMPR_TLV_IE, BER_TLV_IE, TLV_IE_Collection
|
||||||
from osmocom.construct import PlmnAdapter, BcdAdapter, HexAdapter, GsmStringAdapter, TonNpi, GsmString, Bytes, GreedyBytes
|
from osmocom.construct import PlmnAdapter, BcdAdapter, GsmStringAdapter, TonNpi, GsmString, Bytes, GreedyBytes
|
||||||
from osmocom.utils import b2h
|
from osmocom.utils import b2h, h2b
|
||||||
from pySim.utils import dec_xplmn_w_act
|
from pySim.utils import dec_xplmn_w_act
|
||||||
|
|
||||||
# Tag values as per TS 101 220 Table 7.23
|
# Tag values as per TS 101 220 Table 7.23
|
||||||
@@ -255,24 +255,24 @@ class Result(COMPR_TLV_IE, tag=0x83):
|
|||||||
'launch_browser_generic_error': AddlInfoLaunchBrowser,
|
'launch_browser_generic_error': AddlInfoLaunchBrowser,
|
||||||
'bearer_independent_protocol_error': AddlInfoBip,
|
'bearer_independent_protocol_error': AddlInfoBip,
|
||||||
'frames_error': AddlInfoFrames
|
'frames_error': AddlInfoFrames
|
||||||
}, default=HexAdapter(GreedyBytes)))
|
}, default=GreedyBytes))
|
||||||
|
|
||||||
# TS 102 223 Section 8.13 + TS 31.111 Section 8.13
|
# TS 102 223 Section 8.13 + TS 31.111 Section 8.13
|
||||||
class SMS_TPDU(COMPR_TLV_IE, tag=0x8B):
|
class SMS_TPDU(COMPR_TLV_IE, tag=0x8B):
|
||||||
_construct = Struct('tpdu'/HexAdapter(GreedyBytes))
|
_construct = Struct('tpdu'/GreedyBytes)
|
||||||
|
|
||||||
# TS 31.111 Section 8.14
|
# TS 31.111 Section 8.14
|
||||||
class SsString(COMPR_TLV_IE, tag=0x89):
|
class SsString(COMPR_TLV_IE, tag=0x89):
|
||||||
_construct = Struct('ton_npi'/TonNpi, 'ss_string'/HexAdapter(GreedyBytes))
|
_construct = Struct('ton_npi'/TonNpi, 'ss_string'/GreedyBytes)
|
||||||
|
|
||||||
|
|
||||||
# TS 102 223 Section 8.15
|
# TS 102 223 Section 8.15
|
||||||
class TextString(COMPR_TLV_IE, tag=0x8D):
|
class TextString(COMPR_TLV_IE, tag=0x8D):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '8d090470617373776f7264', {'dcs': 4, 'text_string': '70617373776f7264'} ),
|
( '8d090470617373776f7264', {'dcs': 4, 'text_string': b'password'} )
|
||||||
]
|
]
|
||||||
_construct = Struct('dcs'/Int8ub, # TS 03.38
|
_construct = Struct('dcs'/Int8ub, # TS 03.38
|
||||||
'text_string'/HexAdapter(GreedyBytes))
|
'text_string'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.16
|
# TS 102 223 Section 8.16
|
||||||
class Tone(COMPR_TLV_IE, tag=0x8E):
|
class Tone(COMPR_TLV_IE, tag=0x8E):
|
||||||
@@ -308,11 +308,11 @@ class Tone(COMPR_TLV_IE, tag=0x8E):
|
|||||||
# TS 31 111 Section 8.17
|
# TS 31 111 Section 8.17
|
||||||
class USSDString(COMPR_TLV_IE, tag=0x8A):
|
class USSDString(COMPR_TLV_IE, tag=0x8A):
|
||||||
_construct = Struct('dcs'/Int8ub,
|
_construct = Struct('dcs'/Int8ub,
|
||||||
'ussd_string'/HexAdapter(GreedyBytes))
|
'ussd_string'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.18
|
# TS 102 223 Section 8.18
|
||||||
class FileList(COMPR_TLV_IE, tag=0x92):
|
class FileList(COMPR_TLV_IE, tag=0x92):
|
||||||
FileId=HexAdapter(Bytes(2))
|
FileId=Bytes(2)
|
||||||
_construct = Struct('number_of_files'/Int8ub,
|
_construct = Struct('number_of_files'/Int8ub,
|
||||||
'files'/GreedyRange(FileId))
|
'files'/GreedyRange(FileId))
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ class NetworkMeasurementResults(COMPR_TLV_IE, tag=0x96):
|
|||||||
# TS 102 223 Section 8.23
|
# TS 102 223 Section 8.23
|
||||||
class DefaultText(COMPR_TLV_IE, tag=0x97):
|
class DefaultText(COMPR_TLV_IE, tag=0x97):
|
||||||
_construct = Struct('dcs'/Int8ub,
|
_construct = Struct('dcs'/Int8ub,
|
||||||
'text_string'/HexAdapter(GreedyBytes))
|
'text_string'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.24
|
# TS 102 223 Section 8.24
|
||||||
class ItemsNextActionIndicator(COMPR_TLV_IE, tag=0x98):
|
class ItemsNextActionIndicator(COMPR_TLV_IE, tag=0x98):
|
||||||
@@ -394,7 +394,7 @@ class ItemIconIdentifierList(COMPR_TLV_IE, tag=0x9f):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.35
|
# TS 102 223 Section 8.35
|
||||||
class CApdu(COMPR_TLV_IE, tag=0xA2):
|
class CApdu(COMPR_TLV_IE, tag=0xA2):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.37
|
# TS 102 223 Section 8.37
|
||||||
class TimerIdentifier(COMPR_TLV_IE, tag=0xA4):
|
class TimerIdentifier(COMPR_TLV_IE, tag=0xA4):
|
||||||
@@ -406,7 +406,7 @@ class TimerValue(COMPR_TLV_IE, tag=0xA5):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.40
|
# TS 102 223 Section 8.40
|
||||||
class AtCommand(COMPR_TLV_IE, tag=0xA8):
|
class AtCommand(COMPR_TLV_IE, tag=0xA8):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.43
|
# TS 102 223 Section 8.43
|
||||||
class ImmediateResponse(COMPR_TLV_IE, tag=0xAB):
|
class ImmediateResponse(COMPR_TLV_IE, tag=0xAB):
|
||||||
@@ -418,7 +418,7 @@ class DtmfString(COMPR_TLV_IE, tag=0xAC):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.45
|
# TS 102 223 Section 8.45
|
||||||
class Language(COMPR_TLV_IE, tag=0xAD):
|
class Language(COMPR_TLV_IE, tag=0xAD):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 31.111 Section 8.46
|
# TS 31.111 Section 8.46
|
||||||
class TimingAdvance(COMPR_TLV_IE, tag=0xC6):
|
class TimingAdvance(COMPR_TLV_IE, tag=0xC6):
|
||||||
@@ -440,7 +440,7 @@ class Bearer(COMPR_TLV_IE, tag=0xB2):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.50
|
# TS 102 223 Section 8.50
|
||||||
class ProvisioningFileReference(COMPR_TLV_IE, tag=0xB3):
|
class ProvisioningFileReference(COMPR_TLV_IE, tag=0xB3):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.51
|
# TS 102 223 Section 8.51
|
||||||
class BrowserTerminationCause(COMPR_TLV_IE, tag=0xB4):
|
class BrowserTerminationCause(COMPR_TLV_IE, tag=0xB4):
|
||||||
@@ -449,7 +449,7 @@ class BrowserTerminationCause(COMPR_TLV_IE, tag=0xB4):
|
|||||||
# TS 102 223 Section 8.52
|
# TS 102 223 Section 8.52
|
||||||
class BearerDescription(COMPR_TLV_IE, tag=0xB5):
|
class BearerDescription(COMPR_TLV_IE, tag=0xB5):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( 'b50103', {'bearer_parameters': '', 'bearer_type': 'default'} ),
|
( 'b50103', {'bearer_parameters': b'', 'bearer_type': 'default'} ),
|
||||||
]
|
]
|
||||||
# TS 31.111 Section 8.52.1
|
# TS 31.111 Section 8.52.1
|
||||||
BearerParsCs = Struct('data_rate'/Int8ub,
|
BearerParsCs = Struct('data_rate'/Int8ub,
|
||||||
@@ -492,11 +492,11 @@ class BearerDescription(COMPR_TLV_IE, tag=0xB5):
|
|||||||
'packet_grps_utran_eutran': BearerParsPacket,
|
'packet_grps_utran_eutran': BearerParsPacket,
|
||||||
'packet_with_extd_params': BearerParsPacketExt,
|
'packet_with_extd_params': BearerParsPacketExt,
|
||||||
'ng_ran': BearerParsNgRan,
|
'ng_ran': BearerParsNgRan,
|
||||||
}, default=HexAdapter(GreedyBytes)))
|
}, default=GreedyBytes))
|
||||||
|
|
||||||
# TS 102 223 Section 8.53
|
# TS 102 223 Section 8.53
|
||||||
class ChannelData(COMPR_TLV_IE, tag = 0xB6):
|
class ChannelData(COMPR_TLV_IE, tag = 0xB6):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.54
|
# TS 102 223 Section 8.54
|
||||||
class ChannelDataLength(COMPR_TLV_IE, tag = 0xB7):
|
class ChannelDataLength(COMPR_TLV_IE, tag = 0xB7):
|
||||||
@@ -510,15 +510,15 @@ class BufferSize(COMPR_TLV_IE, tag = 0xB9):
|
|||||||
class ChannelStatus(COMPR_TLV_IE, tag = 0xB8):
|
class ChannelStatus(COMPR_TLV_IE, tag = 0xB8):
|
||||||
# complex decoding, depends on out-of-band context/knowledge :(
|
# complex decoding, depends on out-of-band context/knowledge :(
|
||||||
# for default / TCP Client mode: bit 8 of first byte indicates connected, 3 LSB indicate channel nr
|
# for default / TCP Client mode: bit 8 of first byte indicates connected, 3 LSB indicate channel nr
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.58
|
# TS 102 223 Section 8.58
|
||||||
class OtherAddress(COMPR_TLV_IE, tag = 0xBE):
|
class OtherAddress(COMPR_TLV_IE, tag = 0xBE):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( 'be052101020304', {'address': '01020304', 'type_of_address': 'ipv4'} ),
|
( 'be052101020304', {'address': h2b('01020304'), 'type_of_address': 'ipv4'} ),
|
||||||
]
|
]
|
||||||
_construct = Struct('type_of_address'/Enum(Int8ub, ipv4=0x21, ipv6=0x57),
|
_construct = Struct('type_of_address'/Enum(Int8ub, ipv4=0x21, ipv6=0x57),
|
||||||
'address'/HexAdapter(GreedyBytes))
|
'address'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.59
|
# TS 102 223 Section 8.59
|
||||||
class UiccTransportLevel(COMPR_TLV_IE, tag = 0xBC):
|
class UiccTransportLevel(COMPR_TLV_IE, tag = 0xBC):
|
||||||
@@ -532,7 +532,7 @@ class UiccTransportLevel(COMPR_TLV_IE, tag = 0xBC):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.60
|
# TS 102 223 Section 8.60
|
||||||
class Aid(COMPR_TLV_IE, tag=0xAF):
|
class Aid(COMPR_TLV_IE, tag=0xAF):
|
||||||
_construct = Struct('aid'/HexAdapter(GreedyBytes))
|
_construct = Struct('aid'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.61
|
# TS 102 223 Section 8.61
|
||||||
class AccessTechnology(COMPR_TLV_IE, tag=0xBF):
|
class AccessTechnology(COMPR_TLV_IE, tag=0xBF):
|
||||||
@@ -546,35 +546,35 @@ class ServiceRecord(COMPR_TLV_IE, tag=0xC1):
|
|||||||
BearerTechId = Enum(Int8ub, technology_independent=0, bluetooth=1, irda=2, rs232=3, usb=4)
|
BearerTechId = Enum(Int8ub, technology_independent=0, bluetooth=1, irda=2, rs232=3, usb=4)
|
||||||
_construct = Struct('local_bearer_technology'/BearerTechId,
|
_construct = Struct('local_bearer_technology'/BearerTechId,
|
||||||
'service_identifier'/Int8ub,
|
'service_identifier'/Int8ub,
|
||||||
'service_record'/HexAdapter(GreedyBytes))
|
'service_record'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.64
|
# TS 102 223 Section 8.64
|
||||||
class DeviceFilter(COMPR_TLV_IE, tag=0xC2):
|
class DeviceFilter(COMPR_TLV_IE, tag=0xC2):
|
||||||
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
||||||
'device_filter'/HexAdapter(GreedyBytes))
|
'device_filter'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.65
|
# TS 102 223 Section 8.65
|
||||||
class ServiceSearchIE(COMPR_TLV_IE, tag=0xC3):
|
class ServiceSearchIE(COMPR_TLV_IE, tag=0xC3):
|
||||||
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
||||||
'service_search'/HexAdapter(GreedyBytes))
|
'service_search'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.66
|
# TS 102 223 Section 8.66
|
||||||
class AttributeInformation(COMPR_TLV_IE, tag=0xC4):
|
class AttributeInformation(COMPR_TLV_IE, tag=0xC4):
|
||||||
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
_construct = Struct('local_bearer_technology'/ServiceRecord.BearerTechId,
|
||||||
'attribute_information'/HexAdapter(GreedyBytes))
|
'attribute_information'/GreedyBytes)
|
||||||
|
|
||||||
|
|
||||||
# TS 102 223 Section 8.68
|
# TS 102 223 Section 8.68
|
||||||
class RemoteEntityAddress(COMPR_TLV_IE, tag=0xC9):
|
class RemoteEntityAddress(COMPR_TLV_IE, tag=0xC9):
|
||||||
_construct = Struct('coding_type'/Enum(Int8ub, ieee802_16=0, irda=1),
|
_construct = Struct('coding_type'/Enum(Int8ub, ieee802_16=0, irda=1),
|
||||||
'address'/HexAdapter(GreedyBytes))
|
'address'/GreedyBytes)
|
||||||
|
|
||||||
# TS 102 223 Section 8.70
|
# TS 102 223 Section 8.70
|
||||||
class NetworkAccessName(COMPR_TLV_IE, tag=0xC7):
|
class NetworkAccessName(COMPR_TLV_IE, tag=0xC7):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( 'c704036e6161', '036e6161' ),
|
( 'c704036e6161', h2b('036e6161') ),
|
||||||
]
|
]
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.72
|
# TS 102 223 Section 8.72
|
||||||
class TextAttribute(COMPR_TLV_IE, tag=0xD0):
|
class TextAttribute(COMPR_TLV_IE, tag=0xD0):
|
||||||
@@ -618,15 +618,15 @@ class FrameIdentifier(COMPR_TLV_IE, tag=0xE8):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.82
|
# TS 102 223 Section 8.82
|
||||||
class MultimediaMessageReference(COMPR_TLV_IE, tag=0xEA):
|
class MultimediaMessageReference(COMPR_TLV_IE, tag=0xEA):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.83
|
# TS 102 223 Section 8.83
|
||||||
class MultimediaMessageIdentifier(COMPR_TLV_IE, tag=0xEB):
|
class MultimediaMessageIdentifier(COMPR_TLV_IE, tag=0xEB):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.85
|
# TS 102 223 Section 8.85
|
||||||
class MmContentIdentifier(COMPR_TLV_IE, tag=0xEE):
|
class MmContentIdentifier(COMPR_TLV_IE, tag=0xEE):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.89
|
# TS 102 223 Section 8.89
|
||||||
class ActivateDescriptor(COMPR_TLV_IE, tag=0xFB):
|
class ActivateDescriptor(COMPR_TLV_IE, tag=0xFB):
|
||||||
@@ -649,7 +649,7 @@ class ContactlessFunctionalityState(COMPR_TLV_IE, tag=0xD4):
|
|||||||
# TS 31.111 Section 8.91
|
# TS 31.111 Section 8.91
|
||||||
class RoutingAreaIdentification(COMPR_TLV_IE, tag=0xF3):
|
class RoutingAreaIdentification(COMPR_TLV_IE, tag=0xF3):
|
||||||
_construct = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)),
|
_construct = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)),
|
||||||
'lac'/HexAdapter(Bytes(2)),
|
'lac'/Bytes(2),
|
||||||
'rac'/Int8ub)
|
'rac'/Int8ub)
|
||||||
|
|
||||||
# TS 31.111 Section 8.92
|
# TS 31.111 Section 8.92
|
||||||
@@ -709,15 +709,15 @@ class EcatSequenceNumber(COMPR_TLV_IE, tag=0xA1):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.99
|
# TS 102 223 Section 8.99
|
||||||
class EncryptedTlvList(COMPR_TLV_IE, tag=0xA2):
|
class EncryptedTlvList(COMPR_TLV_IE, tag=0xA2):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.100
|
# TS 102 223 Section 8.100
|
||||||
class Mac(COMPR_TLV_IE, tag=0xE0):
|
class Mac(COMPR_TLV_IE, tag=0xE0):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.101
|
# TS 102 223 Section 8.101
|
||||||
class SaTemplate(COMPR_TLV_IE, tag=0xA3):
|
class SaTemplate(COMPR_TLV_IE, tag=0xA3):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.103
|
# TS 102 223 Section 8.103
|
||||||
class RefreshEnforcementPolicy(COMPR_TLV_IE, tag=0xBA):
|
class RefreshEnforcementPolicy(COMPR_TLV_IE, tag=0xBA):
|
||||||
@@ -725,7 +725,7 @@ class RefreshEnforcementPolicy(COMPR_TLV_IE, tag=0xBA):
|
|||||||
|
|
||||||
# TS 102 223 Section 8.104
|
# TS 102 223 Section 8.104
|
||||||
class DnsServerAddress(COMPR_TLV_IE, tag=0xC0):
|
class DnsServerAddress(COMPR_TLV_IE, tag=0xC0):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# TS 102 223 Section 8.105
|
# TS 102 223 Section 8.105
|
||||||
class SupportedRadioAccessTechnologies(COMPR_TLV_IE, tag=0xB4):
|
class SupportedRadioAccessTechnologies(COMPR_TLV_IE, tag=0xB4):
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class EF_AD(TransparentEF):
|
|||||||
'''3.4.33 Administrative Data'''
|
'''3.4.33 Administrative Data'''
|
||||||
|
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "000000", { 'ms_operation_mode' : 'normal', 'additional_info' : '0000', 'rfu' : '' } ),
|
( "000000", { 'ms_operation_mode' : 'normal', 'additional_info' : b'\x00\x00', 'rfu' : b'' } ),
|
||||||
]
|
]
|
||||||
_test_no_pad = True
|
_test_no_pad = True
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ class EF_AD(TransparentEF):
|
|||||||
# Byte 1: Display Condition
|
# Byte 1: Display Condition
|
||||||
'ms_operation_mode'/Enum(Byte, self.OP_MODE),
|
'ms_operation_mode'/Enum(Byte, self.OP_MODE),
|
||||||
# Bytes 2-3: Additional information
|
# Bytes 2-3: Additional information
|
||||||
'additional_info'/HexAdapter(Bytes(2)),
|
'additional_info'/Bytes(2),
|
||||||
# Bytes 4..: RFU
|
# Bytes 4..: RFU
|
||||||
'rfu'/HexAdapter(GreedyBytesRFU),
|
'rfu'/GreedyBytesRFU,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class SetDefaultDpAddress(BER_TLV_IE, tag=0xbf3f, nested=[DefaultDpAddress, SetD
|
|||||||
|
|
||||||
# SGP.22 Section 5.7.7: GetEUICCChallenge
|
# SGP.22 Section 5.7.7: GetEUICCChallenge
|
||||||
class EuiccChallenge(BER_TLV_IE, tag=0x80):
|
class EuiccChallenge(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(Bytes(16))
|
_construct = Bytes(16)
|
||||||
class GetEuiccChallenge(BER_TLV_IE, tag=0xbf2e, nested=[EuiccChallenge]):
|
class GetEuiccChallenge(BER_TLV_IE, tag=0xbf2e, nested=[EuiccChallenge]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class GetEuiccChallenge(BER_TLV_IE, tag=0xbf2e, nested=[EuiccChallenge]):
|
|||||||
class SVN(BER_TLV_IE, tag=0x82):
|
class SVN(BER_TLV_IE, tag=0x82):
|
||||||
_construct = VersionType
|
_construct = VersionType
|
||||||
class SubjectKeyIdentifier(BER_TLV_IE, tag=0x04):
|
class SubjectKeyIdentifier(BER_TLV_IE, tag=0x04):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class EuiccCiPkiListForVerification(BER_TLV_IE, tag=0xa9, nested=[SubjectKeyIdentifier]):
|
class EuiccCiPkiListForVerification(BER_TLV_IE, tag=0xa9, nested=[SubjectKeyIdentifier]):
|
||||||
pass
|
pass
|
||||||
class EuiccCiPkiListForSigning(BER_TLV_IE, tag=0xaa, nested=[SubjectKeyIdentifier]):
|
class EuiccCiPkiListForSigning(BER_TLV_IE, tag=0xaa, nested=[SubjectKeyIdentifier]):
|
||||||
@@ -140,15 +140,15 @@ class ProfileVersion(BER_TLV_IE, tag=0x81):
|
|||||||
class EuiccFirmwareVer(BER_TLV_IE, tag=0x83):
|
class EuiccFirmwareVer(BER_TLV_IE, tag=0x83):
|
||||||
_construct = VersionType
|
_construct = VersionType
|
||||||
class ExtCardResource(BER_TLV_IE, tag=0x84):
|
class ExtCardResource(BER_TLV_IE, tag=0x84):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class UiccCapability(BER_TLV_IE, tag=0x85):
|
class UiccCapability(BER_TLV_IE, tag=0x85):
|
||||||
_construct = HexAdapter(GreedyBytes) # FIXME
|
_construct = GreedyBytes # FIXME
|
||||||
class TS102241Version(BER_TLV_IE, tag=0x86):
|
class TS102241Version(BER_TLV_IE, tag=0x86):
|
||||||
_construct = VersionType
|
_construct = VersionType
|
||||||
class GlobalPlatformVersion(BER_TLV_IE, tag=0x87):
|
class GlobalPlatformVersion(BER_TLV_IE, tag=0x87):
|
||||||
_construct = VersionType
|
_construct = VersionType
|
||||||
class RspCapability(BER_TLV_IE, tag=0x88):
|
class RspCapability(BER_TLV_IE, tag=0x88):
|
||||||
_construct = HexAdapter(GreedyBytes) # FIXME
|
_construct = GreedyBytes # FIXME
|
||||||
class EuiccCategory(BER_TLV_IE, tag=0x8b):
|
class EuiccCategory(BER_TLV_IE, tag=0x8b):
|
||||||
_construct = Enum(Int8ub, other=0, basicEuicc=1, mediumEuicc=2, contactlessEuicc=3)
|
_construct = Enum(Int8ub, other=0, basicEuicc=1, mediumEuicc=2, contactlessEuicc=3)
|
||||||
class PpVersion(BER_TLV_IE, tag=0x04):
|
class PpVersion(BER_TLV_IE, tag=0x04):
|
||||||
@@ -211,7 +211,7 @@ class TagList(BER_TLV_IE, tag=0x5c):
|
|||||||
class ProfileInfoListReq(BER_TLV_IE, tag=0xbf2d, nested=[TagList]): # FIXME: SearchCriteria
|
class ProfileInfoListReq(BER_TLV_IE, tag=0xbf2d, nested=[TagList]): # FIXME: SearchCriteria
|
||||||
pass
|
pass
|
||||||
class IsdpAid(BER_TLV_IE, tag=0x4f):
|
class IsdpAid(BER_TLV_IE, tag=0x4f):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class ProfileState(BER_TLV_IE, tag=0x9f70):
|
class ProfileState(BER_TLV_IE, tag=0x9f70):
|
||||||
_construct = Enum(Int8ub, disabled=0, enabled=1)
|
_construct = Enum(Int8ub, disabled=0, enabled=1)
|
||||||
class ProfileNickname(BER_TLV_IE, tag=0x90):
|
class ProfileNickname(BER_TLV_IE, tag=0x90):
|
||||||
@@ -281,7 +281,7 @@ class EuiccMemoryResetResp(BER_TLV_IE, tag=0xbf34, nested=[ResetResult]):
|
|||||||
|
|
||||||
# SGP.22 Section 5.7.20 GetEID
|
# SGP.22 Section 5.7.20 GetEID
|
||||||
class EidValue(BER_TLV_IE, tag=0x5a):
|
class EidValue(BER_TLV_IE, tag=0x5a):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class GetEuiccData(BER_TLV_IE, tag=0xbf3e, nested=[TagList, EidValue]):
|
class GetEuiccData(BER_TLV_IE, tag=0xbf3e, nested=[TagList, EidValue]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ class CardApplicationISDR(pySim.global_platform.CardApplicationSD):
|
|||||||
ged_cmd = GetEuiccData(children=[TagList(decoded=[0x5A])])
|
ged_cmd = GetEuiccData(children=[TagList(decoded=[0x5A])])
|
||||||
ged = CardApplicationISDR.store_data_tlv(scc, ged_cmd, GetEuiccData)
|
ged = CardApplicationISDR.store_data_tlv(scc, ged_cmd, GetEuiccData)
|
||||||
d = ged.to_dict()
|
d = ged.to_dict()
|
||||||
return flatten_dict_lists(d['get_euicc_data'])['eid_value']
|
return b2h(flatten_dict_lists(d['get_euicc_data'])['eid_value'])
|
||||||
|
|
||||||
def decode_select_response(self, data_hex: Hexstr) -> object:
|
def decode_select_response(self, data_hex: Hexstr) -> object:
|
||||||
t = FciTemplate()
|
t = FciTemplate()
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ class CurrentSecurityLevel(BER_TLV_IE, tag=0xd3):
|
|||||||
|
|
||||||
# GlobalPlatform v2.3.1 Section 11.3.3.1.3
|
# GlobalPlatform v2.3.1 Section 11.3.3.1.3
|
||||||
class ApplicationAID(BER_TLV_IE, tag=0x4f):
|
class ApplicationAID(BER_TLV_IE, tag=0x4f):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class ApplicationTemplate(BER_TLV_IE, tag=0x61, ntested=[ApplicationAID]):
|
class ApplicationTemplate(BER_TLV_IE, tag=0x61, ntested=[ApplicationAID]):
|
||||||
pass
|
pass
|
||||||
class ListOfApplications(BER_TLV_IE, tag=0x2f00, nested=[ApplicationTemplate]):
|
class ListOfApplications(BER_TLV_IE, tag=0x2f00, nested=[ApplicationTemplate]):
|
||||||
@@ -425,10 +425,10 @@ class FciTemplate(BER_TLV_IE, tag=0x6f, nested=FciTemplateNestedList):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class IssuerIdentificationNumber(BER_TLV_IE, tag=0x42):
|
class IssuerIdentificationNumber(BER_TLV_IE, tag=0x42):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class CardImageNumber(BER_TLV_IE, tag=0x45):
|
class CardImageNumber(BER_TLV_IE, tag=0x45):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class SequenceCounterOfDefaultKvn(BER_TLV_IE, tag=0xc1):
|
class SequenceCounterOfDefaultKvn(BER_TLV_IE, tag=0xc1):
|
||||||
_construct = GreedyInteger()
|
_construct = GreedyInteger()
|
||||||
@@ -487,7 +487,7 @@ class ImplicitSelectionParameter(BER_TLV_IE, tag=0xcf):
|
|||||||
|
|
||||||
# Section 11.4.3.1 Table 11-36
|
# Section 11.4.3.1 Table 11-36
|
||||||
class ExecutableLoadFileAID(BER_TLV_IE, tag=0xc4):
|
class ExecutableLoadFileAID(BER_TLV_IE, tag=0xc4):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# Section 11.4.3.1 Table 11-36
|
# Section 11.4.3.1 Table 11-36
|
||||||
class ExecutableLoadFileVersionNumber(BER_TLV_IE, tag=0xce):
|
class ExecutableLoadFileVersionNumber(BER_TLV_IE, tag=0xce):
|
||||||
@@ -495,15 +495,15 @@ class ExecutableLoadFileVersionNumber(BER_TLV_IE, tag=0xce):
|
|||||||
# specification. It shall consist of the version information contained in the original Load File: on a
|
# specification. It shall consist of the version information contained in the original Load File: on a
|
||||||
# Java Card based card, this version number represents the major and minor version attributes of the
|
# Java Card based card, this version number represents the major and minor version attributes of the
|
||||||
# original Load File Data Block.
|
# original Load File Data Block.
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# Section 11.4.3.1 Table 11-36
|
# Section 11.4.3.1 Table 11-36
|
||||||
class ExecutableModuleAID(BER_TLV_IE, tag=0x84):
|
class ExecutableModuleAID(BER_TLV_IE, tag=0x84):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# Section 11.4.3.1 Table 11-36
|
# Section 11.4.3.1 Table 11-36
|
||||||
class AssociatedSecurityDomainAID(BER_TLV_IE, tag=0xcc):
|
class AssociatedSecurityDomainAID(BER_TLV_IE, tag=0xcc):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# Section 11.4.3.1 Table 11-36
|
# Section 11.4.3.1 Table 11-36
|
||||||
class GpRegistryRelatedData(BER_TLV_IE, tag=0xe3, nested=[ApplicationAID, LifeCycleState, Privileges,
|
class GpRegistryRelatedData(BER_TLV_IE, tag=0xe3, nested=[ApplicationAID, LifeCycleState, Privileges,
|
||||||
@@ -640,8 +640,8 @@ class ADF_SD(CardADF):
|
|||||||
|
|
||||||
# Table 11-68: Key Data Field - Format 1 (Basic Format)
|
# Table 11-68: Key Data Field - Format 1 (Basic Format)
|
||||||
KeyDataBasic = GreedyRange(Struct('key_type'/KeyType,
|
KeyDataBasic = GreedyRange(Struct('key_type'/KeyType,
|
||||||
'kcb'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'kcb'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'kcv'/HexAdapter(Prefixed(Int8ub, GreedyBytes))))
|
'kcv'/Prefixed(Int8ub, GreedyBytes)))
|
||||||
|
|
||||||
def put_key(self, old_kvn:int, kvn: int, kid: int, key_dict: dict) -> bytes:
|
def put_key(self, old_kvn:int, kvn: int, kid: int, key_dict: dict) -> bytes:
|
||||||
"""Perform the GlobalPlatform PUT KEY command in order to store a new key on the card.
|
"""Perform the GlobalPlatform PUT KEY command in order to store a new key on the card.
|
||||||
@@ -704,7 +704,7 @@ class ADF_SD(CardADF):
|
|||||||
def set_status(self, scope:str, status:str, aid:Hexstr = ''):
|
def set_status(self, scope:str, status:str, aid:Hexstr = ''):
|
||||||
SetStatus = Struct(Const(0x80, Byte), Const(0xF0, Byte),
|
SetStatus = Struct(Const(0x80, Byte), Const(0xF0, Byte),
|
||||||
'scope'/SetStatusScope, 'status'/CLifeCycleState,
|
'scope'/SetStatusScope, 'status'/CLifeCycleState,
|
||||||
'aid'/HexAdapter(Prefixed(Int8ub, COptional(GreedyBytes))))
|
'aid'/Prefixed(Int8ub, COptional(GreedyBytes)))
|
||||||
apdu = build_construct(SetStatus, {'scope':scope, 'status':status, 'aid':aid})
|
apdu = build_construct(SetStatus, {'scope':scope, 'status':status, 'aid':aid})
|
||||||
_data, _sw = self._cmd.lchan.scc.send_apdu_checksw(b2h(apdu))
|
_data, _sw = self._cmd.lchan.scc.send_apdu_checksw(b2h(apdu))
|
||||||
|
|
||||||
@@ -738,12 +738,12 @@ class ADF_SD(CardADF):
|
|||||||
@cmd2.with_argparser(inst_inst_parser)
|
@cmd2.with_argparser(inst_inst_parser)
|
||||||
def do_install_for_install(self, opts):
|
def do_install_for_install(self, opts):
|
||||||
"""Perform GlobalPlatform INSTALL [for install] command in order to install an application."""
|
"""Perform GlobalPlatform INSTALL [for install] command in order to install an application."""
|
||||||
InstallForInstallCD = Struct('load_file_aid'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
InstallForInstallCD = Struct('load_file_aid'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'module_aid'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'module_aid'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'application_aid'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'application_aid'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'privileges'/Prefixed(Int8ub, Privileges._construct),
|
'privileges'/Prefixed(Int8ub, Privileges._construct),
|
||||||
'install_parameters'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'install_parameters'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'install_token'/HexAdapter(Prefixed(Int8ub, GreedyBytes)))
|
'install_token'/Prefixed(Int8ub, GreedyBytes))
|
||||||
p1 = 0x04
|
p1 = 0x04
|
||||||
if opts.make_selectable:
|
if opts.make_selectable:
|
||||||
p1 |= 0x08
|
p1 |= 0x08
|
||||||
@@ -770,11 +770,11 @@ class ADF_SD(CardADF):
|
|||||||
"""Perform GlobalPlatform INSTALL [for load] command in order to prepare to load an application."""
|
"""Perform GlobalPlatform INSTALL [for load] command in order to prepare to load an application."""
|
||||||
if opts.load_token != '' and opts.load_file_hash == '':
|
if opts.load_token != '' and opts.load_file_hash == '':
|
||||||
raise ValueError('Load File Data Block Hash is mandatory if a Load Token is present')
|
raise ValueError('Load File Data Block Hash is mandatory if a Load Token is present')
|
||||||
InstallForLoadCD = Struct('load_file_aid'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
InstallForLoadCD = Struct('load_file_aid'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'security_domain_aid'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'security_domain_aid'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'load_file_hash'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'load_file_hash'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'load_parameters'/HexAdapter(Prefixed(Int8ub, GreedyBytes)),
|
'load_parameters'/Prefixed(Int8ub, GreedyBytes),
|
||||||
'load_token'/HexAdapter(Prefixed(Int8ub, GreedyBytes)))
|
'load_token'/Prefixed(Int8ub, GreedyBytes))
|
||||||
ifl_bytes = build_construct(InstallForLoadCD, vars(opts))
|
ifl_bytes = build_construct(InstallForLoadCD, vars(opts))
|
||||||
self.install(0x02, 0x00, b2h(ifl_bytes))
|
self.install(0x02, 0x00, b2h(ifl_bytes))
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from osmocom.tlv import *
|
|||||||
|
|
||||||
class AppSpecificParams(BER_TLV_IE, tag=0xC9):
|
class AppSpecificParams(BER_TLV_IE, tag=0xC9):
|
||||||
# GPD_SPE_013, table 11-49
|
# GPD_SPE_013, table 11-49
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class VolatileMemoryQuota(BER_TLV_IE, tag=0xC7):
|
class VolatileMemoryQuota(BER_TLV_IE, tag=0xC7):
|
||||||
# GPD_SPE_013, table 11-49
|
# GPD_SPE_013, table 11-49
|
||||||
@@ -36,7 +36,7 @@ class NonVolatileMemoryQuota(BER_TLV_IE, tag=0xC8):
|
|||||||
class StkParameter(BER_TLV_IE, tag=0xCA):
|
class StkParameter(BER_TLV_IE, tag=0xCA):
|
||||||
# GPD_SPE_013, table 11-49
|
# GPD_SPE_013, table 11-49
|
||||||
# ETSI TS 102 226, section 8.2.1.3.2.1
|
# ETSI TS 102 226, section 8.2.1.3.2.1
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class SystemSpecificParams(BER_TLV_IE, tag=0xEF, nested=[VolatileMemoryQuota, NonVolatileMemoryQuota, StkParameter]):
|
class SystemSpecificParams(BER_TLV_IE, tag=0xEF, nested=[VolatileMemoryQuota, NonVolatileMemoryQuota, StkParameter]):
|
||||||
# GPD_SPE_013 v1.1 Table 6-5
|
# GPD_SPE_013 v1.1 Table 6-5
|
||||||
|
|||||||
@@ -184,13 +184,13 @@ class EF_CallconfI(LinFixedEF):
|
|||||||
class EF_Shunting(TransparentEF):
|
class EF_Shunting(TransparentEF):
|
||||||
"""Section 7.6"""
|
"""Section 7.6"""
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "03f8ffffff000000", { "common_gid": 3, "shunting_gid": "f8ffffff000000" } ),
|
( "03f8ffffff000000", { "common_gid": 3, "shunting_gid": h2b("f8ffffff000000") } ),
|
||||||
]
|
]
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(fid='6ff4', sfid=None,
|
super().__init__(fid='6ff4', sfid=None,
|
||||||
name='EF.Shunting', desc='Shunting', size=(8, 8))
|
name='EF.Shunting', desc='Shunting', size=(8, 8))
|
||||||
self._construct = Struct('common_gid'/Int8ub,
|
self._construct = Struct('common_gid'/Int8ub,
|
||||||
'shunting_gid'/HexAdapter(Bytes(7)))
|
'shunting_gid'/Bytes(7))
|
||||||
|
|
||||||
|
|
||||||
class EF_GsmrPLMN(LinFixedEF):
|
class EF_GsmrPLMN(LinFixedEF):
|
||||||
@@ -199,13 +199,13 @@ class EF_GsmrPLMN(LinFixedEF):
|
|||||||
( "22f860f86f8d6f8e01", { "plmn": "228-06", "class_of_network": {
|
( "22f860f86f8d6f8e01", { "plmn": "228-06", "class_of_network": {
|
||||||
"supported": { "vbs": True, "vgcs": True, "emlpp": True,
|
"supported": { "vbs": True, "vgcs": True, "emlpp": True,
|
||||||
"fn": True, "eirene": True }, "preference": 0 },
|
"fn": True, "eirene": True }, "preference": 0 },
|
||||||
"ic_incoming_ref_tbl": "6f8d", "outgoing_ref_tbl": "6f8e",
|
"ic_incoming_ref_tbl": h2b("6f8d"), "outgoing_ref_tbl": h2b("6f8e"),
|
||||||
"ic_table_ref": "01" } ),
|
"ic_table_ref": h2b("01") } ),
|
||||||
( "22f810416f8d6f8e02", { "plmn": "228-01", "class_of_network": {
|
( "22f810416f8d6f8e02", { "plmn": "228-01", "class_of_network": {
|
||||||
"supported": { "vbs": False, "vgcs": False, "emlpp": False,
|
"supported": { "vbs": False, "vgcs": False, "emlpp": False,
|
||||||
"fn": True, "eirene": False }, "preference": 1 },
|
"fn": True, "eirene": False }, "preference": 1 },
|
||||||
"ic_incoming_ref_tbl": "6f8d", "outgoing_ref_tbl": "6f8e",
|
"ic_incoming_ref_tbl": h2b("6f8d"), "outgoing_ref_tbl": h2b("6f8e"),
|
||||||
"ic_table_ref": "02" } ),
|
"ic_table_ref": h2b("02") } ),
|
||||||
]
|
]
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(fid='6ff5', sfid=None, name='EF.GsmrPLMN',
|
super().__init__(fid='6ff5', sfid=None, name='EF.GsmrPLMN',
|
||||||
@@ -213,24 +213,24 @@ class EF_GsmrPLMN(LinFixedEF):
|
|||||||
self._construct = Struct('plmn'/PlmnAdapter(Bytes(3)),
|
self._construct = Struct('plmn'/PlmnAdapter(Bytes(3)),
|
||||||
'class_of_network'/BitStruct('supported'/FlagsEnum(BitsInteger(5), vbs=1, vgcs=2, emlpp=4, fn=8, eirene=16),
|
'class_of_network'/BitStruct('supported'/FlagsEnum(BitsInteger(5), vbs=1, vgcs=2, emlpp=4, fn=8, eirene=16),
|
||||||
'preference'/BitsInteger(3)),
|
'preference'/BitsInteger(3)),
|
||||||
'ic_incoming_ref_tbl'/HexAdapter(Bytes(2)),
|
'ic_incoming_ref_tbl'/Bytes(2),
|
||||||
'outgoing_ref_tbl'/HexAdapter(Bytes(2)),
|
'outgoing_ref_tbl'/Bytes(2),
|
||||||
'ic_table_ref'/HexAdapter(Bytes(1)))
|
'ic_table_ref'/Bytes(1))
|
||||||
|
|
||||||
|
|
||||||
class EF_IC(LinFixedEF):
|
class EF_IC(LinFixedEF):
|
||||||
"""Section 7.8"""
|
"""Section 7.8"""
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "f06f8e40f10001", { "next_table_type": "decision", "id_of_next_table": "6f8e",
|
( "f06f8e40f10001", { "next_table_type": "decision", "id_of_next_table": h2b("6f8e"),
|
||||||
"ic_decision_value": "041f", "network_string_table_index": 1 } ),
|
"ic_decision_value": "041f", "network_string_table_index": 1 } ),
|
||||||
( "ffffffffffffff", { "next_table_type": "empty", "id_of_next_table": "ffff",
|
( "ffffffffffffff", { "next_table_type": "empty", "id_of_next_table": h2b("ffff"),
|
||||||
"ic_decision_value": "ffff", "network_string_table_index": 65535 } ),
|
"ic_decision_value": "ffff", "network_string_table_index": 65535 } ),
|
||||||
]
|
]
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(fid='6f8d', sfid=None, name='EF.IC',
|
super().__init__(fid='6f8d', sfid=None, name='EF.IC',
|
||||||
desc='International Code', rec_len=(7, 7))
|
desc='International Code', rec_len=(7, 7))
|
||||||
self._construct = Struct('next_table_type'/NextTableType,
|
self._construct = Struct('next_table_type'/NextTableType,
|
||||||
'id_of_next_table'/HexAdapter(Bytes(2)),
|
'id_of_next_table'/Bytes(2),
|
||||||
'ic_decision_value'/BcdAdapter(Bytes(2)),
|
'ic_decision_value'/BcdAdapter(Bytes(2)),
|
||||||
'network_string_table_index'/Int16ub)
|
'network_string_table_index'/Int16ub)
|
||||||
|
|
||||||
@@ -252,18 +252,18 @@ class EF_NW(LinFixedEF):
|
|||||||
class EF_Switching(LinFixedEF):
|
class EF_Switching(LinFixedEF):
|
||||||
"""Section 8.4"""
|
"""Section 8.4"""
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "f26f87f0ff00", { "next_table_type": "num_dial_digits", "id_of_next_table": "6f87",
|
( "f26f87f0ff00", { "next_table_type": "num_dial_digits", "id_of_next_table": h2b("6f87"),
|
||||||
"decision_value": "0fff", "string_table_index": 0 } ),
|
"decision_value": "0fff", "string_table_index": 0 } ),
|
||||||
( "f06f8ff1ff01", { "next_table_type": "decision", "id_of_next_table": "6f8f",
|
( "f06f8ff1ff01", { "next_table_type": "decision", "id_of_next_table": h2b("6f8f"),
|
||||||
"decision_value": "1fff", "string_table_index": 1 } ),
|
"decision_value": "1fff", "string_table_index": 1 } ),
|
||||||
( "f16f89f5ff05", { "next_table_type": "predefined", "id_of_next_table": "6f89",
|
( "f16f89f5ff05", { "next_table_type": "predefined", "id_of_next_table": h2b("6f89"),
|
||||||
"decision_value": "5fff", "string_table_index": 5 } ),
|
"decision_value": "5fff", "string_table_index": 5 } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='1234', name='Switching', desc=None):
|
def __init__(self, fid='1234', name='Switching', desc=None):
|
||||||
super().__init__(fid=fid, sfid=None,
|
super().__init__(fid=fid, sfid=None,
|
||||||
name=name, desc=desc, rec_len=(6, 6))
|
name=name, desc=desc, rec_len=(6, 6))
|
||||||
self._construct = Struct('next_table_type'/NextTableType,
|
self._construct = Struct('next_table_type'/NextTableType,
|
||||||
'id_of_next_table'/HexAdapter(Bytes(2)),
|
'id_of_next_table'/Bytes(2),
|
||||||
'decision_value'/BcdAdapter(Bytes(2)),
|
'decision_value'/BcdAdapter(Bytes(2)),
|
||||||
'string_table_index'/Int8ub)
|
'string_table_index'/Int8ub)
|
||||||
|
|
||||||
@@ -271,12 +271,12 @@ class EF_Switching(LinFixedEF):
|
|||||||
class EF_Predefined(LinFixedEF):
|
class EF_Predefined(LinFixedEF):
|
||||||
"""Section 8.5"""
|
"""Section 8.5"""
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "f26f85", 1, { "next_table_type": "num_dial_digits", "id_of_next_table": "6f85" } ),
|
( "f26f85", 1, { "next_table_type": "num_dial_digits", "id_of_next_table": h2b("6f85") } ),
|
||||||
( "f0ffc8", 2, { "predefined_value1": "0fff", "string_table_index1": 200 } ),
|
( "f0ffc8", 2, { "predefined_value1": "0fff", "string_table_index1": 200 } ),
|
||||||
]
|
]
|
||||||
# header and other records have different structure. WTF !?!
|
# header and other records have different structure. WTF !?!
|
||||||
construct_first = Struct('next_table_type'/NextTableType,
|
construct_first = Struct('next_table_type'/NextTableType,
|
||||||
'id_of_next_table'/HexAdapter(Bytes(2)))
|
'id_of_next_table'/Bytes(2))
|
||||||
construct_others = Struct('predefined_value1'/BcdAdapter(Bytes(2)),
|
construct_others = Struct('predefined_value1'/BcdAdapter(Bytes(2)),
|
||||||
'string_table_index1'/Int8ub)
|
'string_table_index1'/Int8ub)
|
||||||
|
|
||||||
@@ -301,13 +301,13 @@ class EF_Predefined(LinFixedEF):
|
|||||||
class EF_DialledVals(TransparentEF):
|
class EF_DialledVals(TransparentEF):
|
||||||
"""Section 8.6"""
|
"""Section 8.6"""
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "ffffff22", { "next_table_type": "empty", "id_of_next_table": "ffff", "dialed_digits": "22" } ),
|
( "ffffff22", { "next_table_type": "empty", "id_of_next_table": h2b("ffff"), "dialed_digits": "22" } ),
|
||||||
( "f16f8885", { "next_table_type": "predefined", "id_of_next_table": "6f88", "dialed_digits": "58" }),
|
( "f16f8885", { "next_table_type": "predefined", "id_of_next_table": h2b("6f88"), "dialed_digits": "58" }),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='1234', name='DialledVals', desc=None):
|
def __init__(self, fid='1234', name='DialledVals', desc=None):
|
||||||
super().__init__(fid=fid, sfid=None, name=name, desc=desc, size=(4, 4))
|
super().__init__(fid=fid, sfid=None, name=name, desc=desc, size=(4, 4))
|
||||||
self._construct = Struct('next_table_type'/NextTableType,
|
self._construct = Struct('next_table_type'/NextTableType,
|
||||||
'id_of_next_table'/HexAdapter(Bytes(2)),
|
'id_of_next_table'/Bytes(2),
|
||||||
'dialed_digits'/BcdAdapter(Bytes(1)))
|
'dialed_digits'/BcdAdapter(Bytes(1)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from bidict import bidict
|
|||||||
from construct import Int8ub, Byte, Bit, Flag, BitsInteger
|
from construct import Int8ub, Byte, Bit, Flag, BitsInteger
|
||||||
from construct import Struct, Enum, Tell, BitStruct, this, Padding
|
from construct import Struct, Enum, Tell, BitStruct, this, Padding
|
||||||
from construct import Prefixed, GreedyRange
|
from construct import Prefixed, GreedyRange
|
||||||
from osmocom.construct import HexAdapter, BcdAdapter, TonNpi, Bytes, GreedyBytes
|
from osmocom.construct import BcdAdapter, TonNpi, Bytes, GreedyBytes
|
||||||
from osmocom.utils import Hexstr, h2b, b2h
|
from osmocom.utils import Hexstr, h2b, b2h
|
||||||
|
|
||||||
from smpp.pdu import pdu_types, operations
|
from smpp.pdu import pdu_types, operations
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ class EF_PIN(TransparentEF):
|
|||||||
( 'f1030331323334ffffffff0a0a3132333435363738',
|
( 'f1030331323334ffffffff0a0a3132333435363738',
|
||||||
{ 'state': { 'valid': True, 'change_able': True, 'unblock_able': True, 'disable_able': True,
|
{ 'state': { 'valid': True, 'change_able': True, 'unblock_able': True, 'disable_able': True,
|
||||||
'not_initialized': False, 'disabled': True },
|
'not_initialized': False, 'disabled': True },
|
||||||
'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': '31323334',
|
'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': b'1234',
|
||||||
'puk': { 'attempts_remaining': 10, 'maximum_attempts': 10, 'puk': '3132333435363738' }
|
'puk': { 'attempts_remaining': 10, 'maximum_attempts': 10, 'puk': b'12345678' }
|
||||||
} ),
|
} ),
|
||||||
( 'f003039999999999999999',
|
( 'f003039999999999999999',
|
||||||
{ 'state': { 'valid': True, 'change_able': True, 'unblock_able': True, 'disable_able': True,
|
{ 'state': { 'valid': True, 'change_able': True, 'unblock_able': True, 'disable_able': True,
|
||||||
'not_initialized': False, 'disabled': False },
|
'not_initialized': False, 'disabled': False },
|
||||||
'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': '9999999999999999',
|
'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': h2b('9999999999999999'),
|
||||||
'puk': None } ),
|
'puk': None } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f01', name='EF.CHV1'):
|
def __init__(self, fid='6f01', name='EF.CHV1'):
|
||||||
@@ -66,29 +66,32 @@ class EF_PIN(TransparentEF):
|
|||||||
change_able=0x40, valid=0x80)
|
change_able=0x40, valid=0x80)
|
||||||
PukStruct = Struct('attempts_remaining'/Int8ub,
|
PukStruct = Struct('attempts_remaining'/Int8ub,
|
||||||
'maximum_attempts'/Int8ub,
|
'maximum_attempts'/Int8ub,
|
||||||
'puk'/HexAdapter(Rpad(Bytes(8))))
|
'puk'/Rpad(Bytes(8)))
|
||||||
self._construct = Struct('state'/StateByte,
|
self._construct = Struct('state'/StateByte,
|
||||||
'attempts_remaining'/Int8ub,
|
'attempts_remaining'/Int8ub,
|
||||||
'maximum_attempts'/Int8ub,
|
'maximum_attempts'/Int8ub,
|
||||||
'pin'/HexAdapter(Rpad(Bytes(8))),
|
'pin'/Rpad(Bytes(8)),
|
||||||
'puk'/COptional(PukStruct))
|
'puk'/COptional(PukStruct))
|
||||||
|
|
||||||
|
|
||||||
class EF_MILENAGE_CFG(TransparentEF):
|
class EF_MILENAGE_CFG(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '40002040600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000020000000000000000000000000000000400000000000000000000000000000008',
|
( '40002040600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000020000000000000000000000000000000400000000000000000000000000000008',
|
||||||
{"r1": 64, "r2": 0, "r3": 32, "r4": 64, "r5": 96, "c1": "00000000000000000000000000000000", "c2":
|
{"r1": 64, "r2": 0, "r3": 32, "r4": 64, "r5": 96,
|
||||||
"00000000000000000000000000000001", "c3": "00000000000000000000000000000002", "c4":
|
"c1": h2b("00000000000000000000000000000000"),
|
||||||
"00000000000000000000000000000004", "c5": "00000000000000000000000000000008"} ),
|
"c2": h2b("00000000000000000000000000000001"),
|
||||||
|
"c3": h2b("00000000000000000000000000000002"),
|
||||||
|
"c4": h2b("00000000000000000000000000000004"),
|
||||||
|
"c5": h2b("00000000000000000000000000000008")} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f21', name='EF.MILENAGE_CFG', desc='Milenage connfiguration'):
|
def __init__(self, fid='6f21', name='EF.MILENAGE_CFG', desc='Milenage connfiguration'):
|
||||||
super().__init__(fid, name=name, desc=desc)
|
super().__init__(fid, name=name, desc=desc)
|
||||||
self._construct = Struct('r1'/Int8ub, 'r2'/Int8ub, 'r3'/Int8ub, 'r4'/Int8ub, 'r5'/Int8ub,
|
self._construct = Struct('r1'/Int8ub, 'r2'/Int8ub, 'r3'/Int8ub, 'r4'/Int8ub, 'r5'/Int8ub,
|
||||||
'c1'/HexAdapter(Bytes(16)),
|
'c1'/Bytes(16),
|
||||||
'c2'/HexAdapter(Bytes(16)),
|
'c2'/Bytes(16),
|
||||||
'c3'/HexAdapter(Bytes(16)),
|
'c3'/Bytes(16),
|
||||||
'c4'/HexAdapter(Bytes(16)),
|
'c4'/Bytes(16),
|
||||||
'c5'/HexAdapter(Bytes(16)))
|
'c5'/Bytes(16))
|
||||||
|
|
||||||
|
|
||||||
class EF_0348_KEY(LinFixedEF):
|
class EF_0348_KEY(LinFixedEF):
|
||||||
@@ -102,18 +105,18 @@ class EF_0348_KEY(LinFixedEF):
|
|||||||
self._construct = Struct('security_domain'/Int8ub,
|
self._construct = Struct('security_domain'/Int8ub,
|
||||||
'key_set_version'/Int8ub,
|
'key_set_version'/Int8ub,
|
||||||
'key_len_and_type'/KeyLenAndType,
|
'key_len_and_type'/KeyLenAndType,
|
||||||
'key'/HexAdapter(Bytes(this.key_len_and_type.key_length)))
|
'key'/Bytes(this.key_len_and_type.key_length))
|
||||||
|
|
||||||
|
|
||||||
class EF_0348_COUNT(LinFixedEF):
|
class EF_0348_COUNT(LinFixedEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( 'fe010000000000', {"sec_domain": 254, "key_set_version": 1, "counter": "0000000000"} ),
|
( 'fe010000000000', {"sec_domain": 254, "key_set_version": 1, "counter": h2b("0000000000")} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f23', name='EF.0348_COUNT', desc='TS 03.48 OTA Counters'):
|
def __init__(self, fid='6f23', name='EF.0348_COUNT', desc='TS 03.48 OTA Counters'):
|
||||||
super().__init__(fid, name=name, desc=desc, rec_len=(7, 7))
|
super().__init__(fid, name=name, desc=desc, rec_len=(7, 7))
|
||||||
self._construct = Struct('sec_domain'/Int8ub,
|
self._construct = Struct('sec_domain'/Int8ub,
|
||||||
'key_set_version'/Int8ub,
|
'key_set_version'/Int8ub,
|
||||||
'counter'/HexAdapter(Bytes(5)))
|
'counter'/Bytes(5))
|
||||||
|
|
||||||
|
|
||||||
class EF_SIM_AUTH_COUNTER(TransparentEF):
|
class EF_SIM_AUTH_COUNTER(TransparentEF):
|
||||||
@@ -145,8 +148,9 @@ class EF_GP_DIV_DATA(LinFixedEF):
|
|||||||
class EF_SIM_AUTH_KEY(TransparentEF):
|
class EF_SIM_AUTH_KEY(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||||
{"cfg": {"sres_deriv_func": 1, "use_opc_instead_of_op": True, "algorithm": "milenage"}, "key":
|
{"cfg": {"sres_deriv_func": 1, "use_opc_instead_of_op": True, "algorithm": "milenage"},
|
||||||
"000102030405060708090a0b0c0d0e0f", "op_opc": "101112131415161718191a1b1c1d1e1f"} ),
|
"key": h2b("000102030405060708090a0b0c0d0e0f"),
|
||||||
|
"op_opc": h2b("101112131415161718191a1b1c1d1e1f")} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f20', name='EF.SIM_AUTH_KEY'):
|
def __init__(self, fid='6f20', name='EF.SIM_AUTH_KEY'):
|
||||||
super().__init__(fid, name=name, desc='USIM authentication key')
|
super().__init__(fid, name=name, desc='USIM authentication key')
|
||||||
@@ -155,8 +159,8 @@ class EF_SIM_AUTH_KEY(TransparentEF):
|
|||||||
'use_opc_instead_of_op'/Flag,
|
'use_opc_instead_of_op'/Flag,
|
||||||
'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3))
|
'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3))
|
||||||
self._construct = Struct('cfg'/CfgByte,
|
self._construct = Struct('cfg'/CfgByte,
|
||||||
'key'/HexAdapter(Bytes(16)),
|
'key'/Bytes(16),
|
||||||
'op_opc' /HexAdapter(Bytes(16)))
|
'op_opc' /Bytes(16))
|
||||||
|
|
||||||
|
|
||||||
class DF_SYSTEM(CardDF):
|
class DF_SYSTEM(CardDF):
|
||||||
@@ -209,13 +213,13 @@ class EF_USIM_AUTH_KEY(TransparentEF):
|
|||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '141898d827f70120d33b3e7462ee5fd6fe6ca53d7a0a804561646816d7b0c702fb',
|
( '141898d827f70120d33b3e7462ee5fd6fe6ca53d7a0a804561646816d7b0c702fb',
|
||||||
{ "cfg": { "only_4bytes_res_in_3g": False, "sres_deriv_func_in_2g": 1, "use_opc_instead_of_op": True, "algorithm": "milenage" },
|
{ "cfg": { "only_4bytes_res_in_3g": False, "sres_deriv_func_in_2g": 1, "use_opc_instead_of_op": True, "algorithm": "milenage" },
|
||||||
"key": "1898d827f70120d33b3e7462ee5fd6fe", "op_opc": "6ca53d7a0a804561646816d7b0c702fb" } ),
|
"key": h2b("1898d827f70120d33b3e7462ee5fd6fe"), "op_opc": h2b("6ca53d7a0a804561646816d7b0c702fb") } ),
|
||||||
( '160a04101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f000102030405060708090a0b0c0d0e0f',
|
( '160a04101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f000102030405060708090a0b0c0d0e0f',
|
||||||
{ "cfg" : { "algorithm" : "tuak", "key_length" : 128, "sres_deriv_func_in_2g" : 1, "use_opc_instead_of_op" : True },
|
{ "cfg" : { "algorithm" : "tuak", "key_length" : 128, "sres_deriv_func_in_2g" : 1, "use_opc_instead_of_op" : True },
|
||||||
"tuak_cfg" : { "ck_and_ik_size" : 128, "mac_size" : 128, "res_size" : 128 },
|
"tuak_cfg" : { "ck_and_ik_size" : 128, "mac_size" : 128, "res_size" : 128 },
|
||||||
"num_of_keccak_iterations" : 4,
|
"num_of_keccak_iterations" : 4,
|
||||||
"k" : "000102030405060708090a0b0c0d0e0f",
|
"k" : h2b("000102030405060708090a0b0c0d0e0f"),
|
||||||
"op_opc" : "101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f"
|
"op_opc" : h2b("101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f")
|
||||||
} ),
|
} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='af20', name='EF.USIM_AUTH_KEY'):
|
def __init__(self, fid='af20', name='EF.USIM_AUTH_KEY'):
|
||||||
@@ -226,8 +230,8 @@ class EF_USIM_AUTH_KEY(TransparentEF):
|
|||||||
'use_opc_instead_of_op'/Mapping(Bit, {False:0, True:1}),
|
'use_opc_instead_of_op'/Mapping(Bit, {False:0, True:1}),
|
||||||
'algorithm'/Algorithm)
|
'algorithm'/Algorithm)
|
||||||
self._construct = Struct('cfg'/CfgByte,
|
self._construct = Struct('cfg'/CfgByte,
|
||||||
'key'/HexAdapter(Bytes(16)),
|
'key'/Bytes(16),
|
||||||
'op_opc' /HexAdapter(Bytes(16)))
|
'op_opc'/Bytes(16))
|
||||||
# TUAK has a rather different layout for the data, so we define a different
|
# TUAK has a rather different layout for the data, so we define a different
|
||||||
# construct below and use explicit _{decode,encode}_bin() methods for separating
|
# construct below and use explicit _{decode,encode}_bin() methods for separating
|
||||||
# the TUAK and non-TUAK situation
|
# the TUAK and non-TUAK situation
|
||||||
@@ -243,8 +247,8 @@ class EF_USIM_AUTH_KEY(TransparentEF):
|
|||||||
self._constr_tuak = Struct('cfg'/CfgByteTuak,
|
self._constr_tuak = Struct('cfg'/CfgByteTuak,
|
||||||
'tuak_cfg'/TuakCfgByte,
|
'tuak_cfg'/TuakCfgByte,
|
||||||
'num_of_keccak_iterations'/Int8ub,
|
'num_of_keccak_iterations'/Int8ub,
|
||||||
'op_opc'/HexAdapter(Bytes(32)),
|
'op_opc'/Bytes(32),
|
||||||
'k'/HexAdapter(Bytes(this.cfg.key_length//8)))
|
'k'/Bytes(this.cfg.key_length//8))
|
||||||
|
|
||||||
def _decode_bin(self, raw_bin_data: bytearray) -> dict:
|
def _decode_bin(self, raw_bin_data: bytearray) -> dict:
|
||||||
if raw_bin_data[0] & 0x0F == 0x06:
|
if raw_bin_data[0] & 0x0F == 0x06:
|
||||||
@@ -263,8 +267,9 @@ class EF_USIM_AUTH_KEY_2G(TransparentEF):
|
|||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
( '14000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||||
{"cfg": {"only_4bytes_res_in_3g": False, "sres_deriv_func_in_2g": 1, "use_opc_instead_of_op": True,
|
{"cfg": {"only_4bytes_res_in_3g": False, "sres_deriv_func_in_2g": 1, "use_opc_instead_of_op": True,
|
||||||
"algorithm": "milenage"}, "key": "000102030405060708090a0b0c0d0e0f", "op_opc":
|
"algorithm": "milenage"},
|
||||||
"101112131415161718191a1b1c1d1e1f"} ),
|
"key": h2b("000102030405060708090a0b0c0d0e0f"),
|
||||||
|
"op_opc": h2b("101112131415161718191a1b1c1d1e1f")} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='af22', name='EF.USIM_AUTH_KEY_2G'):
|
def __init__(self, fid='af22', name='EF.USIM_AUTH_KEY_2G'):
|
||||||
super().__init__(fid, name=name, desc='USIM authentication key in 2G context')
|
super().__init__(fid, name=name, desc='USIM authentication key in 2G context')
|
||||||
@@ -273,8 +278,8 @@ class EF_USIM_AUTH_KEY_2G(TransparentEF):
|
|||||||
'use_opc_instead_of_op'/Flag,
|
'use_opc_instead_of_op'/Flag,
|
||||||
'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3, xor=14))
|
'algorithm'/Enum(Nibble, milenage=4, comp128v1=1, comp128v2=2, comp128v3=3, xor=14))
|
||||||
self._construct = Struct('cfg'/CfgByte,
|
self._construct = Struct('cfg'/CfgByte,
|
||||||
'key'/HexAdapter(Bytes(16)),
|
'key'/Bytes(16),
|
||||||
'op_opc' /HexAdapter(Bytes(16)))
|
'op_opc'/Bytes(16))
|
||||||
|
|
||||||
|
|
||||||
class EF_GBA_SK(TransparentEF):
|
class EF_GBA_SK(TransparentEF):
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ class FileDescriptor(BER_TLV_IE, tag=0x82):
|
|||||||
|
|
||||||
# ETSI TS 102 221 11.1.1.4.4
|
# ETSI TS 102 221 11.1.1.4.4
|
||||||
class FileIdentifier(BER_TLV_IE, tag=0x83):
|
class FileIdentifier(BER_TLV_IE, tag=0x83):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# ETSI TS 102 221 11.1.1.4.5
|
# ETSI TS 102 221 11.1.1.4.5
|
||||||
class DfName(BER_TLV_IE, tag=0x84):
|
class DfName(BER_TLV_IE, tag=0x84):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
# ETSI TS 102 221 11.1.1.4.6.1
|
# ETSI TS 102 221 11.1.1.4.6.1
|
||||||
class UiccCharacteristics(BER_TLV_IE, tag=0x80):
|
class UiccCharacteristics(BER_TLV_IE, tag=0x80):
|
||||||
@@ -217,7 +217,7 @@ class SecurityAttribExpanded(BER_TLV_IE, tag=0xab):
|
|||||||
# ETSI TS 102 221 11.1.1.4.7.3
|
# ETSI TS 102 221 11.1.1.4.7.3
|
||||||
class SecurityAttribReferenced(BER_TLV_IE, tag=0x8b):
|
class SecurityAttribReferenced(BER_TLV_IE, tag=0x8b):
|
||||||
# TODO: longer format with SEID
|
# TODO: longer format with SEID
|
||||||
_construct = Struct('ef_arr_file_id'/HexAdapter(Bytes(2)), 'ef_arr_record_nr'/Int8ub)
|
_construct = Struct('ef_arr_file_id'/Bytes(2), 'ef_arr_record_nr'/Int8ub)
|
||||||
|
|
||||||
# ETSI TS 102 221 11.1.1.4.8
|
# ETSI TS 102 221 11.1.1.4.8
|
||||||
class ShortFileIdentifier(BER_TLV_IE, tag=0x88):
|
class ShortFileIdentifier(BER_TLV_IE, tag=0x88):
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ from pySim.filesystem import CardDF, TransparentEF
|
|||||||
# TS102 310 Section 7.1
|
# TS102 310 Section 7.1
|
||||||
class EF_EAPKEYS(TransparentEF):
|
class EF_EAPKEYS(TransparentEF):
|
||||||
class Msk(BER_TLV_IE, tag=0x80):
|
class Msk(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class Emsk(BER_TLV_IE, tag=0x81):
|
class Emsk(BER_TLV_IE, tag=0x81):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
class MskCollection(TLV_IE_Collection, nested=[EF_EAPKEYS.Msk, EF_EAPKEYS.Emsk]):
|
class MskCollection(TLV_IE_Collection, nested=[EF_EAPKEYS.Msk, EF_EAPKEYS.Emsk]):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ EF_EST_map = {
|
|||||||
|
|
||||||
# 3gPP TS 31.102 Section 7.5.2.1
|
# 3gPP TS 31.102 Section 7.5.2.1
|
||||||
class SUCI_TlvDataObject(BER_TLV_IE, tag=0xA1):
|
class SUCI_TlvDataObject(BER_TLV_IE, tag=0xA1):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# ADF.USIM
|
# ADF.USIM
|
||||||
@@ -230,7 +230,7 @@ class EF_5GS3GPPNSC(LinFixedEF):
|
|||||||
_construct = Int8ub
|
_construct = Int8ub
|
||||||
|
|
||||||
class K_AMF(BER_TLV_IE, tag=0x81):
|
class K_AMF(BER_TLV_IE, tag=0x81):
|
||||||
_construct = HexAdapter(Bytes(32))
|
_construct = Bytes(32)
|
||||||
|
|
||||||
class UplinkNASCount(BER_TLV_IE, tag=0x82):
|
class UplinkNASCount(BER_TLV_IE, tag=0x82):
|
||||||
_construct = Int32ub
|
_construct = Int32ub
|
||||||
@@ -260,10 +260,10 @@ class EF_5GS3GPPNSC(LinFixedEF):
|
|||||||
# 3GPP TS 31.102 Section 4.4.11.6
|
# 3GPP TS 31.102 Section 4.4.11.6
|
||||||
class EF_5GAUTHKEYS(TransparentEF):
|
class EF_5GAUTHKEYS(TransparentEF):
|
||||||
class K_AUSF(BER_TLV_IE, tag=0x80):
|
class K_AUSF(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class K_SEAF(BER_TLV_IE, tag=0x81):
|
class K_SEAF(BER_TLV_IE, tag=0x81):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class FiveGAuthKeys(TLV_IE_Collection, nested=[K_AUSF, K_SEAF]):
|
class FiveGAuthKeys(TLV_IE_Collection, nested=[K_AUSF, K_SEAF]):
|
||||||
pass
|
pass
|
||||||
@@ -281,9 +281,9 @@ class EF_SUCI_Calc_Info(TransparentEF):
|
|||||||
"identifier": 0,
|
"identifier": 0,
|
||||||
"key_index": 0}],
|
"key_index": 0}],
|
||||||
"hnet_pubkey_list": [{"hnet_pubkey_identifier": 10, "hnet_pubkey":
|
"hnet_pubkey_list": [{"hnet_pubkey_identifier": 10, "hnet_pubkey":
|
||||||
"4e858c4d49d1343e6181284c47ca721730c98742cb7c6182d2e8126e08088d36"},
|
h2b("4e858c4d49d1343e6181284c47ca721730c98742cb7c6182d2e8126e08088d36")},
|
||||||
{"hnet_pubkey_identifier": 11, "hnet_pubkey":
|
{"hnet_pubkey_identifier": 11, "hnet_pubkey":
|
||||||
"d1bc365f4997d17ce4374e72181431cbfeba9e1b98d7618f79d48561b144672a"}]} ),
|
h2b("d1bc365f4997d17ce4374e72181431cbfeba9e1b98d7618f79d48561b144672a")}]} ),
|
||||||
]
|
]
|
||||||
# 3GPP TS 31.102 Section 4.4.11.8
|
# 3GPP TS 31.102 Section 4.4.11.8
|
||||||
class ProtSchemeIdList(BER_TLV_IE, tag=0xa0):
|
class ProtSchemeIdList(BER_TLV_IE, tag=0xa0):
|
||||||
@@ -298,7 +298,7 @@ class EF_SUCI_Calc_Info(TransparentEF):
|
|||||||
|
|
||||||
class HnetPubkey(BER_TLV_IE, tag=0x81):
|
class HnetPubkey(BER_TLV_IE, tag=0x81):
|
||||||
# contents according to RFC 7748 / RFC 5480
|
# contents according to RFC 7748 / RFC 5480
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class HnetPubkeyList(BER_TLV_IE, tag=0xa1, nested=[HnetPubkeyIdentifier, HnetPubkey]):
|
class HnetPubkeyList(BER_TLV_IE, tag=0xa1, nested=[HnetPubkeyIdentifier, HnetPubkey]):
|
||||||
pass
|
pass
|
||||||
@@ -425,7 +425,7 @@ class EF_Keys(TransparentEF):
|
|||||||
desc='Ciphering and Integrity Keys'):
|
desc='Ciphering and Integrity Keys'):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||||
self._construct = Struct(
|
self._construct = Struct(
|
||||||
'ksi'/Int8ub, 'ck'/HexAdapter(Bytes(16)), 'ik'/HexAdapter(Bytes(16)))
|
'ksi'/Int8ub, 'ck'/Bytes(16), 'ik'/Bytes(16))
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.6
|
# TS 31.102 Section 4.2.6
|
||||||
class EF_HPPLMN(TransparentEF):
|
class EF_HPPLMN(TransparentEF):
|
||||||
@@ -536,15 +536,15 @@ class EF_ECC(LinFixedEF):
|
|||||||
class EF_LOCI(TransparentEF):
|
class EF_LOCI(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '47d1264a62f21037211e00',
|
( '47d1264a62f21037211e00',
|
||||||
{ "tmsi": "47d1264a", "lai": { "mcc_mnc": "262-01", "lac": "3721" },
|
{ "tmsi": h2b("47d1264a"), "lai": { "mcc_mnc": "262-01", "lac": h2b("3721") },
|
||||||
"rfu": 30, "lu_status": 0 } ),
|
"rfu": 30, "lu_status": 0 } ),
|
||||||
( 'ffffffff62f2200000ff01',
|
( 'ffffffff62f2200000ff01',
|
||||||
{"tmsi": "ffffffff", "lai": {"mcc_mnc": "262-02", "lac": "0000"}, "rfu": 255, "lu_status": 1} ),
|
{"tmsi": h2b("ffffffff"), "lai": {"mcc_mnc": "262-02", "lac": h2b("0000") }, "rfu": 255, "lu_status": 1} ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f7e', sfid=0x0b, name='EF.LOCI', desc='Location information', size=(11, 11)):
|
def __init__(self, fid='6f7e', sfid=0x0b, name='EF.LOCI', desc='Location information', size=(11, 11)):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||||
Lai = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)), 'lac'/HexAdapter(Bytes(2)))
|
Lai = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)), 'lac'/Bytes(2))
|
||||||
self._construct = Struct('tmsi'/HexAdapter(Bytes(4)), 'lai'/Lai, 'rfu'/Int8ub, 'lu_status'/Int8ub)
|
self._construct = Struct('tmsi'/Bytes(4), 'lai'/Lai, 'rfu'/Int8ub, 'lu_status'/Int8ub)
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.18
|
# TS 31.102 Section 4.2.18
|
||||||
class EF_AD(TransparentEF):
|
class EF_AD(TransparentEF):
|
||||||
@@ -585,15 +585,15 @@ class EF_AD(TransparentEF):
|
|||||||
class EF_PSLOCI(TransparentEF):
|
class EF_PSLOCI(TransparentEF):
|
||||||
def __init__(self, fid='6f73', sfid=0x0c, name='EF.PSLOCI', desc='PS Location information', size=(14, 14)):
|
def __init__(self, fid='6f73', sfid=0x0c, name='EF.PSLOCI', desc='PS Location information', size=(14, 14)):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||||
self._construct = Struct('ptmsi'/HexAdapter(Bytes(4)), 'ptmsi_sig'/HexAdapter(Bytes(3)),
|
self._construct = Struct('ptmsi'/Bytes(4), 'ptmsi_sig'/Bytes(3),
|
||||||
'rai'/HexAdapter(Bytes(6)), 'rau_status'/Int8ub)
|
'rai'/Bytes(6), 'rau_status'/Int8ub)
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.33
|
# TS 31.102 Section 4.2.33
|
||||||
class EF_ICI(CyclicEF):
|
class EF_ICI(CyclicEF):
|
||||||
def __init__(self, fid='6f80', sfid=0x14, name='EF.ICI', rec_len=(28, 48),
|
def __init__(self, fid='6f80', sfid=0x14, name='EF.ICI', rec_len=(28, 48),
|
||||||
desc='Incoming Call Information', **kwargs):
|
desc='Incoming Call Information', **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct('alpha_id'/HexAdapter(Bytes(this._.total_len-28)),
|
self._construct = Struct('alpha_id'/Bytes(this._.total_len-28),
|
||||||
'len_of_bcd_contents'/Int8ub,
|
'len_of_bcd_contents'/Int8ub,
|
||||||
'ton_npi'/Int8ub,
|
'ton_npi'/Int8ub,
|
||||||
'call_number'/BcdAdapter(Bytes(10)),
|
'call_number'/BcdAdapter(Bytes(10)),
|
||||||
@@ -602,14 +602,14 @@ class EF_ICI(CyclicEF):
|
|||||||
'date_and_time'/BcdAdapter(Bytes(7)),
|
'date_and_time'/BcdAdapter(Bytes(7)),
|
||||||
'duration'/Int24ub,
|
'duration'/Int24ub,
|
||||||
'status'/Byte,
|
'status'/Byte,
|
||||||
'link_to_phonebook'/HexAdapter(Bytes(3)))
|
'link_to_phonebook'/Bytes(3))
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.34
|
# TS 31.102 Section 4.2.34
|
||||||
class EF_OCI(CyclicEF):
|
class EF_OCI(CyclicEF):
|
||||||
def __init__(self, fid='6f81', sfid=0x15, name='EF.OCI', rec_len=(27, 47),
|
def __init__(self, fid='6f81', sfid=0x15, name='EF.OCI', rec_len=(27, 47),
|
||||||
desc='Outgoing Call Information', **kwargs):
|
desc='Outgoing Call Information', **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct('alpha_id'/HexAdapter(Bytes(this._.total_len-27)),
|
self._construct = Struct('alpha_id'/Bytes(this._.total_len-27),
|
||||||
'len_of_bcd_contents'/Int8ub,
|
'len_of_bcd_contents'/Int8ub,
|
||||||
'ton_npi'/Int8ub,
|
'ton_npi'/Int8ub,
|
||||||
'call_number'/BcdAdapter(Bytes(10)),
|
'call_number'/BcdAdapter(Bytes(10)),
|
||||||
@@ -617,7 +617,7 @@ class EF_OCI(CyclicEF):
|
|||||||
'ext5_record_id'/Int8ub,
|
'ext5_record_id'/Int8ub,
|
||||||
'date_and_time'/BcdAdapter(Bytes(7)),
|
'date_and_time'/BcdAdapter(Bytes(7)),
|
||||||
'duration'/Int24ub,
|
'duration'/Int24ub,
|
||||||
'link_to_phonebook'/HexAdapter(Bytes(3)))
|
'link_to_phonebook'/Bytes(3))
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.35
|
# TS 31.102 Section 4.2.35
|
||||||
class EF_ICT(CyclicEF):
|
class EF_ICT(CyclicEF):
|
||||||
@@ -655,7 +655,7 @@ class EF_ACL(TransparentEF):
|
|||||||
def __init__(self, fid='6f57', sfid=None, name='EF.ACL', size=(32, None),
|
def __init__(self, fid='6f57', sfid=None, name='EF.ACL', size=(32, None),
|
||||||
desc='Access Point Name Control List', **kwargs):
|
desc='Access Point Name Control List', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
||||||
self._construct = Struct('num_of_apns'/Int8ub, 'tlvs'/HexAdapter(GreedyBytes))
|
self._construct = Struct('num_of_apns'/Int8ub, 'tlvs'/GreedyBytes)
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.51
|
# TS 31.102 Section 4.2.51
|
||||||
class EF_START_HFN(TransparentEF):
|
class EF_START_HFN(TransparentEF):
|
||||||
@@ -705,16 +705,16 @@ class EF_MSK(LinFixedEF):
|
|||||||
def __init__(self, fid='6fd7', sfid=None, name='EF.MSK', desc='MBMS Service Key List', **kwargs):
|
def __init__(self, fid='6fd7', sfid=None, name='EF.MSK', desc='MBMS Service Key List', **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=(20, None), **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=(20, None), **kwargs)
|
||||||
msk_ts_constr = Struct('msk_id'/Int32ub, 'timestamp_counter'/Int32ub)
|
msk_ts_constr = Struct('msk_id'/Int32ub, 'timestamp_counter'/Int32ub)
|
||||||
self._construct = Struct('key_domain_id'/HexAdapter(Bytes(3)),
|
self._construct = Struct('key_domain_id'/Bytes(3),
|
||||||
'num_msk_id'/Int8ub,
|
'num_msk_id'/Int8ub,
|
||||||
'msk_ids'/msk_ts_constr[this.num_msk_id])
|
'msk_ids'/msk_ts_constr[this.num_msk_id])
|
||||||
# TS 31.102 Section 4.2.81
|
# TS 31.102 Section 4.2.81
|
||||||
class EF_MUK(LinFixedEF):
|
class EF_MUK(LinFixedEF):
|
||||||
class MUK_Idr(BER_TLV_IE, tag=0x80):
|
class MUK_Idr(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class MUK_Idi(BER_TLV_IE, tag=0x82):
|
class MUK_Idi(BER_TLV_IE, tag=0x82):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class MUK_ID(BER_TLV_IE, tag=0xA0, nested=[MUK_Idr, MUK_Idi]):
|
class MUK_ID(BER_TLV_IE, tag=0xA0, nested=[MUK_Idr, MUK_Idi]):
|
||||||
pass
|
pass
|
||||||
@@ -732,10 +732,10 @@ class EF_MUK(LinFixedEF):
|
|||||||
# TS 31.102 Section 4.2.83
|
# TS 31.102 Section 4.2.83
|
||||||
class EF_GBANL(LinFixedEF):
|
class EF_GBANL(LinFixedEF):
|
||||||
class NAF_ID(BER_TLV_IE, tag=0x80):
|
class NAF_ID(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class B_TID(BER_TLV_IE, tag=0x81):
|
class B_TID(BER_TLV_IE, tag=0x81):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class EF_GBANL_Collection(BER_TLV_IE, nested=[NAF_ID, B_TID]):
|
class EF_GBANL_Collection(BER_TLV_IE, nested=[NAF_ID, B_TID]):
|
||||||
pass
|
pass
|
||||||
@@ -759,7 +759,7 @@ class EF_EHPLMNPI(TransparentEF):
|
|||||||
# TS 31.102 Section 4.2.87
|
# TS 31.102 Section 4.2.87
|
||||||
class EF_NAFKCA(LinFixedEF):
|
class EF_NAFKCA(LinFixedEF):
|
||||||
class NAF_KeyCentreAddress(BER_TLV_IE, tag=0x80):
|
class NAF_KeyCentreAddress(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
def __init__(self, fid='6fdd', sfid=None, name='EF.NAFKCA', rec_len=(None, None),
|
def __init__(self, fid='6fdd', sfid=None, name='EF.NAFKCA', rec_len=(None, None),
|
||||||
desc='NAF Key Centre Address', **kwargs):
|
desc='NAF Key Centre Address', **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
@@ -770,11 +770,11 @@ class EF_NCP_IP(LinFixedEF):
|
|||||||
class DataDestAddrRange(TLV_IE, tag=0x83):
|
class DataDestAddrRange(TLV_IE, tag=0x83):
|
||||||
_construct = Struct('type_of_address'/Enum(Byte, IPv4=0x21, IPv6=0x56),
|
_construct = Struct('type_of_address'/Enum(Byte, IPv4=0x21, IPv6=0x56),
|
||||||
'prefix_length'/Int8ub,
|
'prefix_length'/Int8ub,
|
||||||
'prefix'/HexAdapter(GreedyBytes))
|
'prefix'/GreedyBytes)
|
||||||
|
|
||||||
class AccessPointName(TLV_IE, tag=0x80):
|
class AccessPointName(TLV_IE, tag=0x80):
|
||||||
# coded as per TS 23.003
|
# coded as per TS 23.003
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class Login(TLV_IE, tag=0x81):
|
class Login(TLV_IE, tag=0x81):
|
||||||
# as per SMS DCS TS 23.038
|
# as per SMS DCS TS 23.038
|
||||||
@@ -803,8 +803,8 @@ class EF_EPSLOCI(TransparentEF):
|
|||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
||||||
upd_status_constr = Enum(
|
upd_status_constr = Enum(
|
||||||
Byte, updated=0, not_updated=1, roaming_not_allowed=2)
|
Byte, updated=0, not_updated=1, roaming_not_allowed=2)
|
||||||
self._construct = Struct('guti'/HexAdapter(Bytes(12)),
|
self._construct = Struct('guti'/Bytes(12),
|
||||||
'last_visited_registered_tai'/HexAdapter(Bytes(5)),
|
'last_visited_registered_tai'/Bytes(5),
|
||||||
'eps_update_status'/upd_status_constr)
|
'eps_update_status'/upd_status_constr)
|
||||||
|
|
||||||
# TS 31.102 Section 4.2.92
|
# TS 31.102 Section 4.2.92
|
||||||
@@ -813,7 +813,7 @@ class EF_EPSNSC(LinFixedEF):
|
|||||||
_construct = Int8ub
|
_construct = Int8ub
|
||||||
|
|
||||||
class K_ASME(BER_TLV_IE, tag=0x81):
|
class K_ASME(BER_TLV_IE, tag=0x81):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class UplinkNASCount(BER_TLV_IE, tag=0x82):
|
class UplinkNASCount(BER_TLV_IE, tag=0x82):
|
||||||
_construct = Int32ub
|
_construct = Int32ub
|
||||||
@@ -822,7 +822,7 @@ class EF_EPSNSC(LinFixedEF):
|
|||||||
_construct = Int32ub
|
_construct = Int32ub
|
||||||
|
|
||||||
class IDofNASAlgorithms(BER_TLV_IE, tag=0x84):
|
class IDofNASAlgorithms(BER_TLV_IE, tag=0x84):
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class EPS_NAS_Security_Context(BER_TLV_IE, tag=0xa0,
|
class EPS_NAS_Security_Context(BER_TLV_IE, tag=0xa0,
|
||||||
nested=[KSI_ASME, K_ASME, UplinkNASCount, DownlinkNASCount,
|
nested=[KSI_ASME, K_ASME, UplinkNASCount, DownlinkNASCount,
|
||||||
@@ -1062,8 +1062,8 @@ class EF_5GS3GPPLOCI(TransparentEF):
|
|||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
||||||
upd_status_constr = Enum(
|
upd_status_constr = Enum(
|
||||||
Byte, updated=0, not_updated=1, roaming_not_allowed=2)
|
Byte, updated=0, not_updated=1, roaming_not_allowed=2)
|
||||||
self._construct = Struct('5g_guti'/HexAdapter(Bytes(13)),
|
self._construct = Struct('5g_guti'/Bytes(13),
|
||||||
'last_visited_registered_tai_in_5gs'/HexAdapter(Bytes(6)),
|
'last_visited_registered_tai_in_5gs'/Bytes(6),
|
||||||
'5gs_update_status'/upd_status_constr)
|
'5gs_update_status'/upd_status_constr)
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.7 (Rel 15)
|
# TS 31.102 Section 4.4.11.7 (Rel 15)
|
||||||
@@ -1083,8 +1083,8 @@ class EF_UAC_AIC(TransparentEF):
|
|||||||
class EF_OPL5G(LinFixedEF):
|
class EF_OPL5G(LinFixedEF):
|
||||||
def __init__(self, fid='4f08', sfid=0x08, name='EF.OPL5G', desc='5GS Operator PLMN List', **kwargs):
|
def __init__(self, fid='4f08', sfid=0x08, name='EF.OPL5G', desc='5GS Operator PLMN List', **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=(10, None), **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=(10, None), **kwargs)
|
||||||
Tai = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)), 'tac_min'/HexAdapter(Bytes(3)),
|
Tai = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)), 'tac_min'/Bytes(3),
|
||||||
'tac_max'/HexAdapter(Bytes(3)))
|
'tac_max'/Bytes(3))
|
||||||
self._construct = Struct('tai'/Tai, 'pnn_record_id'/Int8ub)
|
self._construct = Struct('tai'/Tai, 'pnn_record_id'/Int8ub)
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.10 (Rel 15)
|
# TS 31.102 Section 4.4.11.10 (Rel 15)
|
||||||
@@ -1119,7 +1119,7 @@ class EF_Routing_Indicator(TransparentEF):
|
|||||||
# operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
|
# operator decides to assign less than 4 digits to Routing Indicator, the remaining digits
|
||||||
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
|
# shall be coded as "1111" to fill the 4 digits coding of Routing Indicator
|
||||||
self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2),
|
self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2),
|
||||||
'rfu'/HexAdapter(Bytes(2)))
|
'rfu'/Bytes(2))
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.13 (Rel 16)
|
# TS 31.102 Section 4.4.11.13 (Rel 16)
|
||||||
class EF_TN3GPPSNN(TransparentEF):
|
class EF_TN3GPPSNN(TransparentEF):
|
||||||
@@ -1135,14 +1135,14 @@ class EF_CAG(TransparentEF):
|
|||||||
def __init__(self, fid='4f0d', sfid=0x0d, name='EF.CAG',
|
def __init__(self, fid='4f0d', sfid=0x0d, name='EF.CAG',
|
||||||
desc='Pre-configured CAG information list EF', **kwargs):
|
desc='Pre-configured CAG information list EF', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
||||||
self._construct = HexAdapter(GreedyBytes)
|
self._construct = GreedyBytes
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.15 (Rel 17)
|
# TS 31.102 Section 4.4.11.15 (Rel 17)
|
||||||
class EF_SOR_CMCI(TransparentEF):
|
class EF_SOR_CMCI(TransparentEF):
|
||||||
def __init__(self, fid='4f0e', sfid=0x0e, name='EF.SOR-CMCI',
|
def __init__(self, fid='4f0e', sfid=0x0e, name='EF.SOR-CMCI',
|
||||||
desc='Steering Of Roaming - Connected Mode Control Information', **kwargs):
|
desc='Steering Of Roaming - Connected Mode Control Information', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
||||||
self._construct = HexAdapter(GreedyBytes)
|
self._construct = GreedyBytes
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.11.17 (Rel 17)
|
# TS 31.102 Section 4.4.11.17 (Rel 17)
|
||||||
class EF_DRI(TransparentEF):
|
class EF_DRI(TransparentEF):
|
||||||
@@ -1153,9 +1153,9 @@ class EF_DRI(TransparentEF):
|
|||||||
'parameters_indicator_status'/FlagsEnum(Byte, roaming_wait_range=1,
|
'parameters_indicator_status'/FlagsEnum(Byte, roaming_wait_range=1,
|
||||||
return_wait_range=2,
|
return_wait_range=2,
|
||||||
applicability_indicator=3),
|
applicability_indicator=3),
|
||||||
'roaming_wait_range'/HexAdapter(Bytes(2)),
|
'roaming_wait_range'/Bytes(2),
|
||||||
'return_wait_range'/HexAdapter(Bytes(2)),
|
'return_wait_range'/Bytes(2),
|
||||||
'applicability_indicator'/HexAdapter(Byte))
|
'applicability_indicator'/Byte)
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.12.2 (Rel 17)
|
# TS 31.102 Section 4.4.12.2 (Rel 17)
|
||||||
class EF_PWS_SNPN(TransparentEF):
|
class EF_PWS_SNPN(TransparentEF):
|
||||||
@@ -1173,7 +1173,7 @@ class EF_NID(LinFixedEF):
|
|||||||
self._construct = Struct('assignment_mode'/Enum(Byte, coordinated_ass_opt1=0,
|
self._construct = Struct('assignment_mode'/Enum(Byte, coordinated_ass_opt1=0,
|
||||||
self_ass=1,
|
self_ass=1,
|
||||||
coordinated_ass_opt2=2),
|
coordinated_ass_opt2=2),
|
||||||
'network_identifier'/HexAdapter(Bytes(5)))
|
'network_identifier'/Bytes(5))
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.12 (Rel 17)
|
# TS 31.102 Section 4.4.12 (Rel 17)
|
||||||
class DF_SNPN(CardDF):
|
class DF_SNPN(CardDF):
|
||||||
@@ -1413,7 +1413,7 @@ class EF_5MBSUECONFIG(TransparentEF):
|
|||||||
'nid'/COptional(Bytes(6)))
|
'nid'/COptional(Bytes(6)))
|
||||||
class Tmgi(BER_TLV_IE, tag=0x81):
|
class Tmgi(BER_TLV_IE, tag=0x81):
|
||||||
TmgiEntry = Struct('tmgi'/Bytes(6),
|
TmgiEntry = Struct('tmgi'/Bytes(6),
|
||||||
'usd_fid'/HexAdapter(Bytes(2)),
|
'usd_fid'/Bytes(2),
|
||||||
'service_type'/FlagsEnum(Byte, mbs_service_announcement=1, mbs_user_service=2))
|
'service_type'/FlagsEnum(Byte, mbs_service_announcement=1, mbs_user_service=2))
|
||||||
_construct = GreedyRange(TmgiEntry)
|
_construct = GreedyRange(TmgiEntry)
|
||||||
class NrArfcnList(BER_TLV_IE, tag=0x82):
|
class NrArfcnList(BER_TLV_IE, tag=0x82):
|
||||||
@@ -1482,7 +1482,7 @@ class EF_KAUSF_DERIVATION(TransparentEF):
|
|||||||
def __init__(self, fid='4f16', sfid=0x16, name='EF.KAUSF_DERIVATION',
|
def __init__(self, fid='4f16', sfid=0x16, name='EF.KAUSF_DERIVATION',
|
||||||
desc='K_AUSF derivation configuration', **kwargs):
|
desc='K_AUSF derivation configuration', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, **kwargs)
|
||||||
self._construct = Struct('k_ausf_deriv_cfg'/FlagsEnum(Byte, use_msk=1), 'rfu'/HexAdapter(GreedyBytes))
|
self._construct = Struct('k_ausf_deriv_cfg'/FlagsEnum(Byte, use_msk=1), 'rfu'/GreedyBytes)
|
||||||
|
|
||||||
# TS 31.102 Section 4.4.5
|
# TS 31.102 Section 4.4.5
|
||||||
class DF_WLAN(CardDF):
|
class DF_WLAN(CardDF):
|
||||||
@@ -1826,7 +1826,7 @@ class ADF_USIM(CardADF):
|
|||||||
do = SUCI_TlvDataObject()
|
do = SUCI_TlvDataObject()
|
||||||
do.from_tlv(h2b(data))
|
do.from_tlv(h2b(data))
|
||||||
do_d = do.to_dict()
|
do_d = do.to_dict()
|
||||||
self._cmd.poutput('SUCI TLV Data Object: %s' % do_d['suci__tlv_data_object'])
|
self._cmd.poutput('SUCI TLV Data Object: %s' % b2h(do_d['suci__tlv_data_object']))
|
||||||
|
|
||||||
|
|
||||||
# TS 31.102 Section 7.3
|
# TS 31.102 Section 7.3
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class EF_GBABP(TransparentEF):
|
|||||||
class EF_GBANL(LinFixedEF):
|
class EF_GBANL(LinFixedEF):
|
||||||
class NAF_ID(BER_TLV_IE, tag=0x80):
|
class NAF_ID(BER_TLV_IE, tag=0x80):
|
||||||
_construct = Struct('fqdn'/Utf8Adapter(Bytes(this._.total_len-5)),
|
_construct = Struct('fqdn'/Utf8Adapter(Bytes(this._.total_len-5)),
|
||||||
'ua_spi'/HexAdapter(Bytes(5)))
|
'ua_spi'/Bytes(5))
|
||||||
class B_TID(BER_TLV_IE, tag=0x81):
|
class B_TID(BER_TLV_IE, tag=0x81):
|
||||||
_construct = Utf8Adapter(GreedyBytes)
|
_construct = Utf8Adapter(GreedyBytes)
|
||||||
# pylint: disable=undefined-variable
|
# pylint: disable=undefined-variable
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ hence need to be in a separate python module to avoid circular dependencies.
|
|||||||
|
|
||||||
from construct import Struct, Switch, GreedyString, Int8ub, Prefixed, Enum, Byte
|
from construct import Struct, Switch, GreedyString, Int8ub, Prefixed, Enum, Byte
|
||||||
from osmocom.tlv import BER_TLV_IE, TLV_IE_Collection
|
from osmocom.tlv import BER_TLV_IE, TLV_IE_Collection
|
||||||
from osmocom.construct import Bytes, HexAdapter, Utf8Adapter, GreedyBytes
|
from osmocom.construct import Bytes, Utf8Adapter, GreedyBytes
|
||||||
from pySim.filesystem import *
|
from pySim.filesystem import *
|
||||||
|
|
||||||
# TS 31.103 Section 4.2.16
|
# TS 31.103 Section 4.2.16
|
||||||
@@ -36,7 +36,7 @@ class EF_UICCIARI(LinFixedEF):
|
|||||||
# TS 31.103 Section 4.2.18
|
# TS 31.103 Section 4.2.18
|
||||||
class EF_IMSConfigData(BerTlvEF):
|
class EF_IMSConfigData(BerTlvEF):
|
||||||
class ImsConfigDataEncoding(BER_TLV_IE, tag=0x80):
|
class ImsConfigDataEncoding(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(Bytes(1))
|
_construct = Bytes(1)
|
||||||
class ImsConfigData(BER_TLV_IE, tag=0x81):
|
class ImsConfigData(BER_TLV_IE, tag=0x81):
|
||||||
_construct = GreedyString
|
_construct = GreedyString
|
||||||
# pylint: disable=undefined-variable
|
# pylint: disable=undefined-variable
|
||||||
@@ -103,7 +103,7 @@ class EF_WebRTCURI(LinFixedEF):
|
|||||||
# TS 31.103 Section 4.2.21
|
# TS 31.103 Section 4.2.21
|
||||||
class EF_MuDMiDConfigData(BerTlvEF):
|
class EF_MuDMiDConfigData(BerTlvEF):
|
||||||
class MudMidConfigDataEncoding(BER_TLV_IE, tag=0x80):
|
class MudMidConfigDataEncoding(BER_TLV_IE, tag=0x80):
|
||||||
_construct = HexAdapter(Bytes(1))
|
_construct = Bytes(1)
|
||||||
class MudMidConfigData(BER_TLV_IE, tag=0x81):
|
class MudMidConfigData(BER_TLV_IE, tag=0x81):
|
||||||
_construct = GreedyString
|
_construct = GreedyString
|
||||||
# pylint: disable=undefined-variable
|
# pylint: disable=undefined-variable
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ class EF_SMSP(LinFixedEF):
|
|||||||
"tp_sc_addr": { "length": 255, "ton_npi": { "ext": True, "type_of_number": "reserved_for_extension",
|
"tp_sc_addr": { "length": 255, "ton_npi": { "ext": True, "type_of_number": "reserved_for_extension",
|
||||||
"numbering_plan_id": "reserved_for_extension" },
|
"numbering_plan_id": "reserved_for_extension" },
|
||||||
"call_number": "" },
|
"call_number": "" },
|
||||||
"tp_pid": "00", "tp_dcs": "00", "tp_vp_minutes": 1440 } ),
|
"tp_pid": b"\x00", "tp_dcs": b"\x00", "tp_vp_minutes": 1440 } ),
|
||||||
]
|
]
|
||||||
_test_no_pad = True
|
_test_no_pad = True
|
||||||
class ValidityPeriodAdapter(Adapter):
|
class ValidityPeriodAdapter(Adapter):
|
||||||
@@ -286,8 +286,8 @@ class EF_SMSP(LinFixedEF):
|
|||||||
'tp_dest_addr'/ScAddr,
|
'tp_dest_addr'/ScAddr,
|
||||||
'tp_sc_addr'/ScAddr,
|
'tp_sc_addr'/ScAddr,
|
||||||
|
|
||||||
'tp_pid'/HexAdapter(Bytes(1)),
|
'tp_pid'/Bytes(1),
|
||||||
'tp_dcs'/HexAdapter(Bytes(1)),
|
'tp_dcs'/Bytes(1),
|
||||||
'tp_vp_minutes'/EF_SMSP.ValidityPeriodAdapter(Byte))
|
'tp_vp_minutes'/EF_SMSP.ValidityPeriodAdapter(Byte))
|
||||||
|
|
||||||
# TS 51.011 Section 10.5.7
|
# TS 51.011 Section 10.5.7
|
||||||
@@ -309,14 +309,14 @@ class EF_SMSR(LinFixedEF):
|
|||||||
def __init__(self, fid='6f47', sfid=None, name='EF.SMSR', desc='SMS status reports', rec_len=(30, 30), **kwargs):
|
def __init__(self, fid='6f47', sfid=None, name='EF.SMSR', desc='SMS status reports', rec_len=(30, 30), **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct(
|
self._construct = Struct(
|
||||||
'sms_record_id'/Int8ub, 'sms_status_report'/HexAdapter(Bytes(29)))
|
'sms_record_id'/Int8ub, 'sms_status_report'/Bytes(29))
|
||||||
|
|
||||||
|
|
||||||
class EF_EXT(LinFixedEF):
|
class EF_EXT(LinFixedEF):
|
||||||
def __init__(self, fid, sfid=None, name='EF.EXT', desc='Extension', rec_len=(13, 13), **kwargs):
|
def __init__(self, fid, sfid=None, name='EF.EXT', desc='Extension', rec_len=(13, 13), **kwargs):
|
||||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct(
|
self._construct = Struct(
|
||||||
'record_type'/Int8ub, 'extension_data'/HexAdapter(Bytes(11)), 'identifier'/Int8ub)
|
'record_type'/Int8ub, 'extension_data'/Bytes(11), 'identifier'/Int8ub)
|
||||||
|
|
||||||
# TS 51.011 Section 10.5.16
|
# TS 51.011 Section 10.5.16
|
||||||
class EF_CMI(LinFixedEF):
|
class EF_CMI(LinFixedEF):
|
||||||
@@ -589,11 +589,11 @@ class EF_ACC(TransparentEF):
|
|||||||
class EF_LOCI(TransparentEF):
|
class EF_LOCI(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "7802570222f81009780000",
|
( "7802570222f81009780000",
|
||||||
{ "tmsi": "78025702", "lai": "22f8100978", "tmsi_time": 0, "lu_status": "updated" } ),
|
{ "tmsi": h2b("78025702"), "lai": h2b("22f8100978"), "tmsi_time": 0, "lu_status": "updated" } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f7e', sfid=None, name='EF.LOCI', desc='Location Information', size=(11, 11)):
|
def __init__(self, fid='6f7e', sfid=None, name='EF.LOCI', desc='Location Information', size=(11, 11)):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||||
self._construct = Struct('tmsi'/HexAdapter(Bytes(4)), 'lai'/HexAdapter(Bytes(5)), 'tmsi_time'/Int8ub,
|
self._construct = Struct('tmsi'/Bytes(4), 'lai'/Bytes(5), 'tmsi_time'/Int8ub,
|
||||||
'lu_status'/Enum(Byte, updated=0, not_updated=1, plmn_not_allowed=2,
|
'lu_status'/Enum(Byte, updated=0, not_updated=1, plmn_not_allowed=2,
|
||||||
location_area_not_allowed=3))
|
location_area_not_allowed=3))
|
||||||
|
|
||||||
@@ -751,22 +751,22 @@ class EF_NIA(LinFixedEF):
|
|||||||
# TS 51.011 Section 10.3.32
|
# TS 51.011 Section 10.3.32
|
||||||
class EF_Kc(TransparentEF):
|
class EF_Kc(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "837d783609a3858f05", { "kc": "837d783609a3858f", "cksn": 5 } ),
|
( "837d783609a3858f05", { "kc": h2b("837d783609a3858f"), "cksn": 5 } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f20', sfid=None, name='EF.Kc', desc='Ciphering key Kc', size=(9, 9), **kwargs):
|
def __init__(self, fid='6f20', sfid=None, name='EF.Kc', desc='Ciphering key Kc', size=(9, 9), **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs)
|
||||||
self._construct = Struct('kc'/HexAdapter(Bytes(8)), 'cksn'/Int8ub)
|
self._construct = Struct('kc'/Bytes(8), 'cksn'/Int8ub)
|
||||||
|
|
||||||
# TS 51.011 Section 10.3.33
|
# TS 51.011 Section 10.3.33
|
||||||
class EF_LOCIGPRS(TransparentEF):
|
class EF_LOCIGPRS(TransparentEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( "ffffffffffffff22f8990000ff01",
|
( "ffffffffffffff22f8990000ff01",
|
||||||
{ "ptmsi": "ffffffff", "ptmsi_sig": "ffffff", "rai": "22f8990000ff", "rau_status": "not_updated" } ),
|
{ "ptmsi": h2b("ffffffff"), "ptmsi_sig": h2b("ffffff"), "rai": h2b("22f8990000ff"), "rau_status": "not_updated" } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6f53', sfid=None, name='EF.LOCIGPRS', desc='GPRS Location Information', size=(14, 14)):
|
def __init__(self, fid='6f53', sfid=None, name='EF.LOCIGPRS', desc='GPRS Location Information', size=(14, 14)):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||||
self._construct = Struct('ptmsi'/HexAdapter(Bytes(4)), 'ptmsi_sig'/HexAdapter(Bytes(3)),
|
self._construct = Struct('ptmsi'/Bytes(4), 'ptmsi_sig'/Bytes(3),
|
||||||
'rai'/HexAdapter(Bytes(6)),
|
'rai'/Bytes(6),
|
||||||
'rau_status'/Enum(Byte, updated=0, not_updated=1, plmn_not_allowed=2,
|
'rau_status'/Enum(Byte, updated=0, not_updated=1, plmn_not_allowed=2,
|
||||||
routing_area_not_allowed=3))
|
routing_area_not_allowed=3))
|
||||||
|
|
||||||
@@ -867,12 +867,12 @@ class EF_PNN(LinFixedEF):
|
|||||||
class FullNameForNetwork(BER_TLV_IE, tag=0x43):
|
class FullNameForNetwork(BER_TLV_IE, tag=0x43):
|
||||||
# TS 24.008 10.5.3.5a
|
# TS 24.008 10.5.3.5a
|
||||||
# TODO: proper decode
|
# TODO: proper decode
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class ShortNameForNetwork(BER_TLV_IE, tag=0x45):
|
class ShortNameForNetwork(BER_TLV_IE, tag=0x45):
|
||||||
# TS 24.008 10.5.3.5a
|
# TS 24.008 10.5.3.5a
|
||||||
# TODO: proper decode
|
# TODO: proper decode
|
||||||
_construct = HexAdapter(GreedyBytes)
|
_construct = GreedyBytes
|
||||||
|
|
||||||
class NetworkNameCollection(TLV_IE_Collection, nested=[FullNameForNetwork, ShortNameForNetwork]):
|
class NetworkNameCollection(TLV_IE_Collection, nested=[FullNameForNetwork, ShortNameForNetwork]):
|
||||||
pass
|
pass
|
||||||
@@ -885,14 +885,14 @@ class EF_PNN(LinFixedEF):
|
|||||||
class EF_OPL(LinFixedEF):
|
class EF_OPL(LinFixedEF):
|
||||||
_test_de_encode = [
|
_test_de_encode = [
|
||||||
( '62f2100000fffe01',
|
( '62f2100000fffe01',
|
||||||
{ "lai": { "mcc_mnc": "262-01", "lac_min": "0000", "lac_max": "fffe" }, "pnn_record_id": 1 } ),
|
{ "lai": { "mcc_mnc": "262-01", "lac_min": h2b("0000"), "lac_max": h2b("fffe") }, "pnn_record_id": 1 } ),
|
||||||
( '216354789abcde12',
|
( '216354789abcde12',
|
||||||
{ "lai": { "mcc_mnc": "123-456", "lac_min": "789a", "lac_max": "bcde" }, "pnn_record_id": 18 } ),
|
{ "lai": { "mcc_mnc": "123-456", "lac_min": h2b("789a"), "lac_max": h2b("bcde") }, "pnn_record_id": 18 } ),
|
||||||
]
|
]
|
||||||
def __init__(self, fid='6fc6', sfid=None, name='EF.OPL', rec_len=(8, 8), desc='Operator PLMN List', **kwargs):
|
def __init__(self, fid='6fc6', sfid=None, name='EF.OPL', rec_len=(8, 8), desc='Operator PLMN List', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct('lai'/Struct('mcc_mnc'/PlmnAdapter(Bytes(3)),
|
self._construct = Struct('lai'/Struct('mcc_mnc'/PlmnAdapter(Bytes(3)),
|
||||||
'lac_min'/HexAdapter(Bytes(2)), 'lac_max'/HexAdapter(Bytes(2))), 'pnn_record_id'/Int8ub)
|
'lac_min'/Bytes(2), 'lac_max'/Bytes(2)), 'pnn_record_id'/Int8ub)
|
||||||
|
|
||||||
# TS 51.011 Section 10.3.44 + TS 31.102 4.2.62
|
# TS 51.011 Section 10.3.44 + TS 31.102 4.2.62
|
||||||
class EF_MBI(LinFixedEF):
|
class EF_MBI(LinFixedEF):
|
||||||
@@ -941,8 +941,8 @@ class EF_SPDI(TransparentEF):
|
|||||||
class EF_MMSN(LinFixedEF):
|
class EF_MMSN(LinFixedEF):
|
||||||
def __init__(self, fid='6fce', sfid=None, name='EF.MMSN', rec_len=(4, 20), desc='MMS Notification', **kwargs):
|
def __init__(self, fid='6fce', sfid=None, name='EF.MMSN', rec_len=(4, 20), desc='MMS Notification', **kwargs):
|
||||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len, **kwargs)
|
||||||
self._construct = Struct('mms_status'/HexAdapter(Bytes(2)), 'mms_implementation'/HexAdapter(Bytes(1)),
|
self._construct = Struct('mms_status'/Bytes(2), 'mms_implementation'/Bytes(1),
|
||||||
'mms_notification'/HexAdapter(Bytes(this._.total_len-4)), 'ext_record_nr'/Byte)
|
'mms_notification'/Bytes(this._.total_len-4), 'ext_record_nr'/Byte)
|
||||||
|
|
||||||
# TS 51.011 Annex K.1
|
# TS 51.011 Annex K.1
|
||||||
class MMS_Implementation(BER_TLV_IE, tag=0x80):
|
class MMS_Implementation(BER_TLV_IE, tag=0x80):
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ class DecTestCase(unittest.TestCase):
|
|||||||
{'priority': 1, 'identifier': 1, 'key_index': 2},
|
{'priority': 1, 'identifier': 1, 'key_index': 2},
|
||||||
{'priority': 2, 'identifier': 0, 'key_index': 0}],
|
{'priority': 2, 'identifier': 0, 'key_index': 0}],
|
||||||
'hnet_pubkey_list': [
|
'hnet_pubkey_list': [
|
||||||
{'hnet_pubkey_identifier': 27, 'hnet_pubkey': hnet_pubkey_profile_b.lower()}, # because h2b/b2h returns all lower-case
|
{'hnet_pubkey_identifier': 27, 'hnet_pubkey': h2b(hnet_pubkey_profile_b)}, # because h2b/b2h returns all lower-case
|
||||||
{'hnet_pubkey_identifier': 30, 'hnet_pubkey': hnet_pubkey_profile_a.lower()}]
|
{'hnet_pubkey_identifier': 30, 'hnet_pubkey': h2b(hnet_pubkey_profile_a)}]
|
||||||
}
|
}
|
||||||
|
|
||||||
def testSplitHexStringToListOf5ByteEntries(self):
|
def testSplitHexStringToListOf5ByteEntries(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user