Supreeth Herle | 475dcaa | 2020-03-20 18:57:39 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | """ |
| 4 | Various constants from ETSI TS 131 102 |
| 5 | """ |
| 6 | |
| 7 | # |
| 8 | # Copyright (C) 2020 Supreeth Herle <herlesupreeth@gmail.com> |
| 9 | # |
| 10 | # This program is free software: you can redistribute it and/or modify |
| 11 | # it under the terms of the GNU General Public License as published by |
| 12 | # the Free Software Foundation, either version 2 of the License, or |
| 13 | # (at your option) any later version. |
| 14 | # |
| 15 | # This program is distributed in the hope that it will be useful, |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | # GNU General Public License for more details. |
| 19 | # |
| 20 | # You should have received a copy of the GNU General Public License |
| 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | # |
| 23 | |
| 24 | # Mapping between USIM Service Number and its description |
| 25 | EF_UST_map = { |
| 26 | 1: 'Local Phone Book', |
| 27 | 2: 'Fixed Dialling Numbers (FDN)', |
| 28 | 3: 'Extension 2', |
| 29 | 4: 'Service Dialling Numbers (SDN)', |
| 30 | 5: 'Extension3', |
| 31 | 6: 'Barred Dialling Numbers (BDN)', |
| 32 | 7: 'Extension4', |
| 33 | 8: 'Outgoing Call Information (OCI and OCT)', |
| 34 | 9: 'Incoming Call Information (ICI and ICT)', |
| 35 | 10: 'Short Message Storage (SMS)', |
| 36 | 11: 'Short Message Status Reports (SMSR)', |
| 37 | 12: 'Short Message Service Parameters (SMSP)', |
| 38 | 13: 'Advice of Charge (AoC)', |
| 39 | 14: 'Capability Configuration Parameters 2 (CCP2)', |
| 40 | 15: 'Cell Broadcast Message Identifier', |
| 41 | 16: 'Cell Broadcast Message Identifier Ranges', |
| 42 | 17: 'Group Identifier Level 1', |
| 43 | 18: 'Group Identifier Level 2', |
| 44 | 19: 'Service Provider Name', |
| 45 | 20: 'User controlled PLMN selector with Access Technology', |
| 46 | 21: 'MSISDN', |
| 47 | 22: 'Image (IMG)', |
| 48 | 23: 'Support of Localised Service Areas (SoLSA)', |
| 49 | 24: 'Enhanced Multi-Level Precedence and Pre-emption Service', |
| 50 | 25: 'Automatic Answer for eMLPP', |
| 51 | 26: 'RFU', |
| 52 | 27: 'GSM Access', |
| 53 | 28: 'Data download via SMS-PP', |
| 54 | 29: 'Data download via SMS-CB', |
| 55 | 30: 'Call Control by USIM', |
| 56 | 31: 'MO-SMS Control by USIM', |
| 57 | 32: 'RUN AT COMMAND command', |
| 58 | 33: 'shall be set to 1', |
| 59 | 34: 'Enabled Services Table', |
| 60 | 35: 'APN Control List (ACL)', |
| 61 | 36: 'Depersonalisation Control Keys', |
| 62 | 37: 'Co-operative Network List', |
| 63 | 38: 'GSM security context', |
| 64 | 39: 'CPBCCH Information', |
| 65 | 40: 'Investigation Scan', |
| 66 | 41: 'MexE', |
| 67 | 42: 'Operator controlled PLMN selector with Access Technology', |
| 68 | 43: 'HPLMN selector with Access Technology', |
| 69 | 44: 'Extension 5', |
| 70 | 45: 'PLMN Network Name', |
| 71 | 46: 'Operator PLMN List', |
| 72 | 47: 'Mailbox Dialling Numbers', |
| 73 | 48: 'Message Waiting Indication Status', |
| 74 | 49: 'Call Forwarding Indication Status', |
| 75 | 50: 'Reserved and shall be ignored', |
| 76 | 51: 'Service Provider Display Information', |
| 77 | 52: 'Multimedia Messaging Service (MMS)', |
| 78 | 53: 'Extension 8', |
| 79 | 54: 'Call control on GPRS by USIM', |
| 80 | 55: 'MMS User Connectivity Parameters', |
| 81 | 56: 'Network\'s indication of alerting in the MS (NIA)', |
| 82 | 57: 'VGCS Group Identifier List (EFVGCS and EFVGCSS)', |
| 83 | 58: 'VBS Group Identifier List (EFVBS and EFVBSS)', |
| 84 | 59: 'Pseudonym', |
| 85 | 60: 'User Controlled PLMN selector for I-WLAN access', |
| 86 | 61: 'Operator Controlled PLMN selector for I-WLAN access', |
| 87 | 62: 'User controlled WSID list', |
| 88 | 63: 'Operator controlled WSID list', |
| 89 | 64: 'VGCS security', |
| 90 | 65: 'VBS security', |
| 91 | 66: 'WLAN Reauthentication Identity', |
| 92 | 67: 'Multimedia Messages Storage', |
| 93 | 68: 'Generic Bootstrapping Architecture (GBA)', |
| 94 | 69: 'MBMS security', |
| 95 | 70: 'Data download via USSD and USSD application mode', |
| 96 | 71: 'Equivalent HPLMN', |
| 97 | 72: 'Additional TERMINAL PROFILE after UICC activation', |
| 98 | 73: 'Equivalent HPLMN Presentation Indication', |
| 99 | 74: 'Last RPLMN Selection Indication', |
| 100 | 75: 'OMA BCAST Smart Card Profile', |
| 101 | 76: 'GBA-based Local Key Establishment Mechanism', |
| 102 | 77: 'Terminal Applications', |
| 103 | 78: 'Service Provider Name Icon', |
| 104 | 79: 'PLMN Network Name Icon', |
| 105 | 80: 'Connectivity Parameters for USIM IP connections', |
| 106 | 81: 'Home I-WLAN Specific Identifier List', |
| 107 | 82: 'I-WLAN Equivalent HPLMN Presentation Indication', |
| 108 | 83: 'I-WLAN HPLMN Priority Indication', |
| 109 | 84: 'I-WLAN Last Registered PLMN', |
| 110 | 85: 'EPS Mobility Management Information', |
| 111 | 86: 'Allowed CSG Lists and corresponding indications', |
| 112 | 87: 'Call control on EPS PDN connection by USIM', |
| 113 | 88: 'HPLMN Direct Access', |
| 114 | 89: 'eCall Data', |
| 115 | 90: 'Operator CSG Lists and corresponding indications', |
| 116 | 91: 'Support for SM-over-IP', |
| 117 | 92: 'Support of CSG Display Control', |
| 118 | 93: 'Communication Control for IMS by USIM', |
| 119 | 94: 'Extended Terminal Applications', |
| 120 | 95: 'Support of UICC access to IMS', |
| 121 | 96: 'Non-Access Stratum configuration by USIM', |
| 122 | 97: 'PWS configuration by USIM', |
| 123 | 98: 'RFU', |
| 124 | 99: 'URI support by UICC', |
| 125 | 100: 'Extended EARFCN support', |
| 126 | 101: 'ProSe', |
| 127 | 102: 'USAT Application Pairing', |
| 128 | 103: 'Media Type support', |
| 129 | 104: 'IMS call disconnection cause', |
| 130 | 105: 'URI support for MO SHORT MESSAGE CONTROL', |
| 131 | 106: 'ePDG configuration Information support', |
| 132 | 107: 'ePDG configuration Information configured', |
| 133 | 108: 'ACDC support', |
| 134 | 109: 'MCPTT', |
| 135 | 110: 'ePDG configuration Information for Emergency Service support', |
| 136 | 111: 'ePDG configuration Information for Emergency Service configured', |
Supreeth Herle | 4d9e6be | 2020-03-24 12:13:45 +0100 | [diff] [blame] | 137 | 112: 'eCall Data over IMS', |
| 138 | 113: 'URI support for SMS-PP DOWNLOAD as defined in 3GPP TS 31.111 [12]', |
| 139 | 114: 'From Preferred', |
| 140 | 115: 'IMS configuration data', |
| 141 | 116: 'TV configuration', |
| 142 | 117: '3GPP PS Data Off', |
| 143 | 118: '3GPP PS Data Off Service List', |
| 144 | 119: 'V2X', |
| 145 | 120: 'XCAP Configuration Data', |
| 146 | 121: 'EARFCN list for MTC/NB-IOT UEs', |
| 147 | 122: '5GS Mobility Management Information', |
| 148 | 123: '5G Security Parameters', |
| 149 | 124: 'Subscription identifier privacy support', |
| 150 | 125: 'SUCI calculation by the USIM', |
| 151 | 126: 'UAC Access Identities support', |
| 152 | 127: 'Expect control plane-based Steering of Roaming information during initial registration in VPLMN', |
| 153 | 128: 'Call control on PDU Session by USIM', |
Sebastian Viviani | 0dc8f69 | 2020-05-29 00:14:55 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Sebastian Viviani | e61170c | 2020-06-03 08:57:00 +0100 | [diff] [blame] | 156 | LOCI_STATUS_map = { |
| 157 | 0: 'updated', |
| 158 | 1: 'not updated', |
| 159 | 2: 'plmn not allowed', |
| 160 | 3: 'locatation area not allowed' |
| 161 | } |
herlesupreeth | a562ea0 | 2020-09-16 20:17:22 +0200 | [diff] [blame] | 162 | |
Sebastian Viviani | 0dc8f69 | 2020-05-29 00:14:55 +0100 | [diff] [blame] | 163 | EF_USIM_ADF_map = { |
| 164 | 'LI': '6F05', |
| 165 | 'ARR': '6F06', |
| 166 | 'IMSI': '6F07', |
| 167 | 'Keys': '6F08', |
| 168 | 'KeysPS': '6F09', |
| 169 | 'DCK': '6F2C', |
| 170 | 'HPPLMN': '6F31', |
| 171 | 'CNL': '6F32', |
| 172 | 'ACMmax': '6F37', |
| 173 | 'UST': '6F38', |
| 174 | 'ACM': '6F39', |
| 175 | 'FDN': '6F3B', |
| 176 | 'SMS': '6F3C', |
| 177 | 'GID1': '6F3E', |
| 178 | 'GID2': '6F3F', |
| 179 | 'MSISDN': '6F40', |
| 180 | 'PUCT': '6F41', |
| 181 | 'SMSP': '6F42', |
| 182 | 'SMSS': '6F42', |
| 183 | 'CBMI': '6F45', |
| 184 | 'SPN': '6F46', |
| 185 | 'SMSR': '6F47', |
| 186 | 'CBMID': '6F48', |
| 187 | 'SDN': '6F49', |
| 188 | 'EXT2': '6F4B', |
| 189 | 'EXT3': '6F4C', |
| 190 | 'BDN': '6F4D', |
| 191 | 'EXT5': '6F4E', |
| 192 | 'CCP2': '6F4F', |
| 193 | 'CBMIR': '6F50', |
| 194 | 'EXT4': '6F55', |
| 195 | 'EST': '6F56', |
| 196 | 'ACL': '6F57', |
| 197 | 'CMI': '6F58', |
| 198 | 'START-HFN': '6F5B', |
| 199 | 'THRESHOLD': '6F5C', |
| 200 | 'PLMNwAcT': '6F60', |
| 201 | 'OPLMNwAcT': '6F61', |
| 202 | 'HPLMNwAcT': '6F62', |
| 203 | 'PSLOCI': '6F73', |
| 204 | 'ACC': '6F78', |
| 205 | 'FPLMN': '6F7B', |
| 206 | 'LOCI': '6F7E', |
| 207 | 'ICI': '6F80', |
| 208 | 'OCI': '6F81', |
| 209 | 'ICT': '6F82', |
| 210 | 'OCT': '6F83', |
| 211 | 'AD': '6FAD', |
| 212 | 'VGCS': '6FB1', |
| 213 | 'VGCSS': '6FB2', |
| 214 | 'VBS': '6FB3', |
| 215 | 'VBSS': '6FB4', |
| 216 | 'eMLPP': '6FB5', |
| 217 | 'AAeM': '6FB6', |
| 218 | 'ECC': '6FB7', |
| 219 | 'Hiddenkey': '6FC3', |
| 220 | 'NETPAR': '6FC4', |
| 221 | 'PNN': '6FC5', |
| 222 | 'OPL': '6FC6', |
| 223 | 'MBDN': '6FC7', |
| 224 | 'EXT6': '6FC8', |
| 225 | 'MBI': '6FC9', |
| 226 | 'MWIS': '6FCA', |
| 227 | 'CFIS': '6FCB', |
| 228 | 'EXT7': '6FCC', |
| 229 | 'SPDI': '6FCD', |
| 230 | 'MMSN': '6FCE', |
| 231 | 'EXT8': '6FCF', |
| 232 | 'MMSICP': '6FD0', |
| 233 | 'MMSUP': '6FD1', |
| 234 | 'MMSUCP': '6FD2', |
| 235 | 'NIA': '6FD3', |
| 236 | 'VGCSCA': '6FD4', |
| 237 | 'VBSCA': '6FD5', |
| 238 | 'GBAP': '6FD6', |
| 239 | 'MSK': '6FD7', |
| 240 | 'MUK': '6FD8', |
| 241 | 'EHPLMN': '6FD9', |
| 242 | 'GBANL': '6FDA', |
| 243 | 'EHPLMNPI': '6FDB', |
| 244 | 'LRPLMNSI': '6FDC', |
| 245 | 'NAFKCA': '6FDD', |
| 246 | 'SPNI': '6FDE', |
| 247 | 'PNNI': '6FDF', |
| 248 | 'NCP-IP': '6FE2', |
| 249 | 'EPSLOCI': '6FE3', |
| 250 | 'EPSNSC': '6FE4', |
| 251 | 'UFC': '6FE6', |
| 252 | 'UICCIARI': '6FE7', |
| 253 | 'NASCONFIG': '6FE8', |
| 254 | 'PWC': '6FEC', |
| 255 | 'FDNURI': '6FED', |
| 256 | 'BDNURI': '6FEE', |
| 257 | 'SDNURI': '6FEF', |
| 258 | 'IWL': '6FF0', |
| 259 | 'IPS': '6FF1', |
| 260 | 'IPD': '6FF2', |
| 261 | 'ePDGId': '6FF3', |
| 262 | 'ePDGSelection': '6FF4', |
| 263 | 'ePDGIdEm': '6FF5', |
| 264 | 'ePDGSelectionEm': '6FF6', |
| 265 | } |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 266 | |
| 267 | ###################################################################### |
| 268 | # ADF.USIM |
| 269 | ###################################################################### |
| 270 | |
| 271 | from pySim.filesystem import * |
| 272 | from pySim.ts_51_011 import EF_IMSI, EF_xPLMNwAcT, EF_SPN, EF_CBMI, EF_ACC, EF_PLMNsel, EF_AD |
| 273 | from pySim.ts_51_011 import EF_CBMID, EF_ECC, EF_CBMIR |
| 274 | |
| 275 | import pySim.ts_102_221 |
| 276 | |
Merlin Chlosta | 05ca36b | 2021-04-01 16:15:28 +0200 | [diff] [blame] | 277 | # TS 31.102 4.4.11.8 |
| 278 | class EF_SUCI_Calc_Info(TransparentEF): |
| 279 | def __init__(self, fid="4f07", sfid=0x07, name='EF.SUCI_Calc_Info', size={2, None}, |
| 280 | desc='SUCI Calc Info'): |
| 281 | super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size) |
| 282 | |
| 283 | def _encode_prot_scheme_id_list(self, in_list): |
| 284 | out_bytes = [0xa0] |
| 285 | out_bytes.append(len(in_list)*2) # two byte per entry |
| 286 | |
| 287 | # position in list determines priority; high-priority items (low index) come first |
| 288 | for scheme in sorted(in_list, key=lambda item: item["priority"]): |
| 289 | out_bytes.append(scheme["identifier"]) |
| 290 | out_bytes.append(scheme["key_index"]) |
| 291 | |
| 292 | return out_bytes |
| 293 | |
| 294 | def _encode_hnet_pubkey_list(self, hnet_pubkey_list): |
| 295 | out_bytes = [0xa1] # pubkey list tag |
| 296 | out_bytes.append(0x00) # length filled later |
| 297 | length = 0 |
| 298 | |
| 299 | for key in hnet_pubkey_list: |
| 300 | out_bytes.append(0x80) # identifier tag |
| 301 | out_bytes.append(0x01) # TODO size, fixed to 1 byte |
| 302 | out_bytes.append(key["hnet_pubkey_identifier"]) |
| 303 | out_bytes.append(0x81) # key tag |
| 304 | out_bytes.append(len(key["hnet_pubkey"])//2) |
| 305 | length += 5+len(key["hnet_pubkey"])//2 |
| 306 | |
| 307 | pubkey_bytes = h2b(key["hnet_pubkey"]) |
| 308 | out_bytes += pubkey_bytes |
| 309 | |
| 310 | # fill length |
| 311 | out_bytes[1] = length |
| 312 | return out_bytes |
| 313 | |
| 314 | def _encode_hex(self, in_json): |
| 315 | out_bytes = self._encode_prot_scheme_id_list(in_json['prot_scheme_id_list']) |
| 316 | out_bytes += self._encode_hnet_pubkey_list(in_json['hnet_pubkey_list']) |
| 317 | return "".join(["%02X" % i for i in out_bytes]) |
| 318 | |
| 319 | def _decode_prot_scheme_id_list(self, in_bytes): |
| 320 | prot_scheme_id_list = [] |
| 321 | pos = 0 |
| 322 | # two bytes per entry |
| 323 | while pos < len(in_bytes): |
| 324 | prot_scheme = { |
| 325 | 'priority': pos//2, # first in list: high priority |
| 326 | 'identifier': in_bytes[pos], |
| 327 | 'key_index': in_bytes[pos+1] |
| 328 | } |
| 329 | pos += 2 |
| 330 | prot_scheme_id_list.append(prot_scheme) |
| 331 | return prot_scheme_id_list |
| 332 | |
| 333 | def _decode_hnet_pubkey_list(self, in_bytes): |
| 334 | hnet_pubkey_list = [] |
| 335 | pos = 0 |
| 336 | if in_bytes[pos] != 0xa1: |
| 337 | print("missing Home Network Public Key List data object") |
| 338 | return {} |
| 339 | pos += 1 |
| 340 | hnet_pubkey_list_len = in_bytes[pos] |
| 341 | pos += 1 |
| 342 | |
| 343 | while pos < hnet_pubkey_list_len: |
| 344 | if in_bytes[pos] != 0x80: |
| 345 | print("missing Home Network Public Key Identifier tag") |
| 346 | return {} |
| 347 | pos += 1 |
| 348 | hnet_pubkey_id_len = in_bytes[pos] # TODO might be more than 1 byte? |
| 349 | pos += 1 |
| 350 | hnet_pubkey_id = in_bytes[pos:pos+hnet_pubkey_id_len][0] |
| 351 | pos += hnet_pubkey_id_len |
| 352 | if in_bytes[pos] != 0x81: |
| 353 | print("missing Home Network Public Key tag") |
| 354 | return {} |
| 355 | pos += 1 |
| 356 | hnet_pubkey_len = in_bytes[pos] |
| 357 | pos += 1 |
| 358 | hnet_pubkey = in_bytes[pos:pos+hnet_pubkey_len] |
| 359 | pos += hnet_pubkey_len |
| 360 | |
| 361 | hnet_pubkey_list.append({ |
| 362 | 'hnet_pubkey_identifier': hnet_pubkey_id, |
| 363 | 'hnet_pubkey': b2h(hnet_pubkey) |
| 364 | }) |
| 365 | |
| 366 | return hnet_pubkey_list |
| 367 | |
| 368 | def _decode_bin(self, in_bin): |
| 369 | return self._decode_hex(b2h(in_hex)) |
| 370 | |
| 371 | def _decode_hex(self, in_hex): |
| 372 | in_bytes = h2b(in_hex) |
| 373 | pos = 0 |
| 374 | |
| 375 | if in_bytes[pos] != 0xa0: |
| 376 | print("missing Protection Scheme Identifier List data object tag") |
| 377 | return {} |
| 378 | pos += 1 |
| 379 | |
| 380 | prot_scheme_id_list_len = in_bytes[pos] # TODO maybe more than 1 byte |
| 381 | pos += 1 |
| 382 | # decode Protection Scheme Identifier List data object |
| 383 | prot_scheme_id_list = self._decode_prot_scheme_id_list(in_bytes[pos:pos+prot_scheme_id_list_len]) |
| 384 | pos += prot_scheme_id_list_len |
| 385 | |
| 386 | # remaining data holds Home Network Public Key Data Object |
| 387 | hnet_pubkey_list = self._decode_hnet_pubkey_list(in_bytes[pos:]) |
| 388 | |
| 389 | return { |
| 390 | 'prot_scheme_id_list': prot_scheme_id_list, |
| 391 | 'hnet_pubkey_list': hnet_pubkey_list |
| 392 | } |
| 393 | |
| 394 | def _encode_bin(self, in_json): |
| 395 | return h2b(self._encode_hex(in_json)) |
| 396 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 397 | class EF_LI(TransRecEF): |
| 398 | def __init__(self, fid='6f05', sfid=None, name='EF.LI', size={2,None}, rec_len=2, |
| 399 | desc='Language Indication'): |
| 400 | super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len) |
| 401 | def _decode_record_bin(self, in_bin): |
| 402 | if in_bin == b'\xff\xff': |
| 403 | return None |
| 404 | else: |
| 405 | # officially this is 7-bit GSM alphabet with one padding bit in each byte |
| 406 | return in_bin.decode('ascii') |
| 407 | def _encode_record_bin(self, in_json): |
| 408 | if in_json == None: |
| 409 | return b'\xff\xff' |
| 410 | else: |
| 411 | # officially this is 7-bit GSM alphabet with one padding bit in each byte |
| 412 | return in_json.encode('ascii') |
| 413 | |
| 414 | class EF_Keys(TransparentEF): |
| 415 | def __init__(self, fid='6f08', sfid=0x08, name='EF.Keys', size={33,33}, |
| 416 | desc='Ciphering and Integrity Keys'): |
| 417 | super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size) |
| 418 | def _decode_bin(self, in_bin): |
| 419 | return {'ksi': in_bin[0], |
| 420 | 'ck': b2h(in_bin[1:17]), |
| 421 | 'ik': b2h(in_bin[17:33])} |
| 422 | def _encode_bin(self, in_json): |
| 423 | return h2b(in_json['ksi']) + h2b(in_json['ck']) + h2b(in_json['ik']) |
| 424 | |
| 425 | # TS 31.103 Section 4.2.7 |
| 426 | class EF_UST(TransparentEF): |
| 427 | def __init__(self, fid='6f38', sfid=0x04, name='EF.UST', desc='USIM Service Table'): |
| 428 | super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, size={1,17}) |
| 429 | # add those commands to the general commands of a TransparentEF |
| 430 | self.shell_commands += [self.AddlShellCommands()] |
| 431 | def _decode_bin(self, in_bin): |
| 432 | ret = [] |
| 433 | for i in range (0, len(in_bin)): |
| 434 | byte = in_bin[i] |
| 435 | for bitno in range(0,7): |
| 436 | if byte & (1 << bitno): |
| 437 | ret.append(i * 8 + bitno + 1) |
| 438 | return ret |
| 439 | def _encode_bin(self, in_json): |
| 440 | # FIXME: size this to length of file |
| 441 | ret = bytearray(20) |
| 442 | for srv in in_json: |
| 443 | print("srv=%d"%srv) |
| 444 | srv = srv-1 |
| 445 | byte_nr = srv // 8 |
| 446 | # FIXME: detect if service out of range was selected |
| 447 | bit_nr = srv % 8 |
| 448 | ret[byte_nr] |= (1 << bit_nr) |
| 449 | return ret |
| 450 | @with_default_category('File-Specific Commands') |
| 451 | class AddlShellCommands(CommandSet): |
| 452 | def __init__(self): |
| 453 | super().__init__() |
| 454 | |
| 455 | def do_ust_service_activate(self, arg): |
| 456 | """Activate a service within EF.UST""" |
| 457 | self._cmd.card.update_ust(int(arg), 1) |
| 458 | |
| 459 | def do_ust_service_deactivate(self, arg): |
| 460 | """Deactivate a service within EF.UST""" |
| 461 | self._cmd.card.update_ust(int(arg), 0) |
| 462 | |
Merlin Chlosta | 05ca36b | 2021-04-01 16:15:28 +0200 | [diff] [blame] | 463 | class DF_USIM_5GS(CardDF): |
| 464 | def __init__(self, fid='5FC0', name='DF.5GS', desc='5GS related files'): |
| 465 | super().__init__(fid=fid, name=name, desc=desc) |
| 466 | files = [ |
| 467 | # I'm looking at 31.102 R15.9 |
| 468 | TransparentEF('4F01', None, 'EF.5GS3GPPLOCI', '5GS 3GPP location information', size={20,20}), |
| 469 | TransparentEF('4F02', None, 'EF.5GSN3GPPLOCI', '5GS non-3GPP location information', size={20,20}), |
| 470 | #LinFixedEF('4F03', None, 'EF.5GS3GPPNSC', '5GS 3GPP Access NAS Security Context'), |
| 471 | #LinFixedEF('4F04', None, 'EF.5GSN3GPPNSC', '5GS non-3GPP Access NAS Security Context'), |
| 472 | TransparentEF('4F05', None, 'EF.5GAUTHKEYS', '5G authentication keys', size={68, None}), |
| 473 | TransparentEF('4F06', None, 'EF.UAC_AIC', 'UAC Access Identities Configuration', size={4, 4}), |
| 474 | EF_SUCI_Calc_Info(), #TransparentEF('4F07', None, 'EF.SUCI_Calc_Info', 'SUCI Calculation Information', size={2, None}), |
| 475 | TransparentEF('4F08', None, 'EF.OPL5G', '5GS Operator PLMN List', size={10, None}), |
| 476 | # TransparentEF('4F09', None, 'EF.NSI', 'Network Specific Identifier'), # FFS |
| 477 | TransparentEF('4F0A', None, 'EF.Routing_Indicator', 'Routing Indicator', size={4,4}), |
| 478 | ] |
| 479 | |
| 480 | self.add_files(files) |
| 481 | |
| 482 | def decode_select_response(self, data_hex): |
| 483 | return data_hex |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 484 | |
| 485 | class ADF_USIM(CardADF): |
| 486 | def __init__(self, aid='a0000000871002', name='ADF.USIM', fid=None, sfid=None, |
| 487 | desc='USIM Application'): |
| 488 | super().__init__(aid=aid, fid=fid, sfid=sfid, name=name, desc=desc) |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 489 | |
| 490 | files = [ |
| 491 | EF_LI(sfid=0x02), |
| 492 | EF_IMSI(sfid=0x07), |
| 493 | EF_Keys(), |
| 494 | EF_Keys('6f09', 0x09, 'EF.KeysPS', desc='Ciphering and Integrity Keys for PS domain'), |
| 495 | EF_xPLMNwAcT('6f60', 0x0a, 'EF.PLMNwAcT', |
| 496 | 'User controlled PLMN Selector with Access Technology'), |
| 497 | TransparentEF('6f31', 0x12, 'EF.HPPLMN', 'Higher Priority PLMN search period'), |
| 498 | # EF.ACMmax |
| 499 | EF_UST(), |
| 500 | CyclicEF('6f39', None, 'EF.ACM', 'Accumulated call meter', rec_len={3,3}), |
| 501 | TransparentEF('6f3e', None, 'EF.GID1', 'Group Identifier Level 1'), |
| 502 | TransparentEF('6f3f', None, 'EF.GID2', 'Group Identifier Level 2'), |
| 503 | EF_SPN(), |
| 504 | TransparentEF('6f41', None, 'EF.PUCT', 'Price per unit and currency table', size={5,5}), |
| 505 | EF_CBMI(), |
| 506 | EF_ACC(sfid=0x06), |
| 507 | EF_PLMNsel('6f7b', 0x0d, 'EF.FPLMN', 'Forbidden PLMNs', size={12,None}), |
| 508 | TransparentEF('6f7e', 0x0b, 'EF.LOCI', 'Locationn information', size={11,11}), |
| 509 | EF_AD(sfid=0x03), |
| 510 | EF_CBMID(sfid=0x0e), |
| 511 | EF_ECC(sfid=0x01), |
| 512 | EF_CBMIR(), |
Merlin Chlosta | 05ca36b | 2021-04-01 16:15:28 +0200 | [diff] [blame] | 513 | DF_USIM_5GS(), |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 514 | ] |
| 515 | self.add_files(files) |
| 516 | |
| 517 | def decode_select_response(self, data_hex): |
| 518 | return pySim.ts_102_221.decode_select_response(data_hex) |
| 519 | |
Harald Welte | b2edd14 | 2021-01-08 23:29:35 +0100 | [diff] [blame] | 520 | # TS 31.102 Section 7.3 |
| 521 | sw_usim = { |
| 522 | 'Security management': { |
| 523 | '9862': 'Authentication error, incorrect MAC', |
| 524 | '9864': 'Authentication error, security context not supported', |
| 525 | '9865': 'Key freshness failure', |
| 526 | '9866': 'Authentication error, no memory space available', |
| 527 | '9867': 'Authentication error, no memory space available in EF MUK', |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | CardApplicationUSIM = CardApplication('USIM', adf=ADF_USIM(), sw=sw_usim) |