Supreeth Herle | 8b72c27 | 2020-03-22 08:55:50 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | """ |
Harald Welte | 16ec96a | 2021-04-21 10:46:19 +0200 | [diff] [blame] | 4 | Various constants from 3GPP TS 31.103 V16.1.0 |
Supreeth Herle | 8b72c27 | 2020-03-22 08:55:50 +0100 | [diff] [blame] | 5 | """ |
| 6 | |
| 7 | # |
| 8 | # Copyright (C) 2020 Supreeth Herle <herlesupreeth@gmail.com> |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 9 | # Copyright (C) 2021 Harald Welte <laforge@osmocom.org> |
Supreeth Herle | 8b72c27 | 2020-03-22 08:55:50 +0100 | [diff] [blame] | 10 | # |
| 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 Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 25 | from pySim.filesystem import * |
| 26 | from pySim.utils import * |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 27 | from pySim.tlv import * |
Harald Welte | 35dfe82 | 2021-04-21 10:50:12 +0200 | [diff] [blame] | 28 | from pySim.ts_51_011 import EF_AD, EF_SMS, EF_SMSS, EF_SMSR, EF_SMSP |
Harald Welte | 6f8a870 | 2022-07-17 21:50:31 +0200 | [diff] [blame] | 29 | from pySim.ts_31_102 import ADF_USIM, EF_FromPreferred |
| 30 | from pySim.ts_31_102_telecom import EF_UServiceTable |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 31 | import pySim.ts_102_221 |
Harald Welte | fc4833e | 2021-05-02 21:46:06 +0200 | [diff] [blame] | 32 | from pySim.ts_102_221 import EF_ARR |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 33 | from pySim.construct import * |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 34 | |
Supreeth Herle | 8b72c27 | 2020-03-22 08:55:50 +0100 | [diff] [blame] | 35 | # Mapping between ISIM Service Number and its description |
| 36 | EF_IST_map = { |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 37 | 1: 'P-CSCF address', |
| 38 | 2: 'Generic Bootstrapping Architecture (GBA)', |
| 39 | 3: 'HTTP Digest', |
| 40 | 4: 'GBA-based Local Key Establishment Mechanism', |
| 41 | 5: 'Support of P-CSCF discovery for IMS Local Break Out', |
| 42 | 6: 'Short Message Storage (SMS)', |
| 43 | 7: 'Short Message Status Reports (SMSR)', |
| 44 | 8: 'Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31]', |
| 45 | 9: 'Communication Control for IMS by ISIM', |
| 46 | 10: 'Support of UICC access to IMS', |
| 47 | 11: 'URI support by UICC', |
| 48 | 12: 'Media Type support', |
| 49 | 13: 'IMS call disconnection cause', |
| 50 | 14: 'URI support for MO SHORT MESSAGE CONTROL', |
| 51 | 15: 'MCPTT', |
| 52 | 16: 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [31]', |
| 53 | 17: 'From Preferred', |
| 54 | 18: 'IMS configuration data', |
| 55 | 19: 'XCAP Configuration Data', |
| 56 | 20: 'WebRTC URI', |
| 57 | 21: 'MuD and MiD configuration data', |
Supreeth Herle | 8b72c27 | 2020-03-22 08:55:50 +0100 | [diff] [blame] | 58 | } |
herlesupreeth | 75c14c0 | 2020-12-23 09:41:07 +0100 | [diff] [blame] | 59 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 60 | # TS 31.103 Section 4.2.2 |
| 61 | class EF_IMPI(TransparentEF): |
Harald Welte | fa9f348 | 2023-06-26 10:51:38 +0200 | [diff] [blame] | 62 | _test_de_encode = [ |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 63 | ( '803137333830303630303030303031303140696d732e6d6e633030302e6d63633733382e336770706e6574776f726b2e6f7267', |
| 64 | { "nai": "738006000000101@ims.mnc000.mcc738.3gppnetwork.org" } ), |
| 65 | ] |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 66 | |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 67 | class nai(BER_TLV_IE, tag=0x80): |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 68 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 69 | |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 70 | def __init__(self, fid='6f02', sfid=0x02, name='EF.IMPI', desc='IMS private user identity', **kwargs): |
| 71 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 72 | self._tlv = EF_IMPI.nai |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 73 | |
| 74 | # TS 31.103 Section 4.2.3 |
| 75 | class EF_DOMAIN(TransparentEF): |
Harald Welte | fa9f348 | 2023-06-26 10:51:38 +0200 | [diff] [blame] | 76 | _test_de_encode = [ |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 77 | ( '8021696d732e6d6e633030302e6d63633733382e336770706e6574776f726b2e6f7267', |
| 78 | { "domain": "ims.mnc000.mcc738.3gppnetwork.org" } ), |
| 79 | ] |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 80 | class domain(BER_TLV_IE, tag=0x80): |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 81 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 82 | |
æstrid smith | b7f35ac | 2022-03-26 19:59:54 -0700 | [diff] [blame] | 83 | def __init__(self, fid='6f03', sfid=0x05, name='EF.DOMAIN', desc='Home Network Domain Name', **kwargs): |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 84 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 85 | self._tlv = EF_DOMAIN.domain |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 86 | |
| 87 | # TS 31.103 Section 4.2.4 |
| 88 | class EF_IMPU(LinFixedEF): |
Harald Welte | fa9f348 | 2023-06-26 10:51:38 +0200 | [diff] [blame] | 89 | _test_de_encode = [ |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 90 | ( '80357369703a37333830303630303030303031303140696d732e6d6e633030302e6d63633733382e336770706e6574776f726b2e6f7267', |
| 91 | { "impu": "sip:738006000000101@ims.mnc000.mcc738.3gppnetwork.org" } ), |
| 92 | ] |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 93 | class impu(BER_TLV_IE, tag=0x80): |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 94 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 95 | |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 96 | def __init__(self, fid='6f04', sfid=0x04, name='EF.IMPU', desc='IMS public user identity', **kwargs): |
| 97 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 98 | self._tlv = EF_IMPU.impu |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 99 | |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 100 | # TS 31.103 Section 4.2.7 |
| 101 | class EF_IST(EF_UServiceTable): |
| 102 | def __init__(self, **kwargs): |
Harald Welte | 13edf30 | 2022-07-21 15:19:23 +0200 | [diff] [blame] | 103 | super().__init__('6f07', 0x07, 'EF.IST', 'ISIM Service Table', (1, None), EF_IST_map) |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 104 | # add those commands to the general commands of a TransparentEF |
| 105 | self.shell_commands += [self.AddlShellCommands()] |
| 106 | |
| 107 | @with_default_category('File-Specific Commands') |
| 108 | class AddlShellCommands(CommandSet): |
| 109 | def __init__(self): |
| 110 | super().__init__() |
| 111 | |
| 112 | def do_ist_service_activate(self, arg): |
| 113 | """Activate a service within EF.IST""" |
Alexander Couzens | c8facea | 2023-07-29 05:01:57 +0200 | [diff] [blame] | 114 | selected_file = self._cmd.lchan.selected_file |
| 115 | selected_file.ust_update(self._cmd, [int(arg)], []) |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 116 | |
| 117 | def do_ist_service_deactivate(self, arg): |
| 118 | """Deactivate a service within EF.IST""" |
Alexander Couzens | c8facea | 2023-07-29 05:01:57 +0200 | [diff] [blame] | 119 | selected_file = self._cmd.lchan.selected_file |
| 120 | selected_file.ust_update(self._cmd, [], [int(arg)]) |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 121 | |
| 122 | def do_ist_service_check(self, arg): |
Harald Welte | 3bb516b | 2022-02-12 21:53:18 +0100 | [diff] [blame] | 123 | """Check consistency between services of this file and files present/activated. |
| 124 | |
| 125 | Many services determine if one or multiple files shall be present/activated or if they shall be |
| 126 | absent/deactivated. This performs a consistency check to ensure that no services are activated |
| 127 | for files that are not - and vice-versa, no files are activated for services that are not. Error |
| 128 | messages are printed for every inconsistency found.""" |
Harald Welte | a6c0f88 | 2022-07-17 14:23:17 +0200 | [diff] [blame] | 129 | selected_file = self._cmd.lchan.selected_file |
Harald Welte | 3bb516b | 2022-02-12 21:53:18 +0100 | [diff] [blame] | 130 | num_problems = selected_file.ust_service_check(self._cmd) |
| 131 | self._cmd.poutput("===> %u service / file inconsistencies detected" % num_problems) |
| 132 | |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 133 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 134 | # TS 31.103 Section 4.2.8 |
| 135 | class EF_PCSCF(LinFixedEF): |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 136 | _test_de_encode = [ |
| 137 | ( '802c0070637363662e696d732e6d6e633030302e6d63633733382e7075622e336770706e6574776f726b2e6f7267', |
Harald Welte | 301d6ed | 2023-12-08 15:06:29 +0100 | [diff] [blame] | 138 | {'pcscf_address': { "address": "pcscf.ims.mnc000.mcc738.pub.3gppnetwork.org", "type_of_address": "FQDN" } } ), |
Harald Welte | 324175f | 2023-12-21 20:25:30 +0100 | [diff] [blame] | 139 | ( '800501c0a80c22', |
| 140 | {'pcscf_address': { "address": "192.168.12.34", "type_of_address": "IPv4" } } ), |
| 141 | ( '801102fe800000000000000042d7fffe530335', |
| 142 | {'pcscf_address': { "address": "fe80::42:d7ff:fe53:335", "type_of_address": "IPv6" } } ), |
Harald Welte | 865eea6 | 2023-01-27 19:26:12 +0100 | [diff] [blame] | 143 | ] |
Harald Welte | 301d6ed | 2023-12-08 15:06:29 +0100 | [diff] [blame] | 144 | class PcscfAddress(BER_TLV_IE, tag=0x80): |
| 145 | _construct = Struct('type_of_address'/Enum(Byte, FQDN=0, IPv4=1, IPv6=2), |
| 146 | 'address'/Switch(this.type_of_address, |
| 147 | {'FQDN': Utf8Adapter(GreedyBytes), |
| 148 | 'IPv4': Ipv4Adapter(GreedyBytes), |
| 149 | 'IPv6': Ipv6Adapter(GreedyBytes)})) |
| 150 | |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 151 | def __init__(self, fid='6f09', sfid=None, name='EF.P-CSCF', desc='P-CSCF Address', **kwargs): |
| 152 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 301d6ed | 2023-12-08 15:06:29 +0100 | [diff] [blame] | 153 | self._tlv = EF_PCSCF.PcscfAddress |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 154 | |
| 155 | # TS 31.103 Section 4.2.9 |
Harald Welte | 89e5954 | 2021-04-02 21:33:13 +0200 | [diff] [blame] | 156 | class EF_GBABP(TransparentEF): |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 157 | def __init__(self, fid='6fd5', sfid=None, name='EF.GBABP', desc='GBA Bootstrapping', **kwargs): |
| 158 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 4fe7de8 | 2023-12-21 20:58:56 +0100 | [diff] [blame] | 159 | self._construct = Struct('rand'/LV, |
| 160 | 'b_tid'/LV, |
| 161 | 'key_lifetime'/LV) |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 162 | |
| 163 | # TS 31.103 Section 4.2.10 |
| 164 | class EF_GBANL(LinFixedEF): |
Harald Welte | 4fe7de8 | 2023-12-21 20:58:56 +0100 | [diff] [blame] | 165 | class NAF_ID(BER_TLV_IE, tag=0x80): |
| 166 | _construct = Struct('fqdn'/Utf8Adapter(Bytes(this._.total_len-5)), |
| 167 | 'ua_spi'/HexAdapter(Bytes(5))) |
| 168 | class B_TID(BER_TLV_IE, tag=0x81): |
| 169 | _construct = Utf8Adapter(GreedyBytes) |
| 170 | # pylint: disable=undefined-variable |
| 171 | class GbaNlCollection(TLV_IE_Collection, nested=[NAF_ID, B_TID]): |
| 172 | pass |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 173 | def __init__(self, fid='6fd7', sfid=None, name='EF.GBANL', desc='GBA NAF List', **kwargs): |
| 174 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 4fe7de8 | 2023-12-21 20:58:56 +0100 | [diff] [blame] | 175 | self._tlv = EF_GBANL.GbaNlCollection |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 176 | |
| 177 | # TS 31.103 Section 4.2.11 |
| 178 | class EF_NAFKCA(LinFixedEF): |
Harald Welte | 62e570b | 2023-12-21 20:59:36 +0100 | [diff] [blame] | 179 | _test_de_encode = [ |
| 180 | ( '80296273662e696d732e6d6e633030302e6d63633733382e7075622e336770706e6574776f726b2e6f7267', |
| 181 | { 'naf_key_centre_address': 'bsf.ims.mnc000.mcc738.pub.3gppnetwork.org' } ), |
| 182 | ( '8030656e65746e61667830312e696d732e6d6e633030302e6d63633733382e7075622e336770706e6574776f726b2e6f7267', |
| 183 | { 'naf_key_centre_address': 'enetnafx01.ims.mnc000.mcc738.pub.3gppnetwork.org' }), |
| 184 | ] |
| 185 | class NafKeyCentreAddress(BER_TLV_IE, tag=0x80): |
| 186 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 187 | def __init__(self, fid='6fdd', sfid=None, name='EF.NAFKCA', desc='NAF Key Centre Address', **kwargs): |
| 188 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 62e570b | 2023-12-21 20:59:36 +0100 | [diff] [blame] | 189 | self._tlv = EF_NAFKCA.NafKeyCentreAddress |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 190 | |
| 191 | # TS 31.103 Section 4.2.16 |
| 192 | class EF_UICCIARI(LinFixedEF): |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 193 | class iari(BER_TLV_IE, tag=0x80): |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 194 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 195 | |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 196 | def __init__(self, fid='6fe7', sfid=None, name='EF.UICCIARI', desc='UICC IARI', **kwargs): |
| 197 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 198 | self._tlv = EF_UICCIARI.iari |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 199 | |
| 200 | # TS 31.103 Section 4.2.18 |
Harald Welte | 2788162 | 2021-04-21 11:16:31 +0200 | [diff] [blame] | 201 | class EF_IMSConfigData(BerTlvEF): |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 202 | class ImsConfigDataEncoding(BER_TLV_IE, tag=0x80): |
| 203 | _construct = HexAdapter(Bytes(1)) |
| 204 | class ImsConfigData(BER_TLV_IE, tag=0x81): |
| 205 | _construct = GreedyString |
| 206 | # pylint: disable=undefined-variable |
Harald Welte | afe093c | 2022-07-17 21:39:51 +0200 | [diff] [blame] | 207 | class ImsConfigDataCollection(TLV_IE_Collection, nested=[ImsConfigDataEncoding, ImsConfigData]): |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 208 | pass |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 209 | def __init__(self, fid='6ff8', sfid=None, name='EF.IMSConfigData', desc='IMS Configuration Data', **kwargs): |
| 210 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 211 | self._tlv = EF_IMSConfigData.ImsConfigDataCollection |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 212 | |
| 213 | # TS 31.103 Section 4.2.19 |
Harald Welte | 2788162 | 2021-04-21 11:16:31 +0200 | [diff] [blame] | 214 | class EF_XCAPConfigData(BerTlvEF): |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 215 | class Access(BER_TLV_IE, tag=0x81): |
| 216 | pass |
| 217 | class ApplicationName(BER_TLV_IE, tag=0x82): |
| 218 | pass |
| 219 | class ProviderID(BER_TLV_IE, tag=0x83): |
| 220 | pass |
| 221 | class URI(BER_TLV_IE, tag=0x84): |
| 222 | pass |
| 223 | class XcapAuthenticationUserName(BER_TLV_IE, tag=0x85): |
| 224 | pass |
| 225 | class XcapAuthenticationPassword(BER_TLV_IE, tag=0x86): |
| 226 | pass |
| 227 | class XcapAuthenticationType(BER_TLV_IE, tag=0x87): |
| 228 | pass |
| 229 | class AddressType(BER_TLV_IE, tag=0x88): |
| 230 | pass |
| 231 | class Address(BER_TLV_IE, tag=0x89): |
| 232 | pass |
| 233 | class PDPAuthenticationType(BER_TLV_IE, tag=0x8a): |
| 234 | pass |
| 235 | class PDPAuthenticationName(BER_TLV_IE, tag=0x8b): |
| 236 | pass |
| 237 | class PDPAuthenticationSecret(BER_TLV_IE, tag=0x8c): |
| 238 | pass |
| 239 | |
| 240 | class AccessForXCAP(BER_TLV_IE, tag=0x81): |
| 241 | pass |
| 242 | class NumberOfXcapConnParPolicy(BER_TLV_IE, tag=0x82): |
| 243 | _construct = Int8ub |
| 244 | # pylint: disable=undefined-variable |
| 245 | class XcapConnParamsPolicyPart(BER_TLV_IE, tag=0xa1, nested=[Access, ApplicationName, ProviderID, URI, |
| 246 | XcapAuthenticationUserName, XcapAuthenticationPassword, |
| 247 | XcapAuthenticationType, AddressType, Address, PDPAuthenticationType, |
| 248 | PDPAuthenticationName, PDPAuthenticationSecret]): |
| 249 | pass |
| 250 | class XcapConnParamsPolicy(BER_TLV_IE, tag=0xa0, nested=[AccessForXCAP, NumberOfXcapConnParPolicy, XcapConnParamsPolicyPart]): |
| 251 | pass |
| 252 | class XcapConnParamsPolicyDO(BER_TLV_IE, tag=0x80, nested=[XcapConnParamsPolicy]): |
| 253 | pass |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 254 | def __init__(self, fid='6ffc', sfid=None, name='EF.XCAPConfigData', desc='XCAP Configuration Data', **kwargs): |
| 255 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 256 | self._tlv = EF_XCAPConfigData.XcapConnParamsPolicy |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 257 | |
| 258 | # TS 31.103 Section 4.2.20 |
| 259 | class EF_WebRTCURI(TransparentEF): |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 260 | class uri(BER_TLV_IE, tag=0x80): |
Philipp Maier | 791f80a | 2023-07-26 17:01:37 +0200 | [diff] [blame] | 261 | _construct = Utf8Adapter(GreedyBytes) |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 262 | |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 263 | def __init__(self, fid='6ffa', sfid=None, name='EF.WebRTCURI', desc='WebRTC URI', **kwargs): |
| 264 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 14105dc | 2021-05-31 08:48:51 +0200 | [diff] [blame] | 265 | self._tlv = EF_WebRTCURI.uri |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 266 | |
Harald Welte | 16ec96a | 2021-04-21 10:46:19 +0200 | [diff] [blame] | 267 | # TS 31.103 Section 4.2.21 |
Harald Welte | 2788162 | 2021-04-21 11:16:31 +0200 | [diff] [blame] | 268 | class EF_MuDMiDConfigData(BerTlvEF): |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 269 | class MudMidConfigDataEncoding(BER_TLV_IE, tag=0x80): |
| 270 | _construct = HexAdapter(Bytes(1)) |
| 271 | class MudMidConfigData(BER_TLV_IE, tag=0x81): |
| 272 | _construct = GreedyString |
| 273 | # pylint: disable=undefined-variable |
Harald Welte | afe093c | 2022-07-17 21:39:51 +0200 | [diff] [blame] | 274 | class MudMidConfigDataCollection(TLV_IE_Collection, nested=[MudMidConfigDataEncoding, MudMidConfigData]): |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 275 | pass |
Harald Welte | 16ec96a | 2021-04-21 10:46:19 +0200 | [diff] [blame] | 276 | def __init__(self, fid='6ffe', sfid=None, name='EF.MuDMiDConfigData', |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 277 | desc='MuD and MiD Configuration Data', **kwargs): |
| 278 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, **kwargs) |
Harald Welte | 226b866 | 2022-02-13 11:53:08 +0100 | [diff] [blame] | 279 | self._tlv = EF_MuDMiDConfigData.MudMidConfigDataCollection |
Harald Welte | 16ec96a | 2021-04-21 10:46:19 +0200 | [diff] [blame] | 280 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 281 | |
| 282 | class ADF_ISIM(CardADF): |
Philipp Maier | a1850ae | 2023-10-25 18:05:09 +0200 | [diff] [blame] | 283 | def __init__(self, aid='a0000000871004', has_fs=True, name='ADF.ISIM', fid=None, sfid=None, |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 284 | desc='ISIM Application'): |
Philipp Maier | a1850ae | 2023-10-25 18:05:09 +0200 | [diff] [blame] | 285 | super().__init__(aid=aid, has_fs=has_fs, fid=fid, sfid=sfid, name=name, desc=desc) |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 286 | |
| 287 | files = [ |
| 288 | EF_IMPI(), |
| 289 | EF_DOMAIN(), |
| 290 | EF_IMPU(), |
| 291 | EF_AD(), |
Harald Welte | fc4833e | 2021-05-02 21:46:06 +0200 | [diff] [blame] | 292 | EF_ARR('6f06', 0x06), |
Harald Welte | 6ca2fa7 | 2022-02-12 16:29:31 +0100 | [diff] [blame] | 293 | EF_IST(), |
Harald Welte | 6169c72 | 2022-02-12 09:05:15 +0100 | [diff] [blame] | 294 | EF_PCSCF(service=5), |
| 295 | EF_GBABP(service=2), |
| 296 | EF_GBANL(service=2), |
| 297 | EF_NAFKCA(service=2), |
| 298 | EF_SMS(service=(6,8)), |
| 299 | EF_SMSS(service=(6,8)), |
| 300 | EF_SMSR(service=(7,8)), |
| 301 | EF_SMSP(service=8), |
| 302 | EF_UICCIARI(service=10), |
| 303 | EF_FromPreferred(service=17), |
| 304 | EF_IMSConfigData(service=18), |
| 305 | EF_XCAPConfigData(service=19), |
| 306 | EF_WebRTCURI(service=20), |
| 307 | EF_MuDMiDConfigData(service=21), |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 308 | ] |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 309 | self.add_files(files) |
Harald Welte | 15fae98 | 2021-04-10 10:22:27 +0200 | [diff] [blame] | 310 | # add those commands to the general commands of a TransparentEF |
| 311 | self.shell_commands += [ADF_USIM.AddlShellCommands()] |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 312 | |
| 313 | def decode_select_response(self, data_hex): |
Philipp Maier | 5998a3a | 2021-11-16 15:16:39 +0100 | [diff] [blame] | 314 | return pySim.ts_102_221.CardProfileUICC.decode_select_response(data_hex) |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 315 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 316 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 317 | # TS 31.103 Section 7.1 |
| 318 | sw_isim = { |
| 319 | 'Security management': { |
| 320 | '9862': 'Authentication error, incorrect MAC', |
| 321 | '9864': 'Authentication error, security context not supported', |
| 322 | } |
| 323 | } |
| 324 | |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 325 | |
Philipp Maier | 57f65ee | 2021-10-18 14:09:02 +0200 | [diff] [blame] | 326 | class CardApplicationISIM(CardApplication): |
| 327 | def __init__(self): |
Harald Welte | c91085e | 2022-02-10 18:05:45 +0100 | [diff] [blame] | 328 | super().__init__('ISIM', adf=ADF_ISIM(), sw=sw_isim) |