blob: 7bb7ed2a5de31044eb346bbd9205482c33778ecb [file] [log] [blame]
Supreeth Herle8b72c272020-03-22 08:55:50 +01001# -*- coding: utf-8 -*-
2
3"""
4Various constants from ETSI TS 131 103 V14.2.0
5"""
6
7#
8# Copyright (C) 2020 Supreeth Herle <herlesupreeth@gmail.com>
Harald Welteb2edd142021-01-08 23:29:35 +01009# Copyright (C) 2021 Harald Welte <laforge@osmocom.org>
Supreeth Herle8b72c272020-03-22 08:55:50 +010010#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation, either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24
Harald Welteb2edd142021-01-08 23:29:35 +010025from pySim.filesystem import *
26from pySim.utils import *
Harald Welte35dfe822021-04-21 10:50:12 +020027from pySim.ts_51_011 import EF_AD, EF_SMS, EF_SMSS, EF_SMSR, EF_SMSP
Harald Welte15fae982021-04-10 10:22:27 +020028from pySim.ts_31_102 import ADF_USIM
Harald Welteb2edd142021-01-08 23:29:35 +010029import pySim.ts_102_221
30
Supreeth Herle8b72c272020-03-22 08:55:50 +010031# Mapping between ISIM Service Number and its description
32EF_IST_map = {
33 1: 'P-CSCF address',
34 2: 'Generic Bootstrapping Architecture (GBA)',
35 3: 'HTTP Digest',
36 4: 'GBA-based Local Key Establishment Mechanism',
37 5: 'Support of P-CSCF discovery for IMS Local Break Out',
38 6: 'Short Message Storage (SMS)',
39 7: 'Short Message Status Reports (SMSR)',
40 8: 'Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31]',
41 9: 'Communication Control for IMS by ISIM',
42 10: 'Support of UICC access to IMS',
43 11: 'URI support by UICC',
44 12: 'Media Type support',
45 13: 'IMS call disconnection cause',
46 14: 'URI support for MO SHORT MESSAGE CONTROL',
47 15: 'MCPTT',
48 16: 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [31]',
49 17: 'From Preferred',
50 18: 'IMS configuration data',
Supreeth Herle28484d02020-03-25 15:00:20 +010051 19: 'XCAP Configuration Data',
52 20: 'WebRTC URI',
Supreeth Herle8b72c272020-03-22 08:55:50 +010053}
herlesupreeth75c14c02020-12-23 09:41:07 +010054
55EF_ISIM_ADF_map = {
56 'IST': '6F07',
57 'IMPI': '6F02',
58 'DOMAIN': '6F03',
59 'IMPU': '6F04',
60 'AD': '6FAD',
61 'ARR': '6F06',
62 'PCSCF': '6F09',
63 'GBAP': '6FD5',
64 'GBANL': '6FD7',
65 'NAFKCA': '6FDD',
66 'UICCIARI': '6FE7',
67 'SMS': '6F3C',
68 'SMSS': '6F43',
69 'SMSR': '6F47',
70 'SMSP': '6F42',
71 'FromPreferred': '6FF7',
72 'IMSConfigData': '6FF8',
73 'XCAPConfigData': '6FFC',
74 'WebRTCURI': '6FFA'
75}
Harald Welteb2edd142021-01-08 23:29:35 +010076
77# TS 31.103 Section 4.2.2
78class EF_IMPI(TransparentEF):
79 def __init__(self, fid='6f02', sfid=0x02, name='EF.IMPI', desc='IMS private user identity'):
80 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
81
82# TS 31.103 Section 4.2.3
83class EF_DOMAIN(TransparentEF):
84 def __init__(self, fid='6f05', sfid=0x05, name='EF.DOMAIN', desc='Home Network Domain Name'):
85 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
86
87# TS 31.103 Section 4.2.4
88class EF_IMPU(LinFixedEF):
89 def __init__(self, fid='6f04', sfid=0x04, name='EF.IMPU', desc='IMS public user identity'):
90 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
91
92# TS 31.103 Section 4.2.6
93class EF_ARR(LinFixedEF):
94 def __init__(self, fid='6f06', sfid=0x06, name='EF.ARR', desc='Access Rule Reference'):
95 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
96
97# TS 31.103 Section 4.2.7
98class EF_IST(TransparentEF):
99 def __init__(self, fid='6f07', sfid=0x07, name='EF.IST', desc='ISIM Service Table'):
100 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, size={1,4})
101 # add those commands to the general commands of a TransparentEF
102 self.shell_commands += [self.AddlShellCommands()]
103
104 @with_default_category('File-Specific Commands')
105 class AddlShellCommands(CommandSet):
106 def __init__(self):
107 super().__init__()
108
109 def do_ist_service_activate(self, arg):
110 """Activate a service within EF.IST"""
111 self._cmd.card.update_ist(int(arg), 1)
112
113 def do_ist_service_deactivate(self, arg):
114 """Deactivate a service within EF.IST"""
115 self._cmd.card.update_ist(int(arg), 0)
116
117# TS 31.103 Section 4.2.8
118class EF_PCSCF(LinFixedEF):
119 def __init__(self, fid='6f09', sfid=None, name='EF.P-CSCF', desc='P-CSCF Address'):
120 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
121 def _decode_record_hex(self, raw_hex):
122 # FIXME: this doesn't do JSON output
123 return dec_addr_tlv(raw_hex)
124 def _encode_record_hex(self, json_in):
125 return enc_addr_tlv(json_in)
126
127# TS 31.103 Section 4.2.9
Harald Welte89e59542021-04-02 21:33:13 +0200128class EF_GBABP(TransparentEF):
Harald Weltec9cdce32021-04-11 10:28:28 +0200129 def __init__(self, fid='6fd5', sfid=None, name='EF.GBABP', desc='GBA Bootstrapping'):
Harald Welteb2edd142021-01-08 23:29:35 +0100130 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
131
132# TS 31.103 Section 4.2.10
133class EF_GBANL(LinFixedEF):
134 def __init__(self, fid='6fd7', sfid=None, name='EF.GBANL', desc='GBA NAF List'):
135 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
136
137# TS 31.103 Section 4.2.11
138class EF_NAFKCA(LinFixedEF):
139 def __init__(self, fid='6fdd', sfid=None, name='EF.NAFKCA', desc='NAF Key Centre Address'):
140 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
141
142# TS 31.103 Section 4.2.16
143class EF_UICCIARI(LinFixedEF):
144 def __init__(self, fid='6fe7', sfid=None, name='EF.UICCIARI', desc='UICC IARI'):
145 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
146
147# TS 31.103 Section 4.2.18
148class EF_IMSConfigData(TransparentEF):
149 def __init__(self, fid='6ff8', sfid=None, name='EF.IMSConfigData', desc='IMS Configuration Data'):
150 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
151
152# TS 31.103 Section 4.2.19
153class EF_XCAPConfigData(TransparentEF):
154 def __init__(self, fid='6ffc', sfid=None, name='EF.XCAPConfigData', desc='XCAP Configuration Data'):
155 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
156
157# TS 31.103 Section 4.2.20
158class EF_WebRTCURI(TransparentEF):
159 def __init__(self, fid='6ffa', sfid=None, name='EF.WebRTCURI', desc='WebRTC URI'):
160 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
161
162
163class ADF_ISIM(CardADF):
164 def __init__(self, aid='a0000000871004', name='ADF.ISIM', fid=None, sfid=None,
165 desc='ISIM Application'):
166 super().__init__(aid=aid, fid=fid, sfid=sfid, name=name, desc=desc)
167
168 files = [
169 EF_IMPI(),
170 EF_DOMAIN(),
171 EF_IMPU(),
172 EF_AD(),
173 EF_ARR(),
174 EF_IST(),
175 EF_PCSCF(),
176 EF_GBABP(),
177 EF_GBANL(),
178 EF_NAFKCA(),
Harald Welte35dfe822021-04-21 10:50:12 +0200179 EF_SMS(),
180 EF_SMSS(),
181 EF_SMSR(),
182 EF_SMSP(),
Harald Welteb2edd142021-01-08 23:29:35 +0100183 EF_UICCIARI(),
184 # FromPreferred
185 EF_IMSConfigData(),
186 EF_XCAPConfigData(),
187 EF_WebRTCURI(),
188 ]
189 self.add_files(files)
Harald Welte15fae982021-04-10 10:22:27 +0200190 # add those commands to the general commands of a TransparentEF
191 self.shell_commands += [ADF_USIM.AddlShellCommands()]
Harald Welteb2edd142021-01-08 23:29:35 +0100192
193 def decode_select_response(self, data_hex):
194 return pySim.ts_102_221.decode_select_response(data_hex)
195
196# TS 31.103 Section 7.1
197sw_isim = {
198 'Security management': {
199 '9862': 'Authentication error, incorrect MAC',
200 '9864': 'Authentication error, security context not supported',
201 }
202}
203
204CardApplicationISIM = CardApplication('ISIM', adf=ADF_ISIM(), sw=sw_isim)