lots of file definitions for classic SIM and USIM

Change-Id: I91475df4a5eaca423473aaebba8c69c54c9a0c1a
This commit is contained in:
Harald Welte 2021-04-11 00:01:35 +02:00
parent 9853e247a2
commit 790b2709bd
2 changed files with 490 additions and 31 deletions

View File

@ -6,6 +6,7 @@ Various constants from ETSI TS 131 102
#
# Copyright (C) 2020 Supreeth Herle <herlesupreeth@gmail.com>
# Copyright (C) 2021 Harald Welte <laforge@osmocom.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -270,10 +271,14 @@ EF_USIM_ADF_map = {
from struct import unpack, pack
from construct import *
from pySim.construct import HexAdapter
from pySim.construct import LV, HexAdapter, BcdAdapter
from pySim.filesystem import *
from pySim.ts_102_221 import EF_ARR
from pySim.ts_51_011 import EF_IMSI, EF_xPLMNwAcT, EF_SPN, EF_CBMI, EF_ACC, EF_PLMNsel, EF_AD
from pySim.ts_51_011 import EF_CBMID, EF_CBMIR
from pySim.ts_51_011 import EF_CBMID, EF_CBMIR, EF_ADN, EF_SMS, EF_MSISDN, EF_SMSP, EF_SMSS
from pySim.ts_51_011 import EF_SMSR, EF_DCK, EF_EXT, EF_CNL, EF_OPL, EF_MBI, EF_MWIS
from pySim.ts_51_011 import EF_MMSN, EF_MMSICP, EF_MMSUP, EF_MMSUCP, EF_VGCS, EF_VGCSS, EF_NIA
from pySim.ts_51_011 import EF_ACMmax, EF_AAeM, EF_eMLPP, EF_CMI
import pySim.ts_102_221
@ -422,8 +427,8 @@ class EF_Keys(TransparentEF):
# TS 31.103 Section 4.2.7
class EF_UST(TransparentEF):
def __init__(self, fid='6f38', sfid=0x04, name='EF.UST', desc='USIM Service Table'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, size={1,17})
def __init__(self, fid='6f38', sfid=0x04, name='EF.UST', desc='USIM Service Table', size={1,17}):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, size=size)
# add those commands to the general commands of a TransparentEF
self.shell_commands += [self.AddlShellCommands()]
def _decode_bin(self, in_bin):
@ -464,23 +469,182 @@ class EF_ECC(LinFixedEF):
desc='Emergency Call Codes'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len={4,20})
# TS 31.102 Section 4.2.17
class EF_LOCI(TransparentEF):
def __init__(self, fid='6f7e', sfid=0x0b, name='EF.LOCI', desc='Locationn information', size={11,11}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('tmsi'/HexAdapter(Bytes(4)), 'lai'/HexAdapter(Bytes(5)), 'rfu'/Int8ub,
'lu_status'/Int8ub)
# TS 31.102 Section 4.2.23
class EF_PSLOCI(TransparentEF):
def __init__(self, fid='6f73', sfid=0x0c, name='EF.PSLOCI', desc='PS Locationn information', size={14,14}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('ptmsi'/HexAdapter(Bytes(4)), 'ptmsi_sig'/HexAdapter(Bytes(3)),
'rai'/HexAdapter(Bytes(6)), 'rau_status'/Int8ub)
# TS 31.102 Section 4.2.33
class EF_ICI(CyclicEF):
def __init__(self, fid='6f80', sfid=0x14, name='EF.ICI', rec_len={28,48},
desc='Incoming Call Information'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('alpha_id'/Bytes(this._.total_len-28),
'len_of_bcd_contents'/Int8ub,
'ton_npi'/Int8ub,
'call_number'/BcdAdapter(Bytes(10)),
'cap_cfg2_record_id'/Int8ub,
'ext5_record_id'/Int8ub,
'date_and_time'/BcdAdapter(Bytes(7)),
'duration'/Int24ub,
'status'/Byte,
'link_to_phonebook'/Bytes(3))
# TS 31.102 Section 4.2.34
class EF_OCI(CyclicEF):
def __init__(self, fid='6f81', sfid=0x15, name='EF.OCI', rec_len={27,47},
desc='Outgoing Call Information'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('alpha_id'/Bytes(this._.total_len-27),
'len_of_bcd_contents'/Int8ub,
'ton_npi'/Int8ub,
'call_number'/BcdAdapter(Bytes(10)),
'cap_cfg2_record_id'/Int8ub,
'ext5_record_id'/Int8ub,
'date_and_time'/BcdAdapter(Bytes(7)),
'duration'/Int24ub,
'link_to_phonebook'/Bytes(3))
# TS 31.102 Section 4.2.35
class EF_ICT(CyclicEF):
def __init__(self, fid='6f82', sfid=None, name='EF.ICT', rec_len={3,3},
desc='Incoming Call Timer'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('accumulated_call_timer'/Int24ub)
# TS 31.102 Section 4.2.38
class EF_CCP2(LinFixedEF):
def __init__(self, fid='6f4f', sfid=0x16, name='EF.CCP2', desc='Capability Configuration Parameters 2'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len={15,None})
# TS 31.102 Section 4.2.48
class EF_ACL(TransparentEF):
def __init__(self, fid='6f57', sfid=None, name='EF.ACL', size={32,None},
desc='Access Point Name Control List'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('num_of_apns'/Int8ub, 'tlvs'/GreedyBytes)
# TS 31.102 Section 4.2.51
class EF_START_HFN(TransparentEF):
def __init__(self, fid='6f5b', sfid=0x0f, name='EF.START-HFN', size={6,6},
desc='Initialisation values for Hyperframe number'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('start_cs'/Int24ub, 'start_ps'/Int24ub)
# TS 31.102 Section 4.2.52
class EF_THRESHOLD(TransparentEF):
def __init__(self, fid='6f5c', sfid=0x10, name='EF.THRESHOLD', size={3,3},
desc='Maximum value of START'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('max_start'/Int24ub)
# TS 31.102 Section 4.2.77
class EF_VGCSCA(TransRecEF):
def __init__(self, fid='6fd4', sfid=None, name='EF.VGCSCA', size={2,100}, rec_len=2,
desc='Voice Group Call Service Ciphering Algorithm'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
self._construct = Struct('alg_v_ki_1'/Int8ub, 'alg_v_ki_2'/Int8ub)
# TS 31.102 Section 4.2.79
class EF_GBABP(TransparentEF):
def __init__(self, fid='6fd6', sfid=None, name='EF.GBABP', size={3,50},
desc='GBA Bootstrapping parameters'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('rand'/LV, 'b_tid'/LV, 'key_lifetime'/LV)
# TS 31.102 Section 4.2.80
class EF_MSK(LinFixedEF):
def __init__(self, fid='6fd7', sfid=None, name='EF.MSK', desc='MBMS Service Key List'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len={20,None})
msk_ts_constr = Struct('msk_id'/Int32ub, 'timestamp_counter'/Int32ub)
self._construct = Struct('key_domain_id'/Bytes(3),
'num_msk_id'/Int8ub,
'msk_ids'/msk_ts_constr[this.num_msk_id])
# TS 31.102 Section 4.2.85
class EF_EHPLMNPI(TransparentEF):
def __init__(self, fid='6fdb', sfid=None, name='EF.EHPLMNPI', size={1,1},
desc='Equivalent HPLMN Presentation Indication'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('presentation_ind'/
Enum(Byte, no_preference=0, display_highest_prio_only=1, display_all=2))
# TS 31.102 Section 4.2.91
class EF_EPSLOCI(TransparentEF):
def __init__(self, fid='6fe3', sfid=0x1e, name='EF.EPSLOCI', size={18,18},
desc='EPS Location Information'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
upd_status_constr = Enum(Byte, updated=0, not_updated=1, roaming_not_allowed=2)
self._construct = Struct('guti'/Bytes(12), 'last_visited_registered_tai'/Bytes(5),
'eps_update_status'/upd_status_constr)
# TS 31.102 Section 4.2.96
class EF_PWS(TransparentEF):
def __init__(self, fid='6fec', sfid=None, name='EF.PWS', desc='Public Warning System', size={1,1}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
pws_config = FlagsEnum(Byte, ignore_pws_in_hplmn_and_equivalent=1, ignore_pws_in_vplmn=2)
self._construct = Struct('pws_configuration'/pws_config)
# TS 31.102 Section 4.2.101
class EF_IPS(CyclicEF):
def __init__(self, fid='6ff1', sfid=None, name='EF.IPS', rec_len={4,4},
desc='IMEI(SV) Pairing Status'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('status'/PaddedString(2, 'ascii'),
'link_to_ef_ipd'/Int8ub, 'rfu'/Byte)
######################################################################
# DF.5GS
######################################################################
# TS 31.102 Section 4.4.11.2
class EF_5GS3GPPLOCI(TransparentEF):
def __init__(self, fid='4f01', sfid=0x01, name='EF.5GS3GPPLOCI', size={20,20},
desc='5S 3GP location information'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
upd_status_constr = Enum(Byte, updated=0, not_updated=1, roaming_not_allowed=2)
self._construct = Struct('5g_guti'/Bytes(13), 'last_visited_registered_tai_in_5gs'/Bytes(6),
'5gs_update_status'/upd_status_constr)
# TS 31.102 Section 4.4.11.7
class EF_UAC_AIC(TransparentEF):
def __init__(self, fid='4f06', sfid=0x06, name='EF.UAC_AIC', size={4,4},
desc='UAC Access Identities Configuration'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
cfg_constr = FlagsEnum(Byte, multimedia_priority_service=1,
mission_critical_service=2)
self._construct = Struct('uac_access_id_config'/cfg_constr)
# TS 31.102 Section 4.4.11.10
class EF_OPL5G(LinFixedEF):
def __init__(self, fid='6f08', sfid=0x08, name='EF.OPL5G', desc='5GS Operator PLMN List'):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len={10,None})
self._construct = Struct('tai'/Bytes(9), 'pnn_record_id'/Int8ub)
class DF_USIM_5GS(CardDF):
def __init__(self, fid='5FC0', name='DF.5GS', desc='5GS related files'):
super().__init__(fid=fid, name=name, desc=desc)
files = [
# I'm looking at 31.102 R15.9
TransparentEF('4F01', None, 'EF.5GS3GPPLOCI', '5GS 3GPP location information', size={20,20}),
TransparentEF('4F02', None, 'EF.5GSN3GPPLOCI', '5GS non-3GPP location information', size={20,20}),
#LinFixedEF('4F03', None, 'EF.5GS3GPPNSC', '5GS 3GPP Access NAS Security Context'),
#LinFixedEF('4F04', None, 'EF.5GSN3GPPNSC', '5GS non-3GPP Access NAS Security Context'),
TransparentEF('4F05', None, 'EF.5GAUTHKEYS', '5G authentication keys', size={68, None}),
TransparentEF('4F06', None, 'EF.UAC_AIC', 'UAC Access Identities Configuration', size={4, 4}),
EF_SUCI_Calc_Info(), #TransparentEF('4F07', None, 'EF.SUCI_Calc_Info', 'SUCI Calculation Information', size={2, None}),
LinFixedEF('4F08', None, 'EF.OPL5G', '5GS Operator PLMN List', rec_len={10, None}),
# TransparentEF('4F09', None, 'EF.NSI', 'Network Specific Identifier'), # FFS
TransparentEF('4F0A', None, 'EF.Routing_Indicator', 'Routing Indicator', size={4,4}),
EF_5GS3GPPLOCI(),
EF_5GS3GPPLOCI('4f02', 0x02, 'EF.5GSN3GPPLOCI', '5GS non-3GPP location information'),
LinFixedEF('4F03', 0x03, 'EF.5GS3GPPNSC', '5GS 3GPP Access NAS Security Context', rec_len={57,None}),
LinFixedEF('4F04', 0x04, 'EF.5GSN3GPPNSC', '5GS non-3GPP Access NAS Security Context', rec_len={57,None}),
TransparentEF('4F05', 0x05, 'EF.5GAUTHKEYS', '5G authentication keys', size={68, None}),
EF_UAC_AIC(),
EF_SUCI_Calc_Info(),
EF_OPL5G(),
TransparentEF('4F09', 0x09, 'EF.NSI', 'Network Specific Identifier'),
TransparentEF('4F0A', 0x0a, 'EF.Routing_Indicator', 'Routing Indicator', size={4,4}),
]
self.add_files(files)
class ADF_USIM(CardADF):
@ -498,7 +662,7 @@ class ADF_USIM(CardADF):
EF_xPLMNwAcT('6f60', 0x0a, 'EF.PLMNwAcT',
'User controlled PLMN Selector with Access Technology'),
TransparentEF('6f31', 0x12, 'EF.HPPLMN', 'Higher Priority PLMN search period'),
# EF.ACMmax
EF_ACMmax(),
EF_UST(),
CyclicEF('6f39', None, 'EF.ACM', 'Accumulated call meter', rec_len={3,3}),
TransparentEF('6f3e', None, 'EF.GID1', 'Group Identifier Level 1'),
@ -508,11 +672,92 @@ class ADF_USIM(CardADF):
EF_CBMI(),
EF_ACC(sfid=0x06),
EF_PLMNsel('6f7b', 0x0d, 'EF.FPLMN', 'Forbidden PLMNs', size={12,None}),
TransparentEF('6f7e', 0x0b, 'EF.LOCI', 'Locationn information', size={11,11}),
EF_LOCI(),
EF_AD(sfid=0x03),
EF_CBMID(sfid=0x0e),
EF_ECC(),
EF_CBMIR(),
EF_PSLOCI(),
EF_ADN('6f3b', None, 'EF.FDN', 'Fixed Dialling Numbers'),
EF_SMS('6f3c', None),
EF_MSISDN(),
EF_SMSP(),
EF_SMSS(),
EF_ADN('6f49', None, 'EF.SDN', 'Service Dialling Numbers'),
EF_EXT('6f4b', None, 'EF.EXT2', 'Extension2 (FDN)'),
EF_EXT('6f4c', None, 'EF.EXT3', 'Extension2 (SDN)'),
EF_SMSR(),
EF_ICI(),
EF_OCI(),
EF_ICT(),
EF_ICT('6f83', None, 'EF.OCT', 'Outgoing Call Timer'),
EF_EXT('6f4e', None, 'EF.EXT5', 'Extension5 (ICI/OCI/MSISDN)'),
EF_CCP2(),
EF_eMLPP(),
EF_AAeM(),
# EF_Hiddenkey
EF_ADN('6f4d', None, 'EF.BDN', 'Barred Dialling Numbers'),
EF_EXT('6f55', None, 'EF.EXT4', 'Extension4 (BDN/SSC)'),
EF_CMI(),
EF_UST('6f56', 0x05, 'EF.EST', 'Enabled Services Table', size={1,None}),
EF_ACL(),
EF_DCK(),
EF_CNL(),
EF_START_HFN(),
EF_THRESHOLD(),
EF_xPLMNwAcT('6f61', 0x11, 'EF.OPLMNwAcT',
'User controlled PLMN Selector with Access Technology'),
EF_ARR('6f06', 0x17),
TransparentEF('6fc4', None, 'EF.NETPAR', 'Network Parameters'),
LinFixedEF('6fc5', 0x19, 'EF.PNN', 'PLMN Network Name'),
EF_OPL(),
EF_ADN('6fc7', None, 'EF.MBDN', 'Mailbox Dialling Numbers'),
EF_MBI(),
EF_MWIS(),
EF_ADN('6fcb', None, 'EF.CFIS', 'Call Forwarding Indication Status'),
EF_EXT('6fcc', None, 'EF.EXT7', 'Extension7 (CFIS)'),
TransparentEF('6fcd', None, 'EF.SPDI', 'Service Provider Display Information'),
EF_MMSN(),
EF_EXT('6fcf', None, 'EF.EXT8', 'Extension8 (MMSN)'),
EF_MMSICP(),
EF_MMSUP(),
EF_MMSUCP(),
EF_NIA(),
EF_VGCS(),
EF_VGCSS(),
EF_VGCS('6fb3', None, 'EF.VBS', 'Voice Broadcast Service'),
EF_VGCSS('6fb4', None, 'EF.VBSS', 'Voice Broadcast Service Status'),
EF_VGCSCA(),
EF_VGCSCA('6fd5', None, 'EF.VBCSCA', 'Voice Broadcast Service Ciphering Algorithm'),
EF_GBABP(),
EF_MSK(),
LinFixedEF('6fd8', None, 'EF.MUK', 'MBMS User Key'),
LinFixedEF('6fda', None, 'EF.GBANL', 'GBA NFA List'),
EF_PLMNsel('6fd9', 0x1d, 'EF.EHPLMN', 'Equivalent HPLMN', size={12,None}),
EF_EHPLMNPI(),
LinFixedEF('6fdd', None, 'EF.NAFKCA', 'NAF Key Centre Address'),
TransparentEF('6fde', None, 'EF.SPNI', 'Service Provider Name Icon'),
LinFixedEF('6fdf', None, 'EF.PNNI', 'PLMN Network Name Icon'),
LinFixedEF('6fe2', None, 'EF.NCP-IP', 'Network Connectivity Parameters for USIM IP connections'),
EF_EPSLOCI('6fe3', 0x1e, 'EF.EPSLOCI', 'EPS location information'),
LinFixedEF('6fe4', 0x18, 'EF.EPSNSC', 'EPS NAS Security Context', rec_len={54,128}),
TransparentEF('6fe6', None, 'EF.UFC', 'USAT Facility Control', size={1,16}),
TransparentEF('6fe8', None, 'EF.NASCONFIG', 'Non Access Stratum Configuration'),
# UICC IARI (only in cards that have no ISIM)
EF_PWS(),
LinFixedEF('6fed', None, 'EF.FDNURI', 'Fixed Dialling Numbers URI'),
LinFixedEF('6fee', None, 'EF.BDNURI', 'Barred Dialling Numbers URI'),
LinFixedEF('6fef', None, 'EF.SDNURI', 'Service Dialling Numbers URI'),
EF_IPS(),
# FIXME: from EF_ePDGid onwards
# FIXME: DF_SoLSA
# FIXME: DF_PHONEBOOK
# FIXME: DF_GSM_ACCESS
# FIXME: DF_WLAN
# FIXME: DF_HNB
# FIXME: DF_ProSe
# FIXME: DF_ACDC
# FIXME: DF_TV
DF_USIM_5GS(),
]
self.add_files(files)

View File

@ -332,6 +332,9 @@ EF_AD_mode_map = {
from pySim.utils import *
from struct import pack, unpack
from construct import *
from construct import Optional as COptional
from pySim.construct import HexAdapter, BcdAdapter
from pySim.filesystem import *
import pySim.ts_102_221
@ -395,6 +398,35 @@ class EF_SMSP(LinFixedEF):
def __init__(self, fid='6f42', sfid=None, name='EF.SMSP', desc='Short message service parameters'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len={28, None})
# TS 51.011 Section 10.5.7
class EF_SMSS(TransparentEF):
class MemCapAdapter(Adapter):
def _decode(self, obj, context, path):
return False if obj & 1 else True
def _encode(self, obj, context, path):
return 0 if obj else 1
def __init__(self, fid='6f43', sfid=None, name='EF.SMSS', desc='SMS status', size={2,8}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('last_used_tpmr'/Int8ub, 'memory_capacity_exceeded'/self.MemCapAdapter(Int8ub))
# TS 51.011 Section 10.5.8
class EF_SMSR(LinFixedEF):
def __init__(self, fid='6f47', sfid=None, name='EF.SMSR', desc='SMS status reports', rec_len={30,30}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('sms_record_id'/Int8ub, 'sms_status_report'/HexAdapter(Bytes(29)))
class EF_EXT(LinFixedEF):
def __init__(self, fid, sfid=None, name='EF.EXT', desc='Extension', rec_len={13,13}):
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('record_type'/Int8ub, 'extension_data'/HexAdapter(Bytes(11)), 'identifier'/Int8ub)
# TS 51.011 Section 10.5.16
class EF_CMI(LinFixedEF):
def __init__(self, fid='6f58', sfid=None, name='EF.CMI', rec_len={2,21},
desc='Comparison Method Informatoin'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('alpha_id'/Bytes(this._.total_len-1), 'comparison_method_id'/Int8ub)
class DF_TELECOM(CardDF):
def __init__(self, fid='7f10', name='DF.TELECOM', desc=None):
super().__init__(fid=fid, name=name, desc=desc)
@ -406,10 +438,15 @@ class DF_TELECOM(CardDF):
LinFixedEF(fid='6f4f', name='EF.ECCP', desc='Extended Capability Configuration Parameters', rec_len={15,32}),
EF_MSISDN(),
EF_SMSP(),
TransparentEF(fid='6f43', name='EF.SMSS', desc='SMS status', size={2,8}),
# LND, SDN, EXT1, EXT2, EXT3, BDN, EXT4
LinFixedEF(fid='6f47', name='EF.SMSR', desc='SMS status reports', rec_len={30,30}),
# CMI
EF_SMSS(),
# LND, SDN
EF_EXT('6f4a', None, 'EF.EXT1', 'Extension1 (ADN/SSC)'),
EF_EXT('6f4b', None, 'EF.EXT2', 'Extension2 (FDN/SSC)'),
EF_EXT('6f4c', None, 'EF.EXT3', 'Extension3 (SDN)'),
EF_ADN(fid='6f4d', name='EF.BDN', desc='Barred Dialling Numbers'),
EF_EXT('6f4e', None, 'EF.EXT4', 'Extension4 (BDN/SSC)'),
EF_SMSR(),
EF_CMI(),
]
self.add_files(files)
@ -455,6 +492,13 @@ class EF_PLMNsel(TransRecEF):
else:
return enc_plmn(in_json['mcc'], in_json['mnc'])
# TS 51.011 Section 10.3.6
class EF_ACMmax(TransparentEF):
def __init__(self, fid='6f37', sfid=None, name='EF.ACMmax', size={3,3},
desc='ACM maximum value'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('acm_max'/Int24ub)
# TS 51.011 Section 10.3.7
class EF_ServiceTable(TransparentEF):
def __init__(self, fid, sfid, name, desc, size, table):
@ -499,6 +543,14 @@ class EF_ACC(TransparentEF):
def _encode_bin(self, abstract):
return pack('!H', abstract['acc'])
# TS 51.011 Section 10.3.16
class EF_LOCI(TransparentEF):
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)
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,
location_area_not_allowed=3))
# TS 51.011 Section 10.3.18
class EF_AD(TransparentEF):
OP_MODE = {
@ -526,7 +578,37 @@ class EF_AD(TransparentEF):
res += pack('!B', abstract['len_of_mnc_in_imsi'])
return res
# TS 51.011 Section 10.3.13
# TS 51.011 Section 10.3.20 / 10.3.22
class EF_VGCS(TransRecEF):
def __init__(self, fid='6fb1', sfid=None, name='EF.VGCS', size={4,200}, rec_len=4,
desc='Voice Group Call Service'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
self._construct = BcdAdapter(Bytes(4))
# TS 51.011 Section 10.3.21 / 10.3.23
class EF_VGCSS(TransparentEF):
def __init__(self, fid='6fb2', sfid=None, name='EF.VGCSS', size={7,7},
desc='Voice Group Call Service Status'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = BitStruct('flags'/Bit[50], Padding(6, pattern=b'\xff'))
# TS 51.011 Section 10.3.24
class EF_eMLPP(TransparentEF):
def __init__(self, fid='6fb5', sfid=None, name='EF.eMLPP', size={2,2},
desc='enhanced Multi Level Pre-emption and Priority'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
FlagsConstruct = FlagsEnum(Byte, A=1, B=2, zero=4, one=8, two=16, three=32, four=64)
self._construct = Struct('levels'/FlagsConstruct, 'fast_call_setup_cond'/FlagsConstruct)
# TS 51.011 Section 10.3.25
class EF_AAeM(TransparentEF):
def __init__(self, fid='6fb6', sfid=None, name='EF.AAeM', size={1,1},
desc='Automatic Answer for eMLPP Service'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
FlagsConstruct = FlagsEnum(Byte, A=1, B=2, zero=4, one=8, two=16, three=32, four=64)
self._construct = Struct('auto_answer_prio_levels'/FlagsConstruct)
# TS 51.011 Section 10.3.26
class EF_CBMID(EF_CBMI):
def __init__(self, fid='6f48', sfid=None, name='EF.CBMID', size={2,None}, rec_len=2,
desc='Cell Broadcast Message Identifier for Data Download'):
@ -544,6 +626,52 @@ class EF_CBMIR(TransRecEF):
desc='Cell Broadcast message identifier range selection'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
# TS 51.011 Section 10.3.29
class EF_DCK(TransparentEF):
def __init__(self, fid='6f2c', sfid=None, name='EF.DCK', size={16,16},
desc='Depersonalisation Control Keys'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('network'/BcdAdapter(Bytes(4)),
'network_subset'/BcdAdapter(Bytes(4)),
'service_provider'/BcdAdapter(Bytes(4)),
'corporate'/BcdAdapter(Bytes(4)))
# TS 51.011 Section 10.3.30
class EF_CNL(TransRecEF):
def __init__(self, fid='6f32', sfid=None, name='EF.CNL', size={6,None}, rec_len=6,
desc='Co-operative Network List'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
def _decode_record_hex(self, in_hex):
(in_plmn, sub, svp, corp) = unpack('!3sBBB', h2b(in_hex))
res = dec_plmn(b2h(in_plmn))
res['network_subset'] = sub
res['service_provider_id'] = svp
res['corporate_id'] = corp
return res
def _encode_record_hex(self, in_json):
plmn = enc_plmn(in_json['mcc'], in_json['mnc'])
return b2h(pack('!3sBBB', h2b(plmn), res['network_subset'], res['service_provider_id'],
res['corporate_id']))
# TS 51.011 Section 10.3.31
class EF_NIA(LinFixedEF):
def __init__(self, fid='6f51', sfid=None, name='EF.NIA', rec_len={1,32},
desc='Network\'s Indication of Alerting'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('alerting_category'/Int8ub, 'category'/GreedyBytes)
# TS 51.011 Section 10.3.32
class EF_Kc(TransparentEF):
def __init__(self, fid='6f20', sfid=None, name='EF.Kc', desc='Ciphering key Kc', size={9,9}):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = Struct('kc'/HexAdapter(Bytes(8)), 'cksn'/Int8ub)
# TS 51.011 Section 10.3.33
class EF_LOCIGPRS(TransparentEF):
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)
self._construct = Struct('ptmsi'/Bytes(4), 'ptmsi_sig'/Int8ub, 'rai'/Bytes(6),
'rau_status'/Enum(Byte, updated=0, not_updated=1, plmn_not_allowed=2,
routing_area_not_allowed=3))
# TS 51.011 Section 10.3.35..37
class EF_xPLMNwAcT(TransRecEF):
@ -589,6 +717,68 @@ class EF_xPLMNwAcT(TransRecEF):
u16 |= 0x0088
return '%04X'%(u16)
# TS 51.011 Section 10.3.38
class EF_CPBCCH(TransRecEF):
def __init__(self, fid='6f63', sfid=None, name='EF.CPBCCH', size={2,14}, rec_len=2,
desc='CPBCCH Information'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len)
self._construct = Struct('cpbcch'/Int16ub)
# TS 51.011 Section 10.3.39
class EF_InvScan(TransparentEF):
def __init__(self, fid='6f64', sfid=None, name='EF.InvScan', size={1,1},
desc='IOnvestigation Scan'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
self._construct = FlagsEnum(Byte, in_limited_service_mode=1, after_successful_plmn_selection=2)
# TS 51.011 Section 10.3.42
class EF_OPL(LinFixedEF):
def __init__(self, fid='6fc6', sfid=None, name='EF.OPL', rec_len={8,8}, desc='Operator PLMN List'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('lai'/Bytes(5), 'pnn_record_id'/Int8ub)
# TS 51.011 Section 10.3.44 + TS 31.102 4.2.62
class EF_MBI(LinFixedEF):
def __init__(self, fid='6fc9', sfid=None, name='EF.MBI', rec_len={4,5}, desc='Mailbox Identifier'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('mbi_voicemail'/Int8ub, 'mbi_fax'/Int8ub, 'mbi_email'/Int8ub,
'mbi_other'/Int8ub, 'mbi_videocall'/COptional(Int8ub))
# TS 51.011 Section 10.3.45 + TS 31.102 4.2.63
class EF_MWIS(LinFixedEF):
def __init__(self, fid='6fca', sfid=None, name='EF.MWIS', rec_len={5,6},
desc='Message Waiting Indication Status'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('mwi_status'/FlagsEnum(Byte, voicemail=1, fax=2, email=4, other=8, videomail=16),
'num_waiting_voicemail'/Int8ub,
'num_waiting_fax'/Int8ub, 'num_waiting_email'/Int8ub,
'num_waiting_other'/Int8ub, 'num_waiting_videomail'/COptional(Int8ub))
# TS 51.011 Section 10.3.51
class EF_MMSN(LinFixedEF):
def __init__(self, fid='6fce', sfid=None, name='EF.MMSN', rec_len={4,20}, desc='MMS Notification'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
self._construct = Struct('mms_status'/Bytes(2), 'mms_implementation'/Bytes(1),
'mms_notification'/Bytes(this._.total_len-4), 'ext_record_nr'/Byte)
# TS 51.011 Section 10.3.53
class EF_MMSICP(TransparentEF):
def __init__(self, fid='6fd0', sfid=None, name='EF.MMSICP', size={1,None},
desc='MMS Issuer Connectivity Parameters'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
# TS 51.011 Section 10.3.54
class EF_MMSUP(LinFixedEF):
def __init__(self, fid='6fd1', sfid=None, name='EF.MMSUP', rec_len={1,None},
desc='MMS User Preferences'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
# TS 51.011 Section 10.3.55
class EF_MMSUCP(TransparentEF):
def __init__(self, fid='6fd2', sfid=None, name='EF.MMSUCP', size={1,None},
desc='MMS User Connectivity Parameters'):
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
class DF_GSM(CardDF):
def __init__(self, fid='7f20', name='DF.GSM', desc='GSM Network related files'):
@ -596,12 +786,12 @@ class DF_GSM(CardDF):
files = [
EF_LP(),
EF_IMSI(),
TransparentEF('5f20', None, 'EF.Kc', 'Ciphering key Kc'),
EF_Kc(),
EF_PLMNsel(),
TransparentEF('6f31', None, 'EF.HPPLMN', 'Higher Priority PLMN search period'),
# ACMmax
EF_ServiceTable('6f37', None, 'EF.SST', 'SIM service table', table=EF_SST_map, size={2,16}),
CyclicEF('6f39', None, 'EF.ACM', 'Accumulated call meter', rec_len={4,3}),
EF_ACMmax(),
EF_ServiceTable('6f38', None, 'EF.SST', 'SIM service table', table=EF_SST_map, size={2,16}),
CyclicEF('6f39', None, 'EF.ACM', 'Accumulated call meter', rec_len={3,3}),
TransparentEF('6f3e', None, 'EF.GID1', 'Group Identifier Level 1'),
TransparentEF('6f3f', None, 'EF.GID2', 'Group Identifier Level 2'),
EF_SPN(),
@ -610,21 +800,45 @@ class DF_GSM(CardDF):
TransparentEF('6f7f', None, 'EF.BCCH', 'Broadcast control channels', size={16,16}),
EF_ACC(),
EF_PLMNsel('6f7b', None, 'EF.FPLMN', 'Forbidden PLMNs', size={12,12}),
TransparentEF('6f7e', None, 'EF.LOCI', 'Locationn information', size={11,11}),
EF_LOCI(),
EF_AD(),
TransparentEF('6fa3', None, 'EF.Phase', 'Phase identification', size={1,1}),
# TODO EF.VGCS VGCSS, VBS, VBSS, eMLPP, AAeM
EF_VGCS(),
EF_VGCSS(),
EF_VGCS('6fb3', None, 'EF.VBS', 'Voice Broadcast Service'),
EF_VGCSS('6fb4', None, 'EF.VBSS', 'Voice Broadcast Service Status'),
EF_eMLPP(),
EF_AAeM(),
EF_CBMID(),
EF_ECC(),
EF_CBMIR(),
# DCK, CNL, NIA, KcGRS, LOCIGPRS, SUME
EF_DCK(),
EF_CNL(),
EF_NIA(),
EF_Kc('6f52', None, 'EF.KcGPRS', 'GPRS Ciphering key KcGPRS'),
EF_LOCIGPRS(),
TransparentEF('6f54', None, 'EF.SUME', 'SetUpMenu Elements'),
EF_xPLMNwAcT('6f60', None, 'EF.PLMNwAcT',
'User controlled PLMN Selector with Access Technology'),
EF_xPLMNwAcT('6f61', None, 'EF.OPLMNwAcT',
'Operator controlled PLMN Selector with Access Technology'),
EF_xPLMNwAcT('6f62', None, 'EF.HPLMNwAcT', 'HPLMN Selector with Access Technology'),
# CPBCCH, InvScan, PNN, OPL, MBDN, MBI, MWIS, CFIS, EXT5, EXT6, EXT7, SPDI, MMSN, EXT8
# MMSICP, MMSUP, MMSUCP
EF_CPBCCH(),
EF_InvScan(),
LinFixedEF('6fc5', None,'EF.PNN', 'PLMN Network Name'),
EF_OPL(),
EF_ADN('6fc7', None, 'EF.MBDN', 'Mailbox Dialling Numbers'),
EF_MBI(),
EF_MWIS(),
EF_ADN('6fcb', None, 'EF.CFIS', 'Call Forwarding Indication Status'),
EF_EXT('6fc8', None, 'EF.EXT6', 'Externsion6 (MBDN)'),
EF_EXT('6fcc', None, 'EF.EXT7', 'Externsion7 (CFIS)'),
TransparentEF('6fcd', None, 'EF.SPDI', 'Service Provider Display Information'),
EF_MMSN(),
EF_EXT('6fcf', None, 'EF.EXT8', 'Extension8 (MMSN)'),
EF_MMSICP(),
EF_MMSUP(),
EF_MMSUCP(),
]
self.add_files(files)