blob: 0b0a4f16fa6802016d6d51d155e665aaaa50dbef [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 *
27from pySim.ts_51_011 import EF_AD
28import pySim.ts_102_221
29
Supreeth Herle8b72c272020-03-22 08:55:50 +010030# Mapping between ISIM Service Number and its description
31EF_IST_map = {
32 1: 'P-CSCF address',
33 2: 'Generic Bootstrapping Architecture (GBA)',
34 3: 'HTTP Digest',
35 4: 'GBA-based Local Key Establishment Mechanism',
36 5: 'Support of P-CSCF discovery for IMS Local Break Out',
37 6: 'Short Message Storage (SMS)',
38 7: 'Short Message Status Reports (SMSR)',
39 8: 'Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31]',
40 9: 'Communication Control for IMS by ISIM',
41 10: 'Support of UICC access to IMS',
42 11: 'URI support by UICC',
43 12: 'Media Type support',
44 13: 'IMS call disconnection cause',
45 14: 'URI support for MO SHORT MESSAGE CONTROL',
46 15: 'MCPTT',
47 16: 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [31]',
48 17: 'From Preferred',
49 18: 'IMS configuration data',
Supreeth Herle28484d02020-03-25 15:00:20 +010050 19: 'XCAP Configuration Data',
51 20: 'WebRTC URI',
Supreeth Herle8b72c272020-03-22 08:55:50 +010052}
herlesupreeth75c14c02020-12-23 09:41:07 +010053
54EF_ISIM_ADF_map = {
55 'IST': '6F07',
56 'IMPI': '6F02',
57 'DOMAIN': '6F03',
58 'IMPU': '6F04',
59 'AD': '6FAD',
60 'ARR': '6F06',
61 'PCSCF': '6F09',
62 'GBAP': '6FD5',
63 'GBANL': '6FD7',
64 'NAFKCA': '6FDD',
65 'UICCIARI': '6FE7',
66 'SMS': '6F3C',
67 'SMSS': '6F43',
68 'SMSR': '6F47',
69 'SMSP': '6F42',
70 'FromPreferred': '6FF7',
71 'IMSConfigData': '6FF8',
72 'XCAPConfigData': '6FFC',
73 'WebRTCURI': '6FFA'
74}
Harald Welteb2edd142021-01-08 23:29:35 +010075
76# TS 31.103 Section 4.2.2
77class EF_IMPI(TransparentEF):
78 def __init__(self, fid='6f02', sfid=0x02, name='EF.IMPI', desc='IMS private user identity'):
79 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
80
81# TS 31.103 Section 4.2.3
82class EF_DOMAIN(TransparentEF):
83 def __init__(self, fid='6f05', sfid=0x05, name='EF.DOMAIN', desc='Home Network Domain Name'):
84 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
85
86# TS 31.103 Section 4.2.4
87class EF_IMPU(LinFixedEF):
88 def __init__(self, fid='6f04', sfid=0x04, name='EF.IMPU', desc='IMS public user identity'):
89 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
90
91# TS 31.103 Section 4.2.6
92class EF_ARR(LinFixedEF):
93 def __init__(self, fid='6f06', sfid=0x06, name='EF.ARR', desc='Access Rule Reference'):
94 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
95
96# TS 31.103 Section 4.2.7
97class EF_IST(TransparentEF):
98 def __init__(self, fid='6f07', sfid=0x07, name='EF.IST', desc='ISIM Service Table'):
99 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, size={1,4})
100 # add those commands to the general commands of a TransparentEF
101 self.shell_commands += [self.AddlShellCommands()]
102
103 @with_default_category('File-Specific Commands')
104 class AddlShellCommands(CommandSet):
105 def __init__(self):
106 super().__init__()
107
108 def do_ist_service_activate(self, arg):
109 """Activate a service within EF.IST"""
110 self._cmd.card.update_ist(int(arg), 1)
111
112 def do_ist_service_deactivate(self, arg):
113 """Deactivate a service within EF.IST"""
114 self._cmd.card.update_ist(int(arg), 0)
115
116# TS 31.103 Section 4.2.8
117class EF_PCSCF(LinFixedEF):
118 def __init__(self, fid='6f09', sfid=None, name='EF.P-CSCF', desc='P-CSCF Address'):
119 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
120 def _decode_record_hex(self, raw_hex):
121 # FIXME: this doesn't do JSON output
122 return dec_addr_tlv(raw_hex)
123 def _encode_record_hex(self, json_in):
124 return enc_addr_tlv(json_in)
125
126# TS 31.103 Section 4.2.9
127class EF_GBABP(LinFixedEF):
128 def __init__(self, fid='6fd5', sfid=None, name='EF.GBABP', desc='GBA Bootstrappng'):
129 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
130
131# TS 31.103 Section 4.2.10
132class EF_GBANL(LinFixedEF):
133 def __init__(self, fid='6fd7', sfid=None, name='EF.GBANL', desc='GBA NAF List'):
134 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
135
136# TS 31.103 Section 4.2.11
137class EF_NAFKCA(LinFixedEF):
138 def __init__(self, fid='6fdd', sfid=None, name='EF.NAFKCA', desc='NAF Key Centre Address'):
139 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
140
141# TS 31.103 Section 4.2.16
142class EF_UICCIARI(LinFixedEF):
143 def __init__(self, fid='6fe7', sfid=None, name='EF.UICCIARI', desc='UICC IARI'):
144 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
145
146# TS 31.103 Section 4.2.18
147class EF_IMSConfigData(TransparentEF):
148 def __init__(self, fid='6ff8', sfid=None, name='EF.IMSConfigData', desc='IMS Configuration Data'):
149 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
150
151# TS 31.103 Section 4.2.19
152class EF_XCAPConfigData(TransparentEF):
153 def __init__(self, fid='6ffc', sfid=None, name='EF.XCAPConfigData', desc='XCAP Configuration Data'):
154 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
155
156# TS 31.103 Section 4.2.20
157class EF_WebRTCURI(TransparentEF):
158 def __init__(self, fid='6ffa', sfid=None, name='EF.WebRTCURI', desc='WebRTC URI'):
159 super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
160
161
162class ADF_ISIM(CardADF):
163 def __init__(self, aid='a0000000871004', name='ADF.ISIM', fid=None, sfid=None,
164 desc='ISIM Application'):
165 super().__init__(aid=aid, fid=fid, sfid=sfid, name=name, desc=desc)
166
167 files = [
168 EF_IMPI(),
169 EF_DOMAIN(),
170 EF_IMPU(),
171 EF_AD(),
172 EF_ARR(),
173 EF_IST(),
174 EF_PCSCF(),
175 EF_GBABP(),
176 EF_GBANL(),
177 EF_NAFKCA(),
178 # SMS
179 # SMSS
180 # SMSR
181 #EF_SMSP(),
182 EF_UICCIARI(),
183 # FromPreferred
184 EF_IMSConfigData(),
185 EF_XCAPConfigData(),
186 EF_WebRTCURI(),
187 ]
188 self.add_files(files)
189
190 def decode_select_response(self, data_hex):
191 return pySim.ts_102_221.decode_select_response(data_hex)
192
193# TS 31.103 Section 7.1
194sw_isim = {
195 'Security management': {
196 '9862': 'Authentication error, incorrect MAC',
197 '9864': 'Authentication error, security context not supported',
198 }
199}
200
201CardApplicationISIM = CardApplication('ISIM', adf=ADF_ISIM(), sw=sw_isim)