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