├── .checkpatch.conf ├── .github └── FUNDING.yml ├── .gitignore ├── .gitreview ├── COPYING ├── README.md ├── contrib ├── csv-encrypt-columns.py ├── eidtool.py ├── es2p_client.py ├── es9p_client.py ├── esim-qrcode-gen.py ├── fsdump-diff-apply.py ├── jenkins.sh ├── saip-tool.py ├── saip-tool_example_add-app.sh ├── saip-tool_example_extract-apps.sh ├── saip-tool_example_remove-app-inst.sh ├── saip-tool_example_remove-app.sh ├── sim-rest-client.py ├── sim-rest-server.py ├── sim-rest-server.service ├── suci-keytool.py └── unber.py ├── csv-format ├── docs ├── Makefile ├── cap-tutorial.rst ├── card-key-provider.rst ├── conf.py ├── index.rst ├── legacy.rst ├── library-esim.rst ├── library.rst ├── make.bat ├── osmo-smdpp.rst ├── remote-access.rst ├── saip-tool.rst ├── shell.rst ├── sim-rest.rst ├── smpp2sim.rst ├── suci-keytool.rst ├── suci-tutorial.rst └── trace.rst ├── osmo-smdpp.py ├── pySim-prog.py ├── pySim-read.py ├── pySim-shell.py ├── pySim-smpp2sim.py ├── pySim-trace.py ├── pySim ├── __init__.py ├── apdu │ ├── __init__.py │ ├── global_platform.py │ ├── ts_102_221.py │ ├── ts_102_222.py │ └── ts_31_102.py ├── apdu_source │ ├── __init__.py │ ├── gsmtap.py │ ├── pyshark_gsmtap.py │ ├── pyshark_rspro.py │ └── tca_loader_log.py ├── app.py ├── ara_m.py ├── card_handler.py ├── card_key_provider.py ├── cards.py ├── cat.py ├── cdma_ruim.py ├── commands.py ├── esim │ ├── __init__.py │ ├── asn1 │ │ ├── rsp │ │ │ ├── PKIX1Explicit88.asn │ │ │ ├── PKIX1Implicit88.asn │ │ │ └── rsp.asn │ │ └── saip │ │ │ └── PE_Definitions-3.3.1.asn │ ├── bsp.py │ ├── es2p.py │ ├── es8p.py │ ├── es9p.py │ ├── http_json_api.py │ ├── rsp.py │ ├── saip │ │ ├── __init__.py │ │ ├── oid.py │ │ ├── personalization.py │ │ ├── templates.py │ │ └── validation.py │ └── x509_cert.py ├── euicc.py ├── exceptions.py ├── filesystem.py ├── global_platform │ ├── __init__.py │ ├── http.py │ ├── install_param.py │ ├── scp.py │ └── uicc.py ├── gsm_r.py ├── iso7816_4.py ├── javacard.py ├── jsonpath.py ├── legacy │ ├── __init__.py │ ├── cards.py │ ├── ts_31_102.py │ ├── ts_31_103.py │ ├── ts_51_011.py │ └── utils.py ├── ota.py ├── pprint.py ├── profile.py ├── runtime.py ├── secure_channel.py ├── sms.py ├── sysmocom_sja2.py ├── transport │ ├── __init__.py │ ├── calypso.py │ ├── modem_atcmd.py │ ├── pcsc.py │ └── serial.py ├── ts_102_221.py ├── ts_102_222.py ├── ts_102_310.py ├── ts_31_102.py ├── ts_31_102_telecom.py ├── ts_31_103.py ├── ts_31_103_shared.py ├── ts_31_104.py ├── ts_51_011.py └── utils.py ├── pyproject.toml ├── requirements.txt ├── scripts ├── deactivate-5g.script ├── deactivate-ims.script └── sysmoISIM-SJA2 │ └── dump-auth-cfg.pysim ├── setup.cfg ├── setup.py ├── smdpp-data ├── certs │ ├── CertificateIssuer │ │ ├── CERT_CI_ECDSA_BRP.der │ │ ├── CERT_CI_ECDSA_BRP.pem │ │ ├── CERT_CI_ECDSA_NIST.der │ │ ├── CERT_CI_ECDSA_NIST.pem │ │ └── CI-csr.cnf │ ├── DPauth │ │ ├── CERT_S_SM_DP2auth_ECDSA_BRP.der │ │ ├── CERT_S_SM_DP2auth_ECDSA_NIST.der │ │ ├── CERT_S_SM_DPauth_ECDSA_BRP.der │ │ ├── CERT_S_SM_DPauth_ECDSA_NIST.der │ │ ├── PK_S_SM_DP2auth_ECDSA_BRP.pem │ │ ├── PK_S_SM_DP2auth_ECDSA_NIST.pem │ │ ├── PK_S_SM_DPauth_ECDSA_BRP.pem │ │ ├── PK_S_SM_DPauth_ECDSA_NIST.pem │ │ ├── SK_S_SM_DP2auth_ECDSA_BRP.pem │ │ ├── SK_S_SM_DP2auth_ECDSA_NIST.pem │ │ ├── SK_S_SM_DPauth_ECDSA_BRP.pem │ │ ├── SK_S_SM_DPauth_ECDSA_NIST.pem │ │ └── data_sig.der │ ├── DPpb │ │ ├── CERT_S_SM_DP2pb_ECDSA_BRP.der │ │ ├── CERT_S_SM_DP2pb_ECDSA_NIST.der │ │ ├── CERT_S_SM_DPpb_ECDSA_BRP.der │ │ ├── CERT_S_SM_DPpb_ECDSA_NIST.der │ │ ├── PK_S_SM_DP2pb_ECDSA_BRP.pem │ │ ├── PK_S_SM_DP2pb_ECDSA_NIST.pem │ │ ├── PK_S_SM_DPpb_ECDSA_BRP.pem │ │ ├── PK_S_SM_DPpb_ECDSA_NIST.pem │ │ ├── SK_S_SM_DP2pb_ECDSA_BRP.pem │ │ ├── SK_S_SM_DP2pb_ECDSA_NIST.pem │ │ ├── SK_S_SM_DPpb_ECDSA_BRP.pem │ │ └── SK_S_SM_DPpb_ECDSA_NIST.pem │ ├── DPtls │ │ ├── CERT_S_SM_DP2_TLS.csr.cnf │ │ ├── CERT_S_SM_DP2_TLS.der │ │ ├── CERT_S_SM_DP2_TLS.ext.cnf │ │ ├── CERT_S_SM_DP4_TLS.csr.cnf │ │ ├── CERT_S_SM_DP4_TLS.der │ │ ├── CERT_S_SM_DP4_TLS.ext.cnf │ │ ├── CERT_S_SM_DP8_TLS.csr.cnf │ │ ├── CERT_S_SM_DP8_TLS.der │ │ ├── CERT_S_SM_DP8_TLS.ext.cnf │ │ ├── CERT_S_SM_DP_TLS.csr.cnf │ │ ├── CERT_S_SM_DP_TLS.ext.cnf │ │ ├── CERT_S_SM_DP_TLS_BRP.der │ │ ├── CERT_S_SM_DP_TLS_NIST.der │ │ ├── CERT_S_SM_DP_TLS_NIST.pem │ │ ├── Old_TLS_Validity │ │ │ ├── Expired 2021 │ │ │ │ ├── CERT_S_SM_DP2_TLS.der │ │ │ │ ├── CERT_S_SM_DP4_TLS.der │ │ │ │ ├── CERT_S_SM_DP8_TLS.der │ │ │ │ ├── CERT_S_SM_DP_TLS_BRP.der │ │ │ │ └── CERT_S_SM_DP_TLS_NIST.der │ │ │ ├── Expired 2022 │ │ │ │ ├── CERT_S_SM_DP2_TLS.der │ │ │ │ ├── CERT_S_SM_DP4_TLS.der │ │ │ │ ├── CERT_S_SM_DP8_TLS.der │ │ │ │ ├── CERT_S_SM_DP_TLS_BRP.der │ │ │ │ └── CERT_S_SM_DP_TLS_NIST.der │ │ │ └── Expired 2023 │ │ │ │ ├── CERT_S_SM_DP2_TLS.der │ │ │ │ ├── CERT_S_SM_DP4_TLS.der │ │ │ │ ├── CERT_S_SM_DP8_TLS.der │ │ │ │ ├── CERT_S_SM_DP_TLS_BRP.der │ │ │ │ └── CERT_S_SM_DP_TLS_NIST.der │ │ ├── PK_S_SM_DP2_TLS_NIST.pem │ │ ├── PK_S_SM_DP4_TLS.pem │ │ ├── PK_S_SM_DP8_TLS.pem │ │ ├── PK_S_SM_DP_TLS_BRP.pem │ │ ├── PK_S_SM_DP_TLS_NIST.pem │ │ ├── SK_S_SM_DP2_TLS_NIST.pem │ │ ├── SK_S_SM_DP4_TLS.pem │ │ ├── SK_S_SM_DP8_TLS.pem │ │ ├── SK_S_SM_DP_TLS_BRP.pem │ │ └── SK_S_SM_DP_TLS_NIST.pem │ └── README └── upp │ ├── TS48V1-A-UNIQUE.der │ ├── TS48V1-B-UNIQUE.der │ ├── TS48V2-SAIP2-1-BERTLV-UNIQUE.der │ ├── TS48V2-SAIP2-1-NOBERTLV-UNIQUE.der │ ├── TS48V2-SAIP2-3-BERTLV-UNIQUE.der │ ├── TS48V2-SAIP2-3-NOBERTLV-UNIQUE.der │ ├── TS48V3-SAIP2-1-BERTLV-UNIQUE.der │ ├── TS48V3-SAIP2-1-NOBERTLV-UNIQUE.der │ ├── TS48V3-SAIP2-3-BERTLV-UNIQUE.der │ ├── TS48V3-SAIP2-3-NOBERTLV-UNIQUE.der │ ├── TS48V4-SAIP2-1A-NOBERTLV-UNIQUE.der │ ├── TS48V4-SAIP2-1B-NOBERTLV-UNIQUE.der │ ├── TS48V4-SAIP2-3-BERTLV-UNIQUE.der │ ├── TS48V4-SAIP2-3-NOBERTLV-UNIQUE.der │ ├── TS48V5-SAIP2-1A-NOBERTLV-UNIQUE.der │ ├── TS48V5-SAIP2-1B-NOBERTLV-UNIQUE.der │ ├── TS48V5-SAIP2-3-BERTLV-SUCI-UNIQUE.der │ ├── TS48V5-SAIP2-3-NOBERTLV-UNIQUE.der │ ├── TS48v1_A.der │ ├── TS48v1_B.der │ ├── TS48v2_SAIP2.1_BERTLV.der │ ├── TS48v2_SAIP2.1_NoBERTLV.der │ ├── TS48v2_SAIP2.3_BERTLV.der │ ├── TS48v2_SAIP2.3_NoBERTLV.der │ ├── TS48v3_SAIP2.1_BERTLV.der │ ├── TS48v3_SAIP2.1_NoBERTLV.der │ ├── TS48v3_SAIP2.3_BERTLV.der │ ├── TS48v3_SAIP2.3_NoBERTLV.der │ ├── TS48v4_SAIP2.1A_NoBERTLV.der │ ├── TS48v4_SAIP2.1B_NoBERTLV.der │ ├── TS48v4_SAIP2.3_BERTLV.der │ ├── TS48v4_SAIP2.3_NoBERTLV.der │ ├── TS48v5_SAIP2.1A_NoBERTLV.der │ ├── TS48v5_SAIP2.1B_NoBERTLV.der │ ├── TS48v5_SAIP2.3_BERTLV_SUCI.der │ └── TS48v5_SAIP2.3_NoBERTLV.der └── tests ├── card_sanitizer ├── card_backup_3b991800118822334455667760_2222334455667788990.script ├── card_backup_3b9a940092027593110001020221_1122334455667788990.script ├── card_backup_3b9f95801fc78031e073f62113674d4516004301008f_89445310150011013678.script ├── card_backup_3b9f96801f878031e073fe211b674a357530350265f8_8949440000001155314.script ├── card_backup_3b9f96801f878031e073fe211b674a4c753034054ba9_8988211000000467343.script ├── card_backup_3b9f96801fc78031a073be21136743200718000001a5_8988211320300000028.script ├── card_backup_3b9f96801fc78031a073be21136744220610000001a9_8988219000000117833.script ├── card_data.csv └── card_sanitizer.py ├── pySim-prog_test ├── Fairwaves-SIM.data ├── Fairwaves-SIM.ok ├── Wavemobile-SIM.data ├── Wavemobile-SIM.ok ├── fakemagicsim.data ├── fakemagicsim.ok ├── pySim-prog_test.sh ├── sysmoISIM-SJA2.data ├── sysmoISIM-SJA2.ok ├── sysmoISIM-SJA5.data ├── sysmoISIM-SJA5.ok ├── sysmoUSIM-SJS1.data ├── sysmoUSIM-SJS1.ok ├── sysmosim-gr1.data └── sysmosim-gr1.ok ├── pySim-shell_test ├── README.txt ├── __init__.py ├── apdu │ ├── __init__.py │ ├── test.py │ ├── test_apdu.script │ ├── test_apdu_legacy.script │ ├── test_apdu_legacy_scp02.template │ ├── test_apdu_legacy_scp03.template │ ├── test_apdu_scp02.template │ └── test_apdu_scp03.template ├── ara_m │ ├── __init__.py │ ├── adf_ara-m.cfg.ok │ ├── adf_ara-m.script.ok │ ├── adf_ara-m_empty.cfg.ok │ ├── test.py │ └── test.script ├── authenticate │ ├── __init__.py │ ├── auth_result.ok │ ├── test.py │ └── test.script ├── card_data.csv ├── card_init │ ├── __init__.py │ ├── test.py │ └── test_card_init.script ├── cardinfo │ ├── __init__.py │ ├── sysmoEUICC1-C2T-cardinfo.ok │ ├── sysmoISIM-SJA2-cardinfo.ok │ ├── sysmoISIM-SJA5-S17-cardinfo.ok │ ├── sysmoSIM-GR1-cardinfo.ok │ ├── test.py │ └── test.template ├── chv │ ├── __init__.py │ ├── test.py │ ├── test_manage_csv.ok │ ├── test_manage_csv.template │ ├── test_manage_direct.ok │ ├── test_manage_direct.template │ ├── test_unblock_csv.ok │ ├── test_unblock_csv.script │ ├── test_unblock_direct.ok │ └── test_unblock_direct.template ├── config.yaml ├── euicc │ ├── __init__.py │ ├── enable_disable_profile.ok │ ├── euicc_info1.ok │ ├── euicc_info2.ok │ ├── get_eid.ok │ ├── get_profiles_info.ok │ ├── notifications.ok │ ├── set_nickname.ok │ ├── test.py │ ├── test_enable_disable_profile.script │ ├── test_gen_notif.script │ ├── test_get_eid.script │ ├── test_get_euicc_info.script │ ├── test_get_profiles_info.script │ ├── test_list_notif.script │ ├── test_rm_notif.template │ └── test_set_nickname.script ├── export │ ├── __init__.py │ ├── export.script.ok │ ├── test.py │ ├── test_export.script │ └── test_import.script ├── file_admin │ ├── __init__.py │ ├── activate_deactivate_file.ok │ ├── test.py │ ├── test_activate_deactivate_file.script │ ├── test_create_delete_df.script │ ├── test_create_resize_delete_linear_fixed_ef.script │ └── test_create_resize_delete_transparent_ef.script ├── file_content │ ├── __init__.py │ ├── test.py │ ├── test_ber_tlv_uicc.ok │ ├── test_ber_tlv_uicc.script │ ├── test_binary_sim.ok │ ├── test_binary_sim.script │ ├── test_binary_uicc.ok │ ├── test_binary_uicc.script │ ├── test_record_sim.ok │ ├── test_record_sim.script │ ├── test_record_uicc.ok │ └── test_record_uicc.script ├── file_specific │ ├── __init__.py │ ├── ef_imsi.ok │ ├── test.py │ ├── test_ef_ist.ok │ ├── test_ef_ist.script │ ├── test_ef_ust.ok │ ├── test_ef_ust.script │ └── test_update_imsi_plmn.script ├── fsdump │ ├── __init__.py │ ├── fsdump.json.ok │ ├── test.py │ └── test.script ├── get_identity │ ├── __init__.py │ ├── test.py │ └── test.script ├── gp │ ├── __init__.py │ ├── get_status_isd.ok │ ├── key_information.ok │ ├── test.py │ ├── test_est_scp02_csv.script │ ├── test_est_scp02_direct.template │ ├── test_est_scp03_csv.script │ ├── test_est_scp03_direct.template │ ├── test_get_status.script │ └── test_put_delete_key.script ├── lchan │ ├── __init__.py │ ├── test.ok │ ├── test.py │ └── test.script ├── navigate_fs │ ├── __init__.py │ ├── checkpoints_sim.ok │ ├── checkpoints_uicc.ok │ ├── test.py │ ├── test_sim.script │ └── test_uicc.script ├── utils.py └── verify_adm │ ├── __init__.py │ ├── test.py │ ├── test_cmdline.script │ ├── test_csv.script │ └── test_direct.template ├── pySim-trace_test ├── pySim-trace_test.sh ├── pySim-trace_test_gsmtap.pcapng └── pySim-trace_test_gsmtap.pcapng.ok └── unittests ├── test_apdu.py ├── test_esim.py ├── test_esim_bsp.py ├── test_esim_saip.py ├── test_euicc.py ├── test_files.py ├── test_globalplatform.py ├── test_javacard.cap ├── test_javacard.py ├── test_ota.py ├── test_sms.py ├── test_tlvs.py └── test_utils.py /.checkpatch.conf: -------------------------------------------------------------------------------- 1 | --exclude ^pySim/esim/asn1/.*\.asn$ 2 | --exclude ^smdpp-data/.*$ 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: osmocom 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .*.swp 3 | 4 | /docs/_* 5 | /docs/generated 6 | /.cache 7 | /.local 8 | /build 9 | /pySim.egg-info 10 | /smdpp-data/sm-dp-sessions 11 | dist 12 | tags 13 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=gerrit.osmocom.org 3 | project=pysim 4 | -------------------------------------------------------------------------------- /contrib/eidtool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Command line tool to compute or verify EID (eUICC ID) values 4 | # 5 | # (C) 2024 by Harald Welte 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | 20 | import sys 21 | import argparse 22 | 23 | from pySim.euicc import compute_eid_checksum, verify_eid_checksum 24 | 25 | 26 | option_parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, 27 | description="""pySim EID Tool 28 | This utility program can be used to compute or verify the checksum of an EID 29 | (eUICC Identifier). See GSMA SGP.29 for the algorithm details. 30 | 31 | Example (verification): 32 | $ eidtool.py --verify 89882119900000000000000000001654 33 | EID checksum verified successfully 34 | 35 | Example (generation, passing first 30 digits): 36 | $ eidtool.py --compute 898821199000000000000000000016 37 | 89882119900000000000000000001654 38 | 39 | Example (generation, passing all 32 digits): 40 | $ eidtool.py --compute 89882119900000000000000000001600 41 | 89882119900000000000000000001654 42 | 43 | Example (generation, specifying base 30 digits and number to add): 44 | $ eidtool.py --compute 898821199000000000000000000000 --add 16 45 | 89882119900000000000000000001654 46 | """) 47 | group = option_parser.add_mutually_exclusive_group(required=True) 48 | group.add_argument('--verify', help='Verify given EID csum') 49 | group.add_argument('--compute', help='Generate EID csum') 50 | option_parser.add_argument('--add', type=int, help='Add value to EID base before computing') 51 | 52 | 53 | if __name__ == '__main__': 54 | opts = option_parser.parse_args() 55 | 56 | if opts.verify: 57 | res = verify_eid_checksum(opts.verify) 58 | if res: 59 | print("EID checksum verified successfully") 60 | sys.exit(0) 61 | else: 62 | print("EID checksum invalid") 63 | sys.exit(1) 64 | elif opts.compute: 65 | eid = opts.compute 66 | if opts.add: 67 | if len(eid) != 30: 68 | print("EID base must be 30 digits when using --add") 69 | sys.exit(2) 70 | eid = str(int(eid) + int(opts.add)) 71 | res = compute_eid_checksum(eid) 72 | print(res) 73 | 74 | -------------------------------------------------------------------------------- /contrib/esim-qrcode-gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Small command line utility program to encode eSIM QR-Codes 4 | 5 | # (C) 2024 by Harald Welte 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Affero General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Affero General Public License 18 | # along with this program. If not, see . 19 | 20 | import sys 21 | import argparse 22 | 23 | from pySim.esim import ActivationCode 24 | 25 | 26 | option_parser = argparse.ArgumentParser(description=""" 27 | eSIM QR code generator. Will encode the given hostname + activation code 28 | into the eSIM RSP String format as specified in SGP.22 Section 4.1. If 29 | a PNG output file is specified, it will also generate a QR code.""") 30 | option_parser.add_argument('hostname', help='FQDN of SM-DP+') 31 | option_parser.add_argument('token', help='MatchingID / Token') 32 | option_parser.add_argument('--oid', help='SM-DP+ OID in CERT.DPauth.ECDSA') 33 | option_parser.add_argument('--confirmation-code-required', action='store_true', 34 | help='Whether a Confirmation Code is required') 35 | option_parser.add_argument('--png', help='Output PNG file name (no PNG is written if omitted)') 36 | 37 | 38 | 39 | if __name__ == '__main__': 40 | opts = option_parser.parse_args() 41 | 42 | ac = ActivationCode(opts.hostname, opts.token, opts.oid, opts.confirmation_code_required) 43 | print(ac.to_string()) 44 | if opts.png: 45 | with open(opts.png, 'wb') as f: 46 | img = ac.to_qrcode() 47 | img.save(f) 48 | print("# generated QR code stored to '%s'" % (opts.png)) 49 | -------------------------------------------------------------------------------- /contrib/jenkins.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | # jenkins build helper script for pysim. This is how we build on jenkins.osmocom.org 3 | # 4 | # environment variables: 5 | # * WITH_MANUALS: build manual PDFs if set to "1" 6 | # * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1") 7 | # * JOB_TYPE: one of 'test', 'distcheck', 'pylint', 'docs' 8 | # * SKIP_CLEAN_WORKSPACE: don't run osmo-clean-workspace.sh (for pyosmocom CI) 9 | # 10 | 11 | export PYTHONUNBUFFERED=1 12 | 13 | if [ ! -d "./tests/" ] ; then 14 | echo "###############################################" 15 | echo "Please call from pySim-prog top directory" 16 | echo "###############################################" 17 | exit 1 18 | fi 19 | 20 | if [ -z "$SKIP_CLEAN_WORKSPACE" ]; then 21 | osmo-clean-workspace.sh 22 | fi 23 | 24 | case "$JOB_TYPE" in 25 | "test") 26 | virtualenv -p python3 venv --system-site-packages 27 | . venv/bin/activate 28 | 29 | pip install -r requirements.txt 30 | pip install pyshark 31 | 32 | # Execute automatically discovered unit tests first 33 | python -m unittest discover -v -s tests/unittests 34 | 35 | # Run pySim-prog integration tests (requires physical cards) 36 | cd tests/pySim-prog_test/ 37 | ./pySim-prog_test.sh 38 | cd ../../ 39 | 40 | # Run pySim-trace test 41 | tests/pySim-trace_test/pySim-trace_test.sh 42 | 43 | # Run pySim-shell integration tests (requires physical cards) 44 | python3 -m unittest discover -v -s ./tests/pySim-shell_test/ 45 | ;; 46 | "distcheck") 47 | virtualenv -p python3 venv --system-site-packages 48 | . venv/bin/activate 49 | 50 | pip install . 51 | pip install pyshark 52 | 53 | for prog in venv/bin/pySim-*.py; do 54 | $prog --help > /dev/null 55 | done 56 | ;; 57 | "pylint") 58 | # Print pylint version 59 | pip3 freeze | grep pylint 60 | 61 | virtualenv -p python3 venv --system-site-packages 62 | . venv/bin/activate 63 | 64 | pip install . 65 | 66 | # Run pylint to find potential errors 67 | # Ignore E1102: not-callable 68 | # pySim/filesystem.py: E1102: method is not callable (not-callable) 69 | # Ignore E0401: import-error 70 | # pySim/utils.py:276: E0401: Unable to import 'Crypto.Cipher' (import-error) 71 | # pySim/utils.py:277: E0401: Unable to import 'Crypto.Util.strxor' (import-error) 72 | python3 -m pylint -j0 --errors-only \ 73 | --disable E1102 \ 74 | --disable E0401 \ 75 | --enable W0301 \ 76 | pySim tests/unittests/*.py *.py \ 77 | contrib/*.py 78 | ;; 79 | "docs") 80 | virtualenv -p python3 venv --system-site-packages 81 | . venv/bin/activate 82 | 83 | pip install -r requirements.txt 84 | 85 | # XXX: workaround for https://github.com/python-cmd2/cmd2/issues/1414 86 | # 2.4.3 was the last stable release not affected by this bug (OS#6776) 87 | pip install cmd2==2.4.3 88 | 89 | rm -rf docs/_build 90 | make -C "docs" html latexpdf 91 | 92 | if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then 93 | make -C "docs" publish publish-html 94 | fi 95 | ;; 96 | *) 97 | set +x 98 | echo "ERROR: JOB_TYPE has unexpected value '$JOB_TYPE'." 99 | exit 1 100 | esac 101 | 102 | osmo-clean-workspace.sh 103 | -------------------------------------------------------------------------------- /contrib/saip-tool_example_add-app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is an example script to illustrate how to add JAVA card applets to an existing eUICC profile package. 3 | 4 | PYSIMPATH=../ 5 | INPATH=../smdpp-data/upp/TS48V1-A-UNIQUE.der 6 | OUTPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-hello.der 7 | APPPATH=./HelloSTK_09122024.cap 8 | 9 | # Download example applet (see also https://gitea.osmocom.org/sim-card/hello-stk): 10 | if ! [ -f $APPPATH ]; then 11 | wget https://osmocom.org/attachments/download/8931/HelloSTK_09122024.cap 12 | fi 13 | 14 | # Step #1: Create the application PE and load the ijc contents from the .cap file: 15 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $INPATH add-app \ 16 | --output-file $OUTPATH --applet-file $APPPATH --aid 'D07002CA44' 17 | 18 | # Step #2: Create the application instance inside the application PE created in step #1: 19 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $OUTPATH add-app-inst --output-file $OUTPATH \ 20 | --aid 'D07002CA44' \ 21 | --class-aid 'D07002CA44900101' \ 22 | --inst-aid 'D07002CA44900101' \ 23 | --app-privileges '00' \ 24 | --app-spec-pars '00' \ 25 | --uicc-toolkit-app-spec-pars '01001505000000000000000000000000' 26 | 27 | # Display the contents of the resulting application PE: 28 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $OUTPATH info --apps 29 | 30 | # For an explaination of --uicc-toolkit-app-spec-pars, see: 31 | # ETSI TS 102 226, section 8.2.1.3.2.2.1 32 | -------------------------------------------------------------------------------- /contrib/saip-tool_example_extract-apps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is an example script to illustrate how to extract JAVA card applets from an existing eUICC profile package. 3 | 4 | PYSIMPATH=../ 5 | INPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-hello.der 6 | OUTPATH=./ 7 | 8 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $INPATH extract-apps --output-dir ./ --format ijc 9 | -------------------------------------------------------------------------------- /contrib/saip-tool_example_remove-app-inst.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is an example script to illustrate how to remove a JAVA card applet instance from an application PE inside an 3 | # existing eUICC profile package. 4 | 5 | PYSIMPATH=../ 6 | INPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-hello.der 7 | OUTPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-hello-no-inst.der 8 | 9 | # Remove application PE entirely 10 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $INPATH remove-app-inst \ 11 | --output-file $OUTPATH --aid 'd07002ca44' --inst-aid 'd07002ca44900101' 12 | 13 | # Display the contents of the resulting application PE: 14 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $OUTPATH info --apps 15 | -------------------------------------------------------------------------------- /contrib/saip-tool_example_remove-app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This is an example script to illustrate how to remove a JAVA card applet from an existing eUICC profile package. 3 | 4 | PYSIMPATH=../ 5 | INPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-hello.der 6 | OUTPATH=../smdpp-data/upp/TS48V1-A-UNIQUE-no-hello.der 7 | 8 | # Remove application PE entirely 9 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $INPATH remove-app \ 10 | --output-file $OUTPATH --aid 'D07002CA44' 11 | 12 | # Display the contents of the resulting application PE: 13 | PYTHONPATH=$PYSIMPATH python3 $PYSIMPATH/contrib/saip-tool.py $OUTPATH info --apps 14 | -------------------------------------------------------------------------------- /contrib/sim-rest-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Osmocom SIM REST server 3 | 4 | [Service] 5 | Type=simple 6 | # we listen to 0.0.0.0, allowing remote, unauthenticated clients to connect from everywhere! 7 | ExecStart=/usr/local/src/pysim/contrib/sim-rest-server.py -H 0.0.0.0 8 | Restart=always 9 | RestartSec=2 10 | # this user must be created beforehand; it must have PC/SC access 11 | User=rest 12 | 13 | [Install] 14 | WantedBy=multi-user.target 15 | -------------------------------------------------------------------------------- /contrib/suci-keytool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # small utility program to deal with 5G SUCI key material, at least for the ECIES Protection Scheme 4 | # Profile A (curve25519) and B (secp256r1) 5 | 6 | # (C) 2024 by Harald Welte 7 | # SPDX-License-Identifier: GPL-2.0+ 8 | 9 | import argparse 10 | 11 | from osmocom.utils import b2h 12 | from Cryptodome.PublicKey import ECC 13 | # if used with pycryptodome < v3.21.0 you will get the following error when using curve25519: 14 | # "Cryptodome.PublicKey.ECC.UnsupportedEccFeature: Unsupported ECC purpose (OID: 1.3.101.110)" 15 | 16 | def gen_key(opts): 17 | # FIXME: avoid overwriting key files 18 | mykey = ECC.generate(curve=opts.curve) 19 | data = mykey.export_key(format='PEM') 20 | with open(opts.key_file, "wt") as f: 21 | f.write(data) 22 | 23 | def dump_pkey(opts): 24 | 25 | #with open("curve25519-1.key", "r") as f: 26 | 27 | with open(opts.key_file, "r") as f: 28 | data = f.read() 29 | mykey = ECC.import_key(data) 30 | 31 | der = mykey.public_key().export_key(format='raw', compress=opts.compressed) 32 | print(b2h(der)) 33 | 34 | arg_parser = argparse.ArgumentParser(description="""Generate or export SUCI keys for 5G SA networks""") 35 | arg_parser.add_argument('--key-file', help='The key file to use', required=True) 36 | 37 | subparsers = arg_parser.add_subparsers(dest='command', help="The command to perform", required=True) 38 | 39 | parser_genkey = subparsers.add_parser('generate-key', help='Generate a new key pair') 40 | parser_genkey.add_argument('--curve', help='The ECC curve to use', choices=['secp256r1','curve25519'], required=True) 41 | 42 | parser_dump_pkey = subparsers.add_parser('dump-pub-key', help='Dump the public key') 43 | parser_dump_pkey.add_argument('--compressed', help='Use point compression', action='store_true') 44 | 45 | if __name__ == '__main__': 46 | 47 | opts = arg_parser.parse_args() 48 | 49 | if opts.command == 'generate-key': 50 | gen_key(opts) 51 | elif opts.command == 'dump-pub-key': 52 | dump_pkey(opts) 53 | -------------------------------------------------------------------------------- /contrib/unber.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # A more useful verion of the 'unber' tool provided with asn1c: 4 | # Give a hierarchical decode of BER/DER-encoded ASN.1 TLVs 5 | 6 | import sys 7 | import argparse 8 | 9 | from osmocom.utils import b2h, h2b 10 | from osmocom.tlv import bertlv_parse_one, bertlv_encode_tag 11 | 12 | def process_one_level(content: bytes, indent: int): 13 | remainder = content 14 | while len(remainder): 15 | tdict, l, v, remainder = bertlv_parse_one(remainder) 16 | #print(tdict) 17 | rawtag = bertlv_encode_tag(tdict) 18 | if tdict['constructed']: 19 | print("%s%s l=%d" % (indent*" ", b2h(rawtag), l)) 20 | process_one_level(v, indent + 1) 21 | else: 22 | print("%s%s l=%d %s" % (indent*" ", b2h(rawtag), l, b2h(v))) 23 | 24 | 25 | option_parser = argparse.ArgumentParser(description='BER/DER data dumper') 26 | group = option_parser.add_mutually_exclusive_group(required=True) 27 | group.add_argument('--file', help='Input file') 28 | group.add_argument('--hex', help='Input hexstring') 29 | 30 | 31 | if __name__ == '__main__': 32 | opts = option_parser.parse_args() 33 | 34 | if opts.file: 35 | with open(opts.file, 'rb') as f: 36 | content = f.read() 37 | elif opts.hex: 38 | content = h2b(opts.hex) 39 | else: 40 | # avoid pylint "(possibly-used-before-assignment)" below 41 | sys.exit(2) 42 | 43 | process_one_level(content, 0) 44 | -------------------------------------------------------------------------------- /csv-format: -------------------------------------------------------------------------------- 1 | This file aims to describe the format of the CSV file pySim uses. 2 | 3 | The first line contains the fieldnames which will be used by pySim. This 4 | avoids having a specific order. 5 | 6 | The field names are the following: 7 | 8 | iccid: ICCID of the card. Used to identify the cards (with --read-iccid) 9 | imsi: IMSI of the card 10 | mcc: Mobile Country Code (optional) 11 | mnc: Mobile Network Code (optional) 12 | smsp: MSISDN of the SMSC (optional) 13 | ki: Ki 14 | opc: OPc 15 | acc: Access class of the SIM (optional) 16 | pin_adm: Admin PIN of the SIM. Needed to reprogram various files 17 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= python3 -m sphinx.cmd.build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # for osmo-gsm-manuals 12 | OSMO_GSM_MANUALS_DIR ?= $(shell pkg-config osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null) 13 | OSMO_REPOSITORY = "pysim" 14 | UPLOAD_FILES = $(BUILDDIR)/latex/osmopysim-usermanual.pdf 15 | CLEAN_FILES = $(UPLOAD_FILES) 16 | 17 | # Copy variables from Makefile.common.inc that are used in publish-html, 18 | # as Makefile.common.inc must be included after publish-html 19 | PUBLISH_REF ?= master 20 | PUBLISH_TEMPDIR = _publish_tmpdir 21 | SSH_COMMAND = ssh -o 'UserKnownHostsFile=$(OSMO_GSM_MANUALS_DIR)/build/known_hosts' -p 48 22 | 23 | # Put it first so that "make" without argument is like "make help". 24 | .PHONY: help 25 | help: 26 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 27 | 28 | $(BUILDDIR)/latex/pysim.pdf: latexpdf 29 | @/bin/true 30 | 31 | publish-html: html 32 | rm -rf "$(PUBLISH_TEMPDIR)" 33 | mkdir -p "$(PUBLISH_TEMPDIR)/pysim/$(PUBLISH_REF)" 34 | cp -r "$(BUILDDIR)"/html "$(PUBLISH_TEMPDIR)/pysim/$(PUBLISH_REF)" 35 | cd "$(PUBLISH_TEMPDIR)" && \ 36 | rsync \ 37 | -avzR \ 38 | -e "$(SSH_COMMAND)" \ 39 | "pysim" \ 40 | docs@ftp.osmocom.org:web-files/ 41 | rm -rf "$(PUBLISH_TEMPDIR)" 42 | 43 | # put this before the catch-all below 44 | include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc 45 | 46 | 47 | # Catch-all target: route all unknown targets to Sphinx using the new 48 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 49 | %: 50 | @if [ "$@" != "shrink" ]; then \ 51 | $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O); \ 52 | fi 53 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | sys.path.insert(0, os.path.abspath('..')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = 'osmopysim-usermanual' 21 | copyright = '2009-2023 by Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle, Merlin Chlosta' 22 | author = 'Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle, Merlin Chlosta' 23 | 24 | 25 | # -- General configuration --------------------------------------------------- 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be 28 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 29 | # ones. 30 | extensions = [ 31 | "sphinx.ext.autodoc", 32 | "sphinxarg.ext", 33 | "sphinx.ext.autosectionlabel", 34 | "sphinx.ext.napoleon" 35 | ] 36 | 37 | # Add any paths that contain templates here, relative to this directory. 38 | templates_path = ['_templates'] 39 | 40 | # List of patterns, relative to source directory, that match files and 41 | # directories to ignore when looking for source files. 42 | # This pattern also affects html_static_path and html_extra_path. 43 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 44 | 45 | 46 | # -- Options for HTML output ------------------------------------------------- 47 | 48 | # The theme to use for HTML and HTML Help pages. See the documentation for 49 | # a list of builtin themes. 50 | # 51 | html_theme = 'alabaster' 52 | 53 | # Add any paths that contain custom static files (such as style sheets) here, 54 | # relative to this directory. They are copied after the builtin static files, 55 | # so a file named "default.css" will overwrite the builtin "default.css". 56 | html_static_path = ['_static'] 57 | 58 | autoclass_content = 'both' 59 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. pysim documentation master file 2 | 3 | Welcome to Osmocom pySim 4 | ======================== 5 | 6 | Introduction 7 | ------------ 8 | 9 | pySim is a python implementation of various software that helps you with 10 | managing subscriber identity cards for cellular networks, so-called SIM 11 | cards. 12 | 13 | Many Osmocom (Open Source Mobile Communications) projects relate to operating 14 | private / custom cellular networks, and provisioning SIM cards for said networks 15 | is in many cases a requirement to operate such networks. 16 | 17 | To make use of most of pySim's features, you will need a `programmable` SIM card, 18 | i.e. a card where you are the owner/operator and have sufficient credentials (such 19 | as the `ADM PIN`) in order to write to many if not most of the files on the card. 20 | 21 | Such cards are, for example, available from sysmocom, a major contributor to pySim. 22 | See https://www.sysmocom.de/products/lab/sysmousim/ for more details. 23 | 24 | pySim supports classic GSM SIM cards as well as ETSI UICC with 3GPP USIM and ISIM 25 | applications. It is easily extensible, so support for additional files, card 26 | applications, etc. can be added easily by any python developer. We do encourage you 27 | to submit your contributions to help this collaborative development project. 28 | 29 | pySim consists of several parts: 30 | 31 | * a python :ref:`library` containing plenty of objects and methods that can be used for 32 | writing custom programs interfacing with SIM cards. 33 | * the [new] :ref:`interactive pySim-shell command line program` 34 | * the [new] :ref:`pySim-trace APDU trace decoder` 35 | * the [legacy] :ref:`pySim-prog and pySim-read tools` 36 | 37 | .. toctree:: 38 | :maxdepth: 3 39 | :caption: Contents: 40 | 41 | shell 42 | trace 43 | legacy 44 | smpp2sim 45 | library 46 | library-esim 47 | osmo-smdpp 48 | sim-rest 49 | suci-keytool 50 | saip-tool 51 | 52 | 53 | Indices and tables 54 | ================== 55 | 56 | * :ref:`genindex` 57 | * :ref:`modindex` 58 | * :ref:`search` 59 | -------------------------------------------------------------------------------- /docs/library-esim.rst: -------------------------------------------------------------------------------- 1 | pySim eSIM libraries 2 | ==================== 3 | 4 | The pySim eSIM libraries implement a variety of functionality related to the GSMA eSIM universe, 5 | including the various interfaces of SGP.21 + SGP.22, as well as Interoperable Profile decioding, 6 | validation, personalization and encoding. 7 | 8 | .. automodule:: pySim.esim 9 | :members: 10 | 11 | 12 | GSMA SGP.21/22 Remote SIM Provisioning (RSP) - High Level 13 | --------------------------------------------------------- 14 | 15 | pySim.esim.rsp 16 | ~~~~~~~~~~~~~~ 17 | 18 | .. automodule:: pySim.esim.rsp 19 | :members: 20 | 21 | pySim.esim.es2p 22 | ~~~~~~~~~~~~~~~ 23 | 24 | .. automodule:: pySim.esim.es2p 25 | :members: 26 | 27 | 28 | pySim.esim.es8p 29 | ~~~~~~~~~~~~~~~ 30 | 31 | .. automodule:: pySim.esim.es8p 32 | :members: 33 | 34 | 35 | pySim.esim.es9p 36 | ~~~~~~~~~~~~~~~ 37 | 38 | .. automodule:: pySim.esim.es9p 39 | :members: 40 | 41 | 42 | GSMA SGP.21/22 Remote SIM Provisioning (RSP) - Low Level 43 | -------------------------------------------------------- 44 | 45 | pySim.esim.bsp 46 | ~~~~~~~~~~~~~~ 47 | 48 | .. automodule:: pySim.esim.bsp 49 | :members: 50 | 51 | pySim.esim.http_json_api 52 | ~~~~~~~~~~~~~~~~~~~~~~~~ 53 | 54 | .. automodule:: pySim.esim.http_json_api 55 | :members: 56 | 57 | pySim.esim.x509_cert 58 | ~~~~~~~~~~~~~~~~~~~~ 59 | 60 | .. automodule:: pySim.esim.x509_cert 61 | :members: 62 | 63 | SIMalliance / TCA Interoperable Profile 64 | --------------------------------------- 65 | 66 | 67 | pySim.esim.saip 68 | ~~~~~~~~~~~~~~~ 69 | .. automodule:: pySim.esim.saip 70 | :members: 71 | 72 | 73 | pySim.esim.saip.oid 74 | ~~~~~~~~~~~~~~~~~~~ 75 | 76 | .. automodule:: pySim.esim.saip.oid 77 | :members: 78 | 79 | pySim.esim.saip.personalization 80 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 81 | 82 | .. automodule:: pySim.esim.saip.personalization 83 | :members: 84 | 85 | pySim.esim.saip.templates 86 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | 88 | .. automodule:: pySim.esim.saip.templates 89 | :members: 90 | 91 | pySim.esim.saip.validation 92 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | 94 | .. automodule:: pySim.esim.saip.validation 95 | :members: 96 | -------------------------------------------------------------------------------- /docs/library.rst: -------------------------------------------------------------------------------- 1 | pySim library 2 | ============= 3 | 4 | pySim filesystem abstraction 5 | ---------------------------- 6 | 7 | .. automodule:: pySim.filesystem 8 | :members: 9 | 10 | pySim commands abstraction 11 | -------------------------- 12 | 13 | .. automodule:: pySim.commands 14 | :members: 15 | 16 | pySim Transport 17 | --------------- 18 | 19 | The pySim.transport classes implement specific ways how to 20 | communicate with a SIM card. A "transport" provides ways 21 | to transceive APDUs with the card. 22 | 23 | The most commonly used transport uses the PC/SC interface to 24 | utilize a variety of smart card interfaces ("readers"). 25 | 26 | Transport base class 27 | ~~~~~~~~~~~~~~~~~~~~ 28 | 29 | .. automodule:: pySim.transport 30 | :members: 31 | 32 | 33 | calypso / OsmocomBB transport 34 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35 | 36 | This allows the use of the SIM slot of an OsmocomBB compatible phone with the TI Calypso chipset, 37 | using the L1CTL interface to talk to the layer1.bin firmware on the phone. 38 | 39 | .. automodule:: pySim.transport.calypso 40 | :members: 41 | 42 | 43 | AT-command Modem transport 44 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 45 | 46 | This transport uses AT commands of a cellular modem in order to get access to the SIM card inserted 47 | in such a modem. 48 | 49 | .. automodule:: pySim.transport.modem_atcmd 50 | :members: 51 | 52 | 53 | PC/SC transport 54 | ~~~~~~~~~~~~~~~ 55 | 56 | PC/SC is the standard API for accessing smart card interfaces 57 | on all major operating systems, including the MS Windows Family, 58 | OS X as well as Linux / Unix OSs. 59 | 60 | .. automodule:: pySim.transport.pcsc 61 | :members: 62 | 63 | 64 | Serial/UART transport 65 | ~~~~~~~~~~~~~~~~~~~~~ 66 | 67 | This transport implements interfacing smart cards via 68 | very simplistic UART readers. These readers basically 69 | wire together the Rx+Tx pins of a RS232 UART, provide 70 | a fixed crystal oscillator for clock, and operate the UART 71 | at 9600 bps. These readers are sometimes called `Phoenix`. 72 | 73 | .. automodule:: pySim.transport.serial 74 | :members: 75 | 76 | 77 | pySim utility functions 78 | ----------------------- 79 | 80 | .. automodule:: pySim.utils 81 | :members: 82 | 83 | pySim exceptions 84 | ---------------- 85 | 86 | .. automodule:: pySim.exceptions 87 | :members: 88 | 89 | pySim card_handler 90 | ------------------ 91 | 92 | .. automodule:: pySim.card_handler 93 | :members: 94 | 95 | pySim card_key_provider 96 | ----------------------- 97 | 98 | .. automodule:: pySim.card_key_provider 99 | :members: 100 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/remote-access.rst: -------------------------------------------------------------------------------- 1 |  2 | Remote access to an UICC/eUICC 3 | ============================== 4 | 5 | To access a card with pySim-shell, it is not strictly necessary to have physical 6 | access to it. There are solutions that allow remote access to UICC/eUICC cards. 7 | In this section we will give a brief overview. 8 | 9 | 10 | osmo-remsim 11 | ----------- 12 | 13 | osmo-remsim is a suite of software programs enabling physical/geographic 14 | separation of a cellular phone (or modem) on the one hand side and the 15 | UICC/eUICC card on the other side. 16 | 17 | Using osmo-remsim, you can operate an entire fleet of modems/phones, as well as 18 | banks of SIM cards and dynamically establish or remove the connections between 19 | modems/phones and cards. 20 | 21 | To access remote cards with pySim-shell via osmo-remseim (RSPRO), the 22 | provided libifd_remsim_client would be used to provide a virtual PC/SC reader 23 | on the local machine. pySim-shell can then access this reader like any other 24 | PC/SC reader. 25 | 26 | More information on osmo-remsim can be found under: 27 | * https://osmocom.org/projects/osmo-remsim/wiki 28 | * https://ftp.osmocom.org/docs/osmo-remsim/master/osmo-remsim-usermanual.pdf 29 | 30 | 31 | Android APDU proxy 32 | ------------------ 33 | 34 | Android APDU proxy is an Android app that provides a bridge between a host 35 | computer and the UICC/eUICC slot of an Android smartphone. 36 | 37 | The APDU proxy connects to VPCD server that runs on the remote host (in this 38 | case the local machine where pySim-shell is running). The VPCD server then 39 | provides a virtual PC/SC reader, that pySim-shell can access like any other 40 | PC/SC reader. 41 | 42 | On the Android side the UICC/eUICC is accessed via OMAPI (Open Mobile API), 43 | which is available in Android since API level Android 8 (API level 29). 44 | 45 | More information Android APDU proxy can be found under: 46 | * https://gitea.osmocom.org/sim-card/android-apdu-proxy 47 | -------------------------------------------------------------------------------- /docs/suci-keytool.rst: -------------------------------------------------------------------------------- 1 | suci-keytool 2 | ============ 3 | 4 | Subscriber concealment is an important feature of the 5G SA architecture: It avoids the many privacy 5 | issues associated with having a permanent identifier (SUPI, traditionally the IMSI) transmitted in plain text 6 | over the air interface. Using SUCI solves this issue not just for the air interface; it even ensures the SUPI/IMSI 7 | is not known to the visited network (VPLMN) at all. 8 | 9 | In principle, the SUCI mechanism works by encrypting the SUPI by asymmetric (public key) cryptography: 10 | Only the HPLMN is in possession of the private key and hence can decrypt the SUCI to the SUPI, while 11 | each subscriber has the public key in order to encrypt their SUPI into the SUCI. In reality, the 12 | details are more complex, as there are ephemeral keys and cryptographic MAC involved. 13 | 14 | In any case, in order to operate a SUCI-enabled 5G SA network, you will have to 15 | 16 | #. generate a ECC key pair of public + private key 17 | #. deploy the public key on your USIMs 18 | #. deploy the private key on your 5GC, specifically the UDM function 19 | 20 | pysim contains (int its `contrib` directory) a small utility program that can make it easy to generate 21 | such keys: `suci-keytool.py` 22 | 23 | Generating keys 24 | ~~~~~~~~~~~~~~~ 25 | 26 | Example: Generating a *secp256r1* ECC public key pair and storing it to `/tmp/suci.key`: 27 | :: 28 | 29 | $ ./contrib/suci-keytool.py --key-file /tmp/suci.key generate-key --curve secp256r1 30 | 31 | Dumping public keys 32 | ~~~~~~~~~~~~~~~~~~~ 33 | 34 | In order to store the key to SIM cards as part of `ADF.USIM/DF.5GS/EF.SUCI_Calc_Info`, you will need 35 | a hexadecimal representation of the public key. You can achieve that using the `dump-pub-key` operation 36 | of suci-keytool: 37 | 38 | Example: Dumping the public key part from a previously generated key file: 39 | :: 40 | 41 | $ ./contrib/suci-keytool.py --key-file /tmp/suci.key dump-pub-key 42 | 0473152f32523725f5175d255da2bd909de97b1d06449a9277bc629fe42112f8643e6b69aa6dce6c86714ccbe6f2e0f4f4898d102e2b3f0c18ce26626f052539bb 43 | 44 | If you want the point-compressed representation, you can use the `--compressed` option: 45 | :: 46 | 47 | $ ./contrib/suci-keytool.py --key-file /tmp/suci.key dump-pub-key --compressed 48 | 0373152f32523725f5175d255da2bd909de97b1d06449a9277bc629fe42112f864 49 | 50 | 51 | 52 | suci-keytool syntax 53 | ~~~~~~~~~~~~~~~~~~~ 54 | 55 | .. argparse:: 56 | :module: contrib.suci-keytool 57 | :func: arg_parser 58 | :prog: contrib/suci-keytool.py 59 | -------------------------------------------------------------------------------- /docs/trace.rst: -------------------------------------------------------------------------------- 1 | pySim-trace 2 | =========== 3 | 4 | pySim-trace is a utility for high-level decode of APDU protocol traces such as those obtained with 5 | `Osmocom SIMtrace2 `_ or `osmo-qcdiag `_. 6 | 7 | pySim-trace leverages the existing knowledge of pySim-shell on anything related to SIM cards, 8 | including the structure/encoding of the various files on SIM/USIM/ISIM/HPSIM cards, and applies this 9 | to decoding protocol traces. This means that it shows not only the name of the command (like READ 10 | BINARY), but actually understands what the currently selected file is, and how to decode the 11 | contents of that file. 12 | 13 | pySim-trace also understands the parameters passed to commands and how to decode them, for example 14 | of the AUTHENTICATE command within the USIM/ISIM/HPSIM application. 15 | 16 | 17 | Demo 18 | ---- 19 | 20 | To get an idea how pySim-trace usage looks like, you can watch the relevant part of the 11/2022 21 | SIMtrace2 tutorial whose `recording is freely accessible `_. 22 | 23 | 24 | Running pySim-trace 25 | ------------------- 26 | 27 | Running pySim-trace requires you to specify the *source* of the to-be-decoded APDUs. There are several 28 | supported options, each with their own respective parameters (like a file name for PCAP decoding). 29 | 30 | See the detailed command line reference below for details. 31 | 32 | A typical execution of pySim-trace for doing live decodes of *GSMTAP (SIM APDU)* e.g. from SIMtrace2 or 33 | osmo-qcdiag would look like this: 34 | 35 | :: 36 | 37 | ./pySim-trace.py gsmtap-udp 38 | 39 | This binds to the default UDP port 4729 (GSMTAP) on localhost (127.0.0.1), and decodes any APDUs received 40 | there. 41 | 42 | 43 | 44 | pySim-trace command line reference 45 | ---------------------------------- 46 | 47 | .. argparse:: 48 | :module: pySim-trace 49 | :func: option_parser 50 | :prog: pySim-trace.py 51 | 52 | 53 | Constraints 54 | ----------- 55 | 56 | * In order to properly track the current location in the filesystem tree and other state, it is 57 | important that the trace you're decoding includes all of the communication with the SIM, ideally 58 | from the very start (power up). 59 | 60 | * pySim-trace currently only supports ETSI UICC (USIM/ISIM/HPSIM) and doesn't yet support legacy GSM 61 | SIM. This is not a fundamental technical constraint, it's just simply that nobody got around 62 | developing and testing that part. Contributions are most welcome. 63 | 64 | 65 | -------------------------------------------------------------------------------- /pySim/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/pySim/__init__.py -------------------------------------------------------------------------------- /pySim/apdu/ts_102_222.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """APDU definitions/decoders of ETSI TS 102 222. 3 | 4 | (C) 2022-2024 by Harald Welte 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | """ 19 | 20 | import logging 21 | 22 | from construct import Struct 23 | from osmocom.construct import * 24 | 25 | from pySim.apdu import ApduCommand, ApduCommandSet 26 | from pySim.ts_102_221 import FcpTemplate 27 | 28 | logger = logging.getLogger(__name__) 29 | 30 | # TS 102 222 Section 6.3 31 | class CreateFile(ApduCommand, n='CREATE FILE', ins=0xE0, cla=['0X', '4X', 'EX']): 32 | _apdu_case = 3 33 | _tlv = FcpTemplate 34 | 35 | # TS 102 222 Section 6.4 36 | class DeleteFile(ApduCommand, n='DELETE FILE', ins=0xE4, cla=['0X', '4X']): 37 | _apdu_case = 3 38 | _construct = Struct('file_id'/Bytes(2)) 39 | 40 | # TS 102 222 Section 6.7 41 | class TerminateDF(ApduCommand, n='TERMINATE DF', ins=0xE6, cla=['0X', '4X']): 42 | _apdu_case = 1 43 | 44 | # TS 102 222 Section 6.8 45 | class TerminateEF(ApduCommand, n='TERMINATE EF', ins=0xE8, cla=['0X', '4X']): 46 | _apdu_case = 1 47 | 48 | # TS 102 222 Section 6.9 49 | class TerminateCardUsage(ApduCommand, n='TERMINATE CARD USAGE', ins=0xFE, cla=['0X', '4X']): 50 | _apdu_case = 1 51 | 52 | # TS 102 222 Section 6.10 53 | class ResizeFile(ApduCommand, n='RESIZE FILE', ins=0xD4, cla=['8X', 'CX', 'EX']): 54 | _apdu_case = 3 55 | _construct_p1 = Enum(Byte, mode_0=0, mode_1=1) 56 | _tlv = FcpTemplate 57 | 58 | 59 | ApduCommands = ApduCommandSet('TS 102 222', cmds=[CreateFile, DeleteFile, TerminateDF, 60 | TerminateEF, TerminateCardUsage, ResizeFile]) 61 | -------------------------------------------------------------------------------- /pySim/apdu_source/__init__.py: -------------------------------------------------------------------------------- 1 | import abc 2 | import logging 3 | from typing import Union 4 | from pySim.apdu import Apdu, Tpdu, CardReset, TpduFilter 5 | 6 | PacketType = Union[Apdu, Tpdu, CardReset] 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | class ApduSource(abc.ABC): 11 | def __init__(self): 12 | self.apdu_filter = TpduFilter(None) 13 | 14 | @abc.abstractmethod 15 | def read_packet(self) -> PacketType: 16 | """Read one packet from the source.""" 17 | 18 | def read(self) -> Union[Apdu, CardReset]: 19 | """Main function to call by the user: Blocking read, returns Apdu or CardReset.""" 20 | apdu = None 21 | # loop until we actually have an APDU to return 22 | while not apdu: 23 | r = self.read_packet() 24 | if not r: 25 | continue 26 | if isinstance(r, Tpdu): 27 | apdu = self.apdu_filter.input_tpdu(r) 28 | elif isinstance(r, Apdu): 29 | apdu = r 30 | elif isinstance(r, CardReset): 31 | apdu = r 32 | else: 33 | raise ValueError('Unknown read_packet() return %s' % r) 34 | return apdu 35 | -------------------------------------------------------------------------------- /pySim/apdu_source/gsmtap.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | # (C) 2022 by Harald Welte 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | from osmocom.gsmtap import GsmtapReceiver 20 | 21 | from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands 22 | from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands 23 | from pySim.apdu.ts_31_102 import ApduCommands as UsimApduCommands 24 | from pySim.apdu.global_platform import ApduCommands as GpApduCommands 25 | 26 | from . import ApduSource, PacketType, CardReset 27 | 28 | ApduCommands = UiccApduCommands + UiccAdmApduCommands + UsimApduCommands + GpApduCommands 29 | 30 | class GsmtapApduSource(ApduSource): 31 | """ApduSource for handling GSMTAP-SIM messages received via UDP, such as 32 | those generated by simtrace2-sniff. Note that *if* you use IP loopback 33 | and localhost addresses (which is the default), you will need to start 34 | this source before starting simtrace2-sniff, as otherwise the latter will 35 | claim the GSMTAP UDP port. 36 | """ 37 | def __init__(self, bind_ip:str='127.0.0.1', bind_port:int=4729): 38 | """Create a UDP socket for receiving GSMTAP-SIM messages. 39 | Args: 40 | bind_ip: IP address to which the socket should be bound (default: 127.0.0.1) 41 | bind_port: UDP port number to which the socket should be bound (default: 4729) 42 | """ 43 | super().__init__() 44 | self.gsmtap = GsmtapReceiver(bind_ip, bind_port) 45 | 46 | def read_packet(self) -> PacketType: 47 | gsmtap_msg, _addr = self.gsmtap.read_packet() 48 | if gsmtap_msg['type'] != 'sim': 49 | raise ValueError('Unsupported GSMTAP type %s' % gsmtap_msg['type']) 50 | sub_type = gsmtap_msg['sub_type'] 51 | if sub_type == 'apdu': 52 | return ApduCommands.parse_cmd_bytes(gsmtap_msg['body']) 53 | if sub_type == 'atr': 54 | # card has been reset 55 | return CardReset(gsmtap_msg['body']) 56 | if sub_type in ['pps_req', 'pps_rsp']: 57 | # simply ignore for now 58 | pass 59 | else: 60 | raise ValueError('Unsupported GSMTAP-SIM sub-type %s' % sub_type) 61 | -------------------------------------------------------------------------------- /pySim/apdu_source/tca_loader_log.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | # (C) 2024 by Harald Welte 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | from pySim.utils import h2b 20 | 21 | from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands 22 | from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands 23 | from pySim.apdu.ts_31_102 import ApduCommands as UsimApduCommands 24 | from pySim.apdu.global_platform import ApduCommands as GpApduCommands 25 | 26 | from . import ApduSource, PacketType, CardReset 27 | 28 | ApduCommands = UiccApduCommands + UiccAdmApduCommands + UsimApduCommands + GpApduCommands 29 | 30 | class TcaLoaderLogApduSource(ApduSource): 31 | """ApduSource for reading log files created by TCALoader.""" 32 | def __init__(self, filename:str): 33 | super().__init__() 34 | self.logfile = open(filename, 'r') 35 | 36 | def read_packet(self) -> PacketType: 37 | command = None 38 | response = None 39 | for line in self.logfile: 40 | if line.startswith('Command'): 41 | command = line.split()[1] 42 | print("Command: '%s'" % command) 43 | pass 44 | elif command and line.startswith('Response'): 45 | response = line.split()[1] 46 | print("Response: '%s'" % response) 47 | return ApduCommands.parse_cmd_bytes(h2b(command) + h2b(response)) 48 | raise StopIteration 49 | -------------------------------------------------------------------------------- /pySim/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ pySim: Exceptions 4 | """ 5 | 6 | # 7 | # Copyright (C) 2009-2010 Sylvain Munaut 8 | # Copyright (C) 2021 Harald Welte 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 . 22 | # 23 | 24 | 25 | class NoCardError(Exception): 26 | """No card was found in the reader.""" 27 | 28 | 29 | class ProtocolError(Exception): 30 | """Some kind of protocol level error interfacing with the card.""" 31 | 32 | 33 | class ReaderError(Exception): 34 | """Some kind of general error with the card reader.""" 35 | 36 | 37 | class SwMatchError(Exception): 38 | """Raised when an operation specifies an expected SW but the actual SW from 39 | the card doesn't match.""" 40 | 41 | def __init__(self, sw_actual: str, sw_expected: str, rs=None): 42 | """ 43 | Args: 44 | sw_actual : the SW we actually received from the card (4 hex digits) 45 | sw_expected : the SW we expected to receive from the card (4 hex digits) 46 | rs : interpreter class to convert SW to string 47 | """ 48 | self.sw_actual = sw_actual 49 | self.sw_expected = sw_expected 50 | self.rs = rs 51 | 52 | @property 53 | def description(self): 54 | if self.rs and self.rs.lchan[0]: 55 | r = self.rs.lchan[0].interpret_sw(self.sw_actual) 56 | if r: 57 | return "%s - %s" % (r[0], r[1]) 58 | return '' 59 | 60 | def __str__(self): 61 | description = self.description 62 | if description: 63 | description = ": " + description 64 | else: 65 | description = "." 66 | return "SW match failed! Expected %s and got %s%s" % (self.sw_expected, self.sw_actual, description) 67 | -------------------------------------------------------------------------------- /pySim/global_platform/install_param.py: -------------------------------------------------------------------------------- 1 | # GlobalPlatform install parameter generator 2 | # 3 | # (C) 2024 by Sysmocom s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | from osmocom.construct import * 21 | from osmocom.utils import * 22 | from osmocom.tlv import * 23 | 24 | class AppSpecificParams(BER_TLV_IE, tag=0xC9): 25 | # GPD_SPE_013, table 11-49 26 | _construct = GreedyBytes 27 | 28 | class VolatileMemoryQuota(BER_TLV_IE, tag=0xC7): 29 | # GPD_SPE_013, table 11-49 30 | _construct = StripHeaderAdapter(GreedyBytes, 4, steps = [2,4]) 31 | 32 | class NonVolatileMemoryQuota(BER_TLV_IE, tag=0xC8): 33 | # GPD_SPE_013, table 11-49 34 | _construct = StripHeaderAdapter(GreedyBytes, 4, steps = [2,4]) 35 | 36 | class StkParameter(BER_TLV_IE, tag=0xCA): 37 | # GPD_SPE_013, table 11-49 38 | # ETSI TS 102 226, section 8.2.1.3.2.1 39 | _construct = GreedyBytes 40 | 41 | class SystemSpecificParams(BER_TLV_IE, tag=0xEF, nested=[VolatileMemoryQuota, NonVolatileMemoryQuota, StkParameter]): 42 | # GPD_SPE_013 v1.1 Table 6-5 43 | pass 44 | 45 | class InstallParams(TLV_IE_Collection, nested=[AppSpecificParams, SystemSpecificParams]): 46 | # GPD_SPE_013, table 11-49 47 | pass 48 | 49 | def gen_install_parameters(non_volatile_memory_quota:int, volatile_memory_quota:int, stk_parameter:str): 50 | 51 | # GPD_SPE_013, table 11-49 52 | 53 | #Mandatory 54 | install_params = InstallParams() 55 | install_params_dict = [{'app_specific_params': None}] 56 | 57 | #Conditional 58 | if non_volatile_memory_quota and volatile_memory_quota and stk_parameter: 59 | system_specific_params = [] 60 | #Optional 61 | if non_volatile_memory_quota: 62 | system_specific_params += [{'non_volatile_memory_quota': non_volatile_memory_quota}] 63 | #Optional 64 | if volatile_memory_quota: 65 | system_specific_params += [{'volatile_memory_quota': volatile_memory_quota}] 66 | #Optional 67 | if stk_parameter: 68 | system_specific_params += [{'stk_parameter': stk_parameter}] 69 | install_params_dict += [{'system_specific_params': system_specific_params}] 70 | 71 | install_params.from_dict(install_params_dict) 72 | return b2h(install_params.to_bytes()) 73 | -------------------------------------------------------------------------------- /pySim/iso7816_4.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Utilities / Functions related to ISO 7816-4 3 | 4 | (C) 2022 by Harald Welte 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | """ 19 | 20 | from construct import GreedyString 21 | from osmocom.tlv import * 22 | from osmocom.construct import * 23 | 24 | # Table 91 + Section 8.2.1.2 25 | class ApplicationId(BER_TLV_IE, tag=0x4f): 26 | _construct = GreedyBytes 27 | 28 | # Table 91 29 | class ApplicationLabel(BER_TLV_IE, tag=0x50): 30 | _construct = GreedyBytes 31 | 32 | # Table 91 + Section 5.3.1.2 33 | class FileReference(BER_TLV_IE, tag=0x51): 34 | _construct = GreedyBytes 35 | 36 | # Table 91 37 | class CommandApdu(BER_TLV_IE, tag=0x52): 38 | _construct = GreedyBytes 39 | 40 | # Table 91 41 | class DiscretionaryData(BER_TLV_IE, tag=0x53): 42 | _construct = GreedyBytes 43 | 44 | # Table 91 45 | class DiscretionaryTemplate(BER_TLV_IE, tag=0x73): 46 | _construct = GreedyBytes 47 | 48 | # Table 91 + RFC1738 / RFC2396 49 | class URL(BER_TLV_IE, tag=0x5f50): 50 | _construct = GreedyString('ascii') 51 | 52 | # Table 91 53 | class ApplicationRelatedDOSet(BER_TLV_IE, tag=0x61): 54 | _construct = GreedyBytes 55 | 56 | # Section 8.2.1.3 Application Template 57 | class ApplicationTemplate(BER_TLV_IE, tag=0x61, nested=[ApplicationId, ApplicationLabel, FileReference, 58 | CommandApdu, DiscretionaryData, DiscretionaryTemplate, URL, 59 | ApplicationRelatedDOSet]): 60 | pass 61 | -------------------------------------------------------------------------------- /pySim/jsonpath.py: -------------------------------------------------------------------------------- 1 | """JSONpath utility functions as needed within pysim. 2 | 3 | As pySim-sell has the ability to represent SIM files as JSON strings, 4 | adding JSONpath allows us to conveniently modify individual sub-fields 5 | of a file or record in its JSON representation. 6 | """ 7 | 8 | import jsonpath_ng 9 | 10 | # (C) 2021 by Harald Welte 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 2 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program. If not, see . 24 | 25 | 26 | def js_path_find(js_dict, js_path): 27 | """Find/Match a JSON path within a given JSON-serializable dict. 28 | Args: 29 | js_dict : JSON-serializable dict to operate on 30 | js_path : JSONpath string 31 | Returns: Result of the JSONpath expression 32 | """ 33 | jsonpath_expr = jsonpath_ng.parse(js_path) 34 | return jsonpath_expr.find(js_dict) 35 | 36 | 37 | def js_path_modify(js_dict, js_path, new_val): 38 | """Find/Match a JSON path within a given JSON-serializable dict. 39 | Args: 40 | js_dict : JSON-serializable dict to operate on 41 | js_path : JSONpath string 42 | new_val : New value for field in js_dict at js_path 43 | """ 44 | jsonpath_expr = jsonpath_ng.parse(js_path) 45 | jsonpath_expr.find(js_dict) 46 | jsonpath_expr.update(js_dict, new_val) 47 | -------------------------------------------------------------------------------- /pySim/legacy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/pySim/legacy/__init__.py -------------------------------------------------------------------------------- /pySim/legacy/ts_31_103.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Various constants from 3GPP TS 31.103 V16.1.0 used by *legacy* code only 5 | """ 6 | 7 | # Copyright (C) 2020 Supreeth Herle 8 | # Copyright (C) 2021 Harald Welte 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 . 22 | 23 | EF_ISIM_ADF_map = { 24 | 'IST': '6F07', 25 | 'IMPI': '6F02', 26 | 'DOMAIN': '6F03', 27 | 'IMPU': '6F04', 28 | 'AD': '6FAD', 29 | 'ARR': '6F06', 30 | 'PCSCF': '6F09', 31 | 'GBAP': '6FD5', 32 | 'GBANL': '6FD7', 33 | 'NAFKCA': '6FDD', 34 | 'UICCIARI': '6FE7', 35 | 'SMS': '6F3C', 36 | 'SMSS': '6F43', 37 | 'SMSR': '6F47', 38 | 'SMSP': '6F42', 39 | 'FromPreferred': '6FF7', 40 | 'IMSConfigData': '6FF8', 41 | 'XCAPConfigData': '6FFC', 42 | 'WebRTCURI': '6FFA' 43 | } 44 | -------------------------------------------------------------------------------- /pySim/pprint.py: -------------------------------------------------------------------------------- 1 | import pprint 2 | from pprint import PrettyPrinter 3 | from functools import singledispatch, wraps 4 | from typing import get_type_hints 5 | 6 | from pySim.utils import b2h 7 | 8 | def common_container_checks(f): 9 | type_ = get_type_hints(f)['object'] 10 | base_impl = type_.__repr__ 11 | empty_repr = repr(type_()) # {}, [], () 12 | too_deep_repr = f'{empty_repr[0]}...{empty_repr[-1]}' # {...}, [...], (...) 13 | @wraps(f) 14 | def wrapper(object, context, maxlevels, level): 15 | if type(object).__repr__ is not base_impl: # subclassed repr 16 | return repr(object) 17 | if not object: # empty, short-circuit 18 | return empty_repr 19 | if maxlevels and level >= maxlevels: # exceeding the max depth 20 | return too_deep_repr 21 | oid = id(object) 22 | if oid in context: # self-reference 23 | return pprint._recursion(object) 24 | context[oid] = 1 25 | result = f(object, context, maxlevels, level) 26 | del context[oid] 27 | return result 28 | return wrapper 29 | 30 | @singledispatch 31 | def saferepr(object, context, maxlevels, level): 32 | return repr(object) 33 | 34 | @saferepr.register 35 | def _handle_bytes(object: bytes, *args): 36 | if len(object) <= 40: 37 | return '"%s"' % b2h(object) 38 | else: 39 | return '"%s...%s"' % (b2h(object[:20]), b2h(object[-20:])) 40 | 41 | @saferepr.register 42 | @common_container_checks 43 | def _handle_dict(object: dict, context, maxlevels, level): 44 | level += 1 45 | contents = [ 46 | f'{saferepr(k, context, maxlevels, level)}: ' 47 | f'{saferepr(v, context, maxlevels, level)}' 48 | for k, v in sorted(object.items(), key=pprint._safe_tuple) 49 | ] 50 | return f'{{{", ".join(contents)}}}' 51 | 52 | @saferepr.register 53 | @common_container_checks 54 | def _handle_list(object: list, context, maxlevels, level): 55 | level += 1 56 | contents = [ 57 | f'{saferepr(v, context, maxlevels, level)}' 58 | for v in object 59 | ] 60 | return f'[{", ".join(contents)}]' 61 | 62 | @saferepr.register 63 | @common_container_checks 64 | def _handle_tuple(object: tuple, context, maxlevels, level): 65 | level += 1 66 | if len(object) == 1: 67 | return f'({saferepr(object[0], context, maxlevels, level)},)' 68 | contents = [ 69 | f'{saferepr(v, context, maxlevels, level)}' 70 | for v in object 71 | ] 72 | return f'({", ".join(contents)})' 73 | 74 | class HexBytesPrettyPrinter(PrettyPrinter): 75 | def format(self, *args): 76 | # it doesn't matter what the boolean values are here 77 | return saferepr(*args), True, False 78 | -------------------------------------------------------------------------------- /pySim/secure_channel.py: -------------------------------------------------------------------------------- 1 | # Generic code related to Secure Channel processing 2 | # 3 | # (C) 2023-2024 by Harald Welte 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | import abc 19 | from osmocom.utils import b2h, h2b, Hexstr 20 | 21 | from pySim.utils import ResTuple 22 | 23 | class SecureChannel(abc.ABC): 24 | @abc.abstractmethod 25 | def wrap_cmd_apdu(self, apdu: bytes) -> bytes: 26 | """Wrap Command APDU according to specific Secure Channel Protocol.""" 27 | pass 28 | 29 | @abc.abstractmethod 30 | def unwrap_rsp_apdu(self, sw: bytes, rsp_apdu: bytes) -> bytes: 31 | """UnWrap Response-APDU according to specific Secure Channel Protocol.""" 32 | pass 33 | 34 | def send_apdu_wrapper(self, send_fn: callable, pdu: Hexstr, *args, **kwargs) -> ResTuple: 35 | """Wrapper function to wrap command APDU and unwrap repsonse APDU around send_apdu callable.""" 36 | pdu_wrapped = b2h(self.wrap_cmd_apdu(h2b(pdu))) 37 | res, sw = send_fn(pdu_wrapped, *args, **kwargs) 38 | res_unwrapped = b2h(self.unwrap_rsp_apdu(h2b(sw), h2b(res))) 39 | return res_unwrapped, sw 40 | -------------------------------------------------------------------------------- /pySim/ts_31_104.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Support for 3GPP TS 31.104 V17.0.0 5 | """ 6 | 7 | # Copyright (C) 2023 Harald Welte 8 | # 9 | # This program is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | # 22 | 23 | from osmocom.utils import * 24 | from osmocom.tlv import * 25 | from pySim.filesystem import * 26 | from pySim.ts_31_102 import ADF_USIM 27 | from pySim.ts_51_011 import EF_IMSI, EF_AD 28 | import pySim.ts_102_221 29 | from pySim.ts_102_221 import EF_ARR 30 | 31 | 32 | class ADF_HPSIM(CardADF): 33 | def __init__(self, aid='a000000087100A', has_fs=True, name='ADF.HPSIM', fid=None, sfid=None, 34 | desc='HPSIM Application'): 35 | super().__init__(aid=aid, has_fs=has_fs, fid=fid, sfid=sfid, name=name, desc=desc) 36 | 37 | files = [ 38 | EF_ARR(fid='6f06', sfid=0x06), 39 | EF_IMSI(fid='6f07', sfid=0x07), 40 | EF_AD(fid='6fad', sfid=0x03), 41 | ] 42 | self.add_files(files) 43 | # add those commands to the general commands of a TransparentEF 44 | self.shell_commands += [ADF_USIM.AddlShellCommands()] 45 | 46 | def decode_select_response(self, data_hex): 47 | return pySim.ts_102_221.CardProfileUICC.decode_select_response(data_hex) 48 | 49 | 50 | # TS 31.104 Section 7.1 51 | sw_hpsim = { 52 | 'Security management': { 53 | '9862': 'Authentication error, incorrect MAC', 54 | } 55 | } 56 | 57 | 58 | class CardApplicationHPSIM(CardApplication): 59 | def __init__(self): 60 | super().__init__('HPSIM', adf=ADF_HPSIM(), sw=sw_hpsim) 61 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyscard 2 | pyserial 3 | pytlv 4 | cmd2>=1.5 5 | jsonpath-ng 6 | construct>=2.10.70 7 | bidict 8 | pyosmocom>=0.0.9 9 | pyyaml>=5.1 10 | termcolor 11 | colorlog 12 | pycryptodomex 13 | cryptography 14 | git+https://github.com/osmocom/asn1tools 15 | packaging 16 | git+https://github.com/hologram-io/smpp.pdu 17 | smpp.twisted3 @ git+https://github.com/jookies/smpp.twisted 18 | -------------------------------------------------------------------------------- /scripts/deactivate-5g.script: -------------------------------------------------------------------------------- 1 | # script to be used with pySim-shell.py which is part of the Osmocom pysim package, 2 | # found at https://osmocom.org/projects/pysim/wiki 3 | set echo true 4 | 5 | # this script will deactivate all 5G related services and files. This can be used 6 | # in case you do not wish to use any 5G services, or you do not wish to configure 7 | # the 5G specific files on the USIM card. The card will then behave like a 3G USIM 8 | # without any 5G capability, using the default fall-back mechanisms specified by 3GPP. 9 | 10 | # TODO: add your card-specific ADM pin at the end of the verify_adm line below 11 | verify_adm 12 | 13 | # deactivate any 5G related services in EF.UST 14 | select ADF.USIM 15 | select EF.UST 16 | ust_service_deactivate 122 17 | ust_service_deactivate 123 18 | ust_service_deactivate 124 19 | ust_service_deactivate 125 20 | ust_service_deactivate 126 21 | ust_service_deactivate 127 22 | ust_service_deactivate 129 23 | ust_service_deactivate 130 24 | ust_service_deactivate 132 25 | ust_service_deactivate 133 26 | ust_service_deactivate 134 27 | ust_service_deactivate 135 28 | 29 | # deactivate all files in EF.5GS 30 | select ADF.USIM 31 | select DF.5GS 32 | 33 | select EF.5GAUTHKEYS 34 | deactivate_file 35 | 36 | select EF.5GS3GPPLOCI 37 | deactivate_file 38 | 39 | select EF.5GSN3GPPNSC 40 | deactivate_file 41 | 42 | select EF.5GSN3GPPLOCI 43 | deactivate_file 44 | 45 | select EF.5GS3GPPNSC 46 | deactivate_file 47 | 48 | # only exists on sysmoISIM-SJA2v2 49 | select EF.OPL5G 50 | deactivate_file 51 | 52 | select EF.Routing_Indicator 53 | deactivate_file 54 | 55 | select EF.SUCI_Calc_Info 56 | deactivate_file 57 | 58 | select EF.SUPI_NAI 59 | deactivate_file 60 | 61 | # only exists on sysmoISIM-SJA2v2 62 | select EF.TN3GPPSNN 63 | deactivate_file 64 | 65 | select EF.UAC_AIC 66 | deactivate_file 67 | 68 | # only exists on sysmoISIM-SJA2v2 69 | select EF.URSP 70 | deactivate_file 71 | -------------------------------------------------------------------------------- /scripts/deactivate-ims.script: -------------------------------------------------------------------------------- 1 | # script to be used with pySim-shell.py which is part of the Osmocom pysim package, 2 | # found at https://osmocom.org/projects/pysim/wiki 3 | set echo true 4 | 5 | # this script will deactivate all IMS related services and files. This can be used 6 | # in case you do not wish to use any IMS services, or you do not wish to configure 7 | # the IMS specific files on the USIM/ISIM cards. The card will then behave like a 3G USIM 8 | # without any IMS capability, using the default fall-back mechanisms specified by 3GPP. 9 | 10 | # TODO: add your card-specific ADM pin at the end of the verify_adm line below 11 | verify_adm 12 | 13 | # deactivate any IMS related services in EF.UST 14 | select ADF.USIM 15 | select EF.UST 16 | ust_service_deactivate 93 17 | ust_service_deactivate 95 18 | ust_service_deactivate 104 19 | ust_service_deactivate 105 20 | ust_service_deactivate 106 21 | ust_service_deactivate 107 22 | ust_service_deactivate 108 23 | ust_service_deactivate 109 24 | ust_service_deactivate 110 25 | ust_service_deactivate 112 26 | ust_service_deactivate 114 27 | ust_service_deactivate 115 28 | ust_service_deactivate 118 29 | ust_service_deactivate 120 30 | ust_service_deactivate 131 31 | ust_service_deactivate 134 32 | 33 | # deactivate all IMS related files in ADF.USIM 34 | select ADF.USIM 35 | 36 | select EF.UICCIARI 37 | deactivate_file 38 | 39 | select EF.ePDGId 40 | deactivate_file 41 | 42 | select EF.ePDGSelection 43 | deactivate_file 44 | 45 | select EF.ePDGIdEm 46 | deactivate_file 47 | 48 | select EF.ePDGSelectionEm 49 | deactivate_file 50 | 51 | select EF.FromPreferred 52 | deactivate_file 53 | 54 | select EF.IMSConfigData 55 | deactivate_file 56 | 57 | select EF.3GPPPSDATAOFF 58 | deactivate_file 59 | 60 | select EF.3GPPPSDATAOFFservicelist 61 | deactivate_file 62 | 63 | select EF.XCAPConfigData 64 | deactivate_file 65 | 66 | select EF.MuDMiDConfigData 67 | deactivate_file 68 | 69 | echo "Please make sure to manually disable the ISIM applet as described in the end of the script" 70 | # you can currently only manually do this via GlobalPlatformPro or some other tool using 71 | # java -jar ./gp.jar --key-enc KIC1 --key-mac KID1 --key-dek KIK1 --lock-applet A0000000871004FFFFFFFF8907090000 72 | # (substituting KIC1/KID1/KIK1 with the card-specific keys, of course) 73 | 74 | quit 75 | -------------------------------------------------------------------------------- /scripts/sysmoISIM-SJA2/dump-auth-cfg.pysim: -------------------------------------------------------------------------------- 1 | # script to be used with pySim-shell.py which is part of the Osmocom pysim package, 2 | # found at https://osmocom.org/projects/pysim/wiki 3 | set echo true 4 | 5 | # TODO: add your card-specific ADM pin at the end of the verify_adm line below 6 | verify_adm 7 | 8 | select DF.SYSTEM 9 | 10 | # Milenage configuration (constants) 11 | select EF.MILENAGE_CFG 12 | read_binary_decoded 13 | 14 | # 2G authentication kay / algorithm 15 | select EF.SIM_AUTH_KEY 16 | read_binary_decoded 17 | 18 | # OTA keys 19 | #select EF.0348_KEY 20 | #read_records_decoded 21 | 22 | select ADF.USIM 23 | # USIM authentication key / algoritmh in 3G security context 24 | select EF.USIM_AUTH_KEY 25 | read_binary_decoded 26 | # USIM authentication key / algorithm in 2G security context 27 | select EF.USIM_AUTH_KEY_2G 28 | read_binary_decoded 29 | # USIM SQN numbers 30 | select EF.USIM_SQN 31 | read_binary_decoded 32 | 33 | select ADF.ISIM 34 | # ISIM authentication key / algorithm 35 | select EF.ISIM_AUTH_KEY 36 | read_binary_decoded 37 | # ISIM SQN numbers 38 | select EF.ISIM_SQN 39 | read_binary_decoded 40 | 41 | quit 42 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | long_description = file: README.md 3 | long_description_content_type = text/markdown -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name='pySim', 5 | version='1.0', 6 | packages=[ 7 | 'pySim', 8 | 'pySim.apdu', 9 | 'pySim.apdu_source', 10 | 'pySim.esim', 11 | 'pySim.esim.saip', 12 | 'pySim.global_platform', 13 | 'pySim.legacy', 14 | 'pySim.transport', 15 | ], 16 | url='https://osmocom.org/projects/pysim/wiki', 17 | license='GPLv2', 18 | author_email='simtrace@lists.osmocom.org', 19 | description='Tools related to SIM/USIM/ISIM cards', 20 | install_requires=[ 21 | "pyscard", 22 | "pyserial", 23 | "pytlv", 24 | "cmd2 >= 1.5.0", 25 | "jsonpath-ng", 26 | "construct >= 2.10.70", 27 | "bidict", 28 | "pyosmocom >= 0.0.9", 29 | "pyyaml >= 5.1", 30 | "termcolor", 31 | "colorlog", 32 | "pycryptodomex", 33 | "packaging", 34 | "smpp.pdu @ git+https://github.com/hologram-io/smpp.pdu", 35 | "asn1tools", 36 | "smpp.twisted3 @ git+https://github.com/jookies/smpp.twisted", 37 | ], 38 | scripts=[ 39 | 'pySim-prog.py', 40 | 'pySim-read.py', 41 | 'pySim-shell.py', 42 | 'pySim-trace.py', 43 | 'pySim-smpp2sim.py', 44 | ], 45 | package_data={ 46 | 'pySim.esim': 47 | [ 48 | 'asn1/rsp/*.asn', 49 | 'asn1/saip/*.asn', 50 | ], 51 | }, 52 | ) 53 | -------------------------------------------------------------------------------- /smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICUTCCAfigAwIBAgIJALh086v6bETTMAoGCCqGSM49BAMCMEQxEDAOBgNVBAMM 3 | B1Rlc3QgQ0kxETAPBgNVBAsMCFRFU1RDRVJUMRAwDgYDVQQKDAdSU1BURVNUMQsw 4 | CQYDVQQGEwJJVDAgFw0yMDA0MDEwODI3NTFaGA8yMDU1MDQwMTA4Mjc1MVowRDEQ 5 | MA4GA1UEAwwHVGVzdCBDSTERMA8GA1UECwwIVEVTVENFUlQxEDAOBgNVBAoMB1JT 6 | UFRFU1QxCzAJBgNVBAYTAklUMFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABCeH 7 | tNVu2CSp5r4E4Yh/a5i6/rjHY/UoN/cBE+k2Tt2+E5vAx95+Fo8eXNDBhTT8UGTm 8 | T2htxTMnyn8dzqhaKZSjgc8wgcwwHQYDVR0OBBYEFMC8cLo2kp1DtGf/V1cFMOV6 9 | uPzYMA8GA1UdEwEB/wQFMAMBAf8wFwYDVR0gAQH/BA0wCzAJBgdngRIBAgEAMA4G 10 | A1UdDwEB/wQEAwIBBjAOBgNVHREEBzAFiAOINwEwYQYDVR0fBFowWDAqoCigJoYk 11 | aHR0cDovL2NpLnRlc3QuZXhhbXBsZS5jb20vQ1JMLUEuY3JsMCqgKKAmhiRodHRw 12 | Oi8vY2kudGVzdC5leGFtcGxlLmNvbS9DUkwtQi5jcmwwCgYIKoZIzj0EAwIDRwAw 13 | RAIgPYrf0CKl0FBMUaHx5xS1duTDbQ4wBZN3qKBeNniuux0CIHBek2vLfoANAdtt 14 | f5u5Ce6DVC2oIfpn5UnS24F3oMqM 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/CertificateIssuer/CERT_CI_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICUDCCAfegAwIBAgIJALh086v6bETTMAoGCCqGSM49BAMCMEQxEDAOBgNVBAMM 3 | B1Rlc3QgQ0kxETAPBgNVBAsMCFRFU1RDRVJUMRAwDgYDVQQKDAdSU1BURVNUMQsw 4 | CQYDVQQGEwJJVDAgFw0yMDA0MDEwODI3NTFaGA8yMDU1MDQwMTA4Mjc1MVowRDEQ 5 | MA4GA1UEAwwHVGVzdCBDSTERMA8GA1UECwwIVEVTVENFUlQxEDAOBgNVBAoMB1JT 6 | UFRFU1QxCzAJBgNVBAYTAklUMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElAZX 7 | pnPcKI+J1S6opHcEmSeR+cNLADbmM+LQy6lFTWXbMusXmBeZ0vJDiO4rlcEJRUbJ 8 | eQHOrrqWUJGaLiDSKaOBzzCBzDAdBgNVHQ4EFgQU9UFyvfmKldZcvriKOKHBHYAK 9 | hcMwDwYDVR0TAQH/BAUwAwEB/zAXBgNVHSABAf8EDTALMAkGB2eBEgECAQAwDgYD 10 | VR0PAQH/BAQDAgEGMA4GA1UdEQQHMAWIA4g3ATBhBgNVHR8EWjBYMCqgKKAmhiRo 11 | dHRwOi8vY2kudGVzdC5leGFtcGxlLmNvbS9DUkwtQS5jcmwwKqAooCaGJGh0dHA6 12 | Ly9jaS50ZXN0LmV4YW1wbGUuY29tL0NSTC1CLmNybDAKBggqhkjOPQQDAgNHADBE 13 | AiBSdWqvwgIKbOy/Ll88IIklEP8pdR0pi9OwFdlgWk/mfQIgV5goNuTSBd3S5sPB 14 | tFWTf2tuSTtgL9G2bDV0iak192s= 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /smdpp-data/certs/CertificateIssuer/CI-csr.cnf: -------------------------------------------------------------------------------- 1 | #openssl x509 extfile params 2 | extensions = extend 3 | # This prevent the user to be prompted for values 4 | prompt = no 5 | 6 | distinguished_name = dn-param 7 | [dn-param] # DN fields 8 | CN = Test CI 9 | OU = TESTCERT 10 | O = RSPTEST 11 | C = IT 12 | 13 | # Extensions for the Test CI 14 | [extend] # openssl extensions 15 | subjectKeyIdentifier = hash 16 | 17 | basicConstraints = critical, CA:true 18 | 19 | certificatePolicies=critical,2.23.146.1.2.1.0 20 | 21 | keyUsage =critical, keyCertSign, cRLSign 22 | 23 | subjectAltName = RID:2.999.1 24 | 25 | crlDistributionPoints=URI:http://ci.test.example.com/CRL-A.crl, URI:http://ci.test.example.com/CRL-B.crl -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPauth/CERT_S_SM_DP2auth_ECDSA_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPauth/CERT_S_SM_DPauth_ECDSA_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABC7uB8ltAFvlGV95rR2tzR03jKMJ 3 | XkT3LupBDwjHVhIskGPJZbf8hSnAyk6bT2WWnCg8ZWNkV4dxGPbRFy1qI2U= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/PK_S_SM_DP2auth_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKy6bRdNRwJr0DpFDg6GQOEfyYH3m 3 | DverJcQOA/jbtlCOFFdQjCvgAXNH7Pob+fd159B+gF5S4ZiLe1hacRGuMw== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABCVdfa8A74Qddvp6Y9Y+s/5sn3BJ 3 | LTgZI/j4vXsk88WtFo6+OwndgPKef/0kpNG+dH+DI+RykoOW3engFRzquhg= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/PK_S_SM_DPauth_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAETf7U9GlHkb8Wlc6gMHo1tBgBlpU4 3 | e7dbfSRHtrUgnwRFrk5eUhzROIjXX+B8hYAiKuINuqwdd812MEmTQhvXOQ== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgkrJAMDAggBAQc= 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHgCAQEEIAwXNVwBHQ/o19rdY/GXhc9sUcvNRmroi+j4G8EFiEb2oAsGCSskAwMC 6 | CAEBB6FEA0IABC7uB8ltAFvlGV95rR2tzR03jKMJXkT3LupBDwjHVhIskGPJZbf8 7 | hSnAyk6bT2WWnCg8ZWNkV4dxGPbRFy1qI2U= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/SK_S_SM_DP2auth_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIJwyoJXUiELZ/6QE9xJRKqLFQloaJjhqtqFF1YEeA5FBoAoGCCqGSM49 6 | AwEHoUQDQgAEKy6bRdNRwJr0DpFDg6GQOEfyYH3mDverJcQOA/jbtlCOFFdQjCvg 7 | AXNH7Pob+fd159B+gF5S4ZiLe1hacRGuMw== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgkrJAMDAggBAQc= 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHgCAQEEIJP7M9BYTzSbB/i10q+T18PjVLNJo7kTUC5qvAcOTUkpoAsGCSskAwMC 6 | CAEBB6FEA0IABCVdfa8A74Qddvp6Y9Y+s/5sn3BJLTgZI/j4vXsk88WtFo6+Ownd 7 | gPKef/0kpNG+dH+DI+RykoOW3engFRzquhg= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/SK_S_SM_DPauth_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIAp8wcJE5gxSzVt4B6uMNgwmUkYBUH3KvF3VmLWmFtXVoAoGCCqGSM49 6 | AwEHoUQDQgAETf7U9GlHkb8Wlc6gMHo1tBgBlpU4e7dbfSRHtrUgnwRFrk5eUhzR 7 | OIjXX+B8hYAiKuINuqwdd812MEmTQhvXOQ== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPauth/data_sig.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPauth/data_sig.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPpb/CERT_S_SM_DP2pb_ECDSA_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPpb/CERT_S_SM_DPpb_ECDSA_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABHNhhV5ZAmSyUscaYGKgIeJ7Rvdg 3 | uBOCBqf3RCDvi8Vai5iNFlj51w06LYSAqt9k5ixNcSfeWgorkXqUP0R0qt0= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/PK_S_SM_DP2pb_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPi11oQYiEhbCruj61YT3eWM8+URo 3 | G17HWpZlP19AHEdq451UbAMtMtAHCnuG5dzrqt3zHKXCdmwZa9ebwhoBgA== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABIkyU+zJTFHfT+5uDbCVHPxlYnSB 3 | tUGOVXBp9If6oVRmpcuOEMwrOAmc8qkp9/gtrAZRJrcdBkCWHbf5GknpVhI= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/PK_S_SM_DPpb_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEEwq49At75yXkmGnxnEAdrlwch0J 3 | VaJkSuBfrkvCMU5dwJ9r8BGAJhZTQuISMYd142XztXMlNzBmuZBuC9E4jQ== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgkrJAMDAggBAQc= 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHgCAQEEIJyuLhpWB6nVeDgu7pMuJR9SME+G7rHxcIzb08B74s09oAsGCSskAwMC 6 | CAEBB6FEA0IABHNhhV5ZAmSyUscaYGKgIeJ7RvdguBOCBqf3RCDvi8Vai5iNFlj5 7 | 1w06LYSAqt9k5ixNcSfeWgorkXqUP0R0qt0= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/SK_S_SM_DP2pb_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIGaTEUljnbqsHcPTBsWL0t/SL3O/Y6yGMZgykLV/kJNFoAoGCCqGSM49 6 | AwEHoUQDQgAEPi11oQYiEhbCruj61YT3eWM8+URoG17HWpZlP19AHEdq451UbAMt 7 | MtAHCnuG5dzrqt3zHKXCdmwZa9ebwhoBgA== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgkrJAMDAggBAQc= 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHgCAQEEIHX/Mi9BZhba4aSE73HUh0+w3zKV/TXCy6SJ+7K7nHv2oAsGCSskAwMC 6 | CAEBB6FEA0IABIkyU+zJTFHfT+5uDbCVHPxlYnSBtUGOVXBp9If6oVRmpcuOEMwr 7 | OAmc8qkp9/gtrAZRJrcdBkCWHbf5GknpVhI= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPpb/SK_S_SM_DPpb_ECDSA_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEINzWlLd4lX6Omt292UQz6e+Pc9EeSRxI1CWjipSRvTvtoAoGCCqGSM49 6 | AwEHoUQDQgAEEEwq49At75yXkmGnxnEAdrlwch0JVaJkSuBfrkvCMU5dwJ9r8BGA 7 | JhZTQuISMYd142XztXMlNzBmuZBuC9E4jQ== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.csr.cnf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | prompt = no 3 | distinguished_name = req_distinguished_name 4 | 5 | [ req_distinguished_name ] 6 | O = ACME 7 | 8 | # shall be aligned with SGP.23 value #TEST_DP_ADDRESS2 9 | CN = testsmdpplus2.example.com 10 | 11 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP2_TLS.ext.cnf: -------------------------------------------------------------------------------- 1 | ###################################################################################################################################################################### 2 | # Extensions for a DPTLS 3 | keyUsage = critical, digitalSignature 4 | extendedKeyUsage = critical, serverAuth, clientAuth 5 | certificatePolicies = 2.23.146.1.2.1.3 6 | subjectKeyIdentifier = hash 7 | authorityKeyIdentifier = keyid:always,issuer 8 | 9 | # RID shall be aligend with SGP.23 value SM-DP+OID2 10 | # DNS name shall be aligned with SGP.23 value #TEST_DP_ADDRESS2 11 | subjectAltName = DNS:testsmdpplus2.example.com, RID:2.999.12 12 | 13 | crlDistributionPoints=URI:http://ci.test.example.com/CRL-A.crl, URI:http://ci.test.example.com/CRL-B.crl 14 | 15 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.csr.cnf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | prompt = no 3 | distinguished_name = req_distinguished_name 4 | 5 | [ req_distinguished_name ] 6 | O = ACME 7 | 8 | # shall be aligned with SGP.23 value #TEST_DP_ADDRESS4 9 | CN = testsmdpplus4.example.com 10 | 11 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP4_TLS.ext.cnf: -------------------------------------------------------------------------------- 1 | ###################################################################################################################################################################### 2 | # Extensions for a DPTLS 3 | keyUsage = critical, digitalSignature 4 | extendedKeyUsage = critical, serverAuth, clientAuth 5 | certificatePolicies = 2.23.146.1.2.1.3 6 | subjectKeyIdentifier = hash 7 | authorityKeyIdentifier = keyid:always,issuer 8 | 9 | # RID shall be aligend with SGP.23 value SM-DP+OID4 10 | # DNS name shall be aligned with SGP.23 value #TEST_DP_ADDRESS4 11 | subjectAltName = DNS:testsmdpplus4.example.com, RID:2.999.14 12 | 13 | crlDistributionPoints=URI:http://ci.test.example.com/CRL-A.crl, URI:http://ci.test.example.com/CRL-B.crl 14 | 15 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.csr.cnf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | prompt = no 3 | distinguished_name = req_distinguished_name 4 | 5 | [ req_distinguished_name ] 6 | O = ACME 7 | 8 | # shall be aligned with SGP.23 value #TEST_DP_ADDRESS8 9 | CN = testsmdpplus8.example.com 10 | 11 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP8_TLS.ext.cnf: -------------------------------------------------------------------------------- 1 | ###################################################################################################################################################################### 2 | # Extensions for a DPTLS 3 | keyUsage = critical, digitalSignature 4 | extendedKeyUsage = critical, serverAuth, clientAuth 5 | certificatePolicies = 2.23.146.1.2.1.3 6 | subjectKeyIdentifier = hash 7 | authorityKeyIdentifier = keyid:always,issuer 8 | 9 | # RID shall be aligend with SGP.23 value SM-DP+OID8 10 | # DNS name shall be aligned with SGP.23 value #TEST_DP_ADDRESS8 11 | subjectAltName = DNS:testsmdpplus8.example.com, RID:2.999.18 12 | 13 | crlDistributionPoints=URI:http://ci.test.example.com/CRL-A.crl, URI:http://ci.test.example.com/CRL-B.crl 14 | 15 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.csr.cnf: -------------------------------------------------------------------------------- 1 | [ req ] 2 | prompt = no 3 | distinguished_name = req_distinguished_name 4 | 5 | [ req_distinguished_name ] 6 | O = ACME 7 | 8 | # shall be aligned with SGP.23 value #TEST_DP_ADDRESS1 9 | CN = testsmdpplus1.example.com 10 | 11 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS.ext.cnf: -------------------------------------------------------------------------------- 1 | ###################################################################################################################################################################### 2 | # Extensions for a DPTLS 3 | keyUsage = critical, digitalSignature 4 | extendedKeyUsage = critical, serverAuth, clientAuth 5 | certificatePolicies = 2.23.146.1.2.1.3 6 | subjectKeyIdentifier = hash 7 | authorityKeyIdentifier = keyid:always,issuer 8 | 9 | # RID shall be aligend with SGP.23 value SM-DP+OID 10 | # DNS name shall be aligned with SGP.23 value #TEST_DP_ADDRESS1 11 | subjectAltName = DNS:testsmdpplus1.example.com, RID:2.999.10 12 | 13 | crlDistributionPoints=URI:http://ci.test.example.com/CRL-A.crl, URI:http://ci.test.example.com/CRL-B.crl 14 | 15 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/CERT_S_SM_DP_TLS_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICgjCCAiigAwIBAgIBCjAKBggqhkjOPQQDAjBEMRAwDgYDVQQDDAdUZXN0IENJ 3 | MREwDwYDVQQLDAhURVNUQ0VSVDEQMA4GA1UECgwHUlNQVEVTVDELMAkGA1UEBhMC 4 | SVQwHhcNMjUwNDIzMTUyMzA1WhcNMzUwNDIxMTUyMzA1WjAzMQ0wCwYDVQQKDARB 5 | Q01FMSIwIAYDVQQDDBl0ZXN0c21kcHBsdXMxLmV4YW1wbGUuY29tMFkwEwYHKoZI 6 | zj0CAQYIKoZIzj0DAQcDQgAEKCQwdc6O/R+uZ2g5QH2ybkzLQ3CUYhybOWEz8bJL 7 | tQG4/k6yTT4NOS8lP28blGJws8opLjTbb3qHs6X2rJRfCKOCARowggEWMA4GA1Ud 8 | DwEB/wQEAwIHgDAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwFAYD 9 | VR0gBA0wCzAJBgdngRIBAgEDMB0GA1UdDgQWBBQn/vHyKRh+x4Pt9uApZKRRjVfU 10 | qTAfBgNVHSMEGDAWgBT1QXK9+YqV1ly+uIo4ocEdgAqFwzApBgNVHREEIjAgghl0 11 | ZXN0c21kcHBsdXMxLmV4YW1wbGUuY29tiAOINwowYQYDVR0fBFowWDAqoCigJoYk 12 | aHR0cDovL2NpLnRlc3QuZXhhbXBsZS5jb20vQ1JMLUEuY3JsMCqgKKAmhiRodHRw 13 | Oi8vY2kudGVzdC5leGFtcGxlLmNvbS9DUkwtQi5jcmwwCgYIKoZIzj0EAwIDSAAw 14 | RQIgYakBZP6y9/2iu9aZkgb89SQgfRb0TKVMGElWgtyoX2gCIQCT8o/TkAxhWCTY 15 | yaBDMi1L9Ub+93ef5s+S+eHLmwuudA== 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP2_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP2_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP4_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP4_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP8_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP8_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2021/CERT_S_SM_DP_TLS_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP2_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP2_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP4_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP4_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP8_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP8_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2022/CERT_S_SM_DP_TLS_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP2_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP2_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP4_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP4_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP8_TLS.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP8_TLS.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_BRP.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_BRP.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_NIST.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/certs/DPtls/Old_TLS_Validity/Expired 2023/CERT_S_SM_DP_TLS_NIST.der -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/PK_S_SM_DP2_TLS_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEGtkADHVON2E+dQ+3v3NC/tULwHJS 3 | 7YRla0XW9wh4lQip/+CWFyOvEe/I3aaaafK1GIuzEhOCCrLdHvWALo/Utg== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/PK_S_SM_DP4_TLS.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOtvoTSOoGvY7otiZg2y7aKdiVrMN 3 | cCYwPcNrwV32ETbE++cCAbTFpm49rGsrO5V6mbtOdBAD6L90LwgTAqp9pg== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/PK_S_SM_DP8_TLS.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEzkExGPpkmW7Yspv8rIUzg+ZdPyKh 3 | meeWa/QGmmlYOSvlOdAA6lGlSIsQh9brR8ABhG0eaH7EkOgagJZJQgxSaw== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/PK_S_SM_DP_TLS_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFowFAYHKoZIzj0CAQYJKyQDAwIIAQEHA0IABEwizNgsjQIh+dhUO3LhB7zJ/ZBU 3 | 1mx1wOt0p73nMOdhjvZbJwteguQ6eW+N7guvivvrilNiU3oC/WXHnkEZa7U= 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/PK_S_SM_DP_TLS_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEKCQwdc6O/R+uZ2g5QH2ybkzLQ3CU 3 | YhybOWEz8bJLtQG4/k6yTT4NOS8lP28blGJws8opLjTbb3qHs6X2rJRfCA== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/SK_S_SM_DP2_TLS_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIE5lYcZAiPZpkHrb45SxGoQkLgM6gqiEAjFjbckbTuP1oAoGCCqGSM49 6 | AwEHoUQDQgAEGtkADHVON2E+dQ+3v3NC/tULwHJS7YRla0XW9wh4lQip/+CWFyOv 7 | Ee/I3aaaafK1GIuzEhOCCrLdHvWALo/Utg== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/SK_S_SM_DP4_TLS.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIPJlnS9Sj0sRN0DVig0q8+srSOEiwrYKavb8lq2Gvm+koAoGCCqGSM49 6 | AwEHoUQDQgAEOtvoTSOoGvY7otiZg2y7aKdiVrMNcCYwPcNrwV32ETbE++cCAbTF 7 | pm49rGsrO5V6mbtOdBAD6L90LwgTAqp9pg== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/SK_S_SM_DP8_TLS.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIP9uSlCbrds4EIgxwjzMLUQwevKB6SWWf4zfHZVUoCiNoAoGCCqGSM49 6 | AwEHoUQDQgAEzkExGPpkmW7Yspv8rIUzg+ZdPyKhmeeWa/QGmmlYOSvlOdAA6lGl 7 | SIsQh9brR8ABhG0eaH7EkOgagJZJQgxSaw== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/SK_S_SM_DP_TLS_BRP.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgkrJAMDAggBAQc= 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHgCAQEEID9nFSgCs/TH+uZ5WFX2glQeReNe//TooFVloPGRKnguoAsGCSskAwMC 6 | CAEBB6FEA0IABEwizNgsjQIh+dhUO3LhB7zJ/ZBU1mx1wOt0p73nMOdhjvZbJwte 7 | guQ6eW+N7guvivvrilNiU3oC/WXHnkEZa7U= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/DPtls/SK_S_SM_DP_TLS_NIST.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIKA+fORVBHS+pLeoc5nOWoyfZhtoD5QBOf/4Tp3sak2MoAoGCCqGSM49 6 | AwEHoUQDQgAEKCQwdc6O/R+uZ2g5QH2ybkzLQ3CUYhybOWEz8bJLtQG4/k6yTT4N 7 | OS8lP28blGJws8opLjTbb3qHs6X2rJRfCA== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /smdpp-data/certs/README: -------------------------------------------------------------------------------- 1 | files taken from SGP.26 v3 2 | -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V1-A-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V1-A-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V1-B-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V1-B-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V2-SAIP2-1-BERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V2-SAIP2-1-BERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V2-SAIP2-1-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V2-SAIP2-1-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V2-SAIP2-3-BERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V2-SAIP2-3-BERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V2-SAIP2-3-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V2-SAIP2-3-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V3-SAIP2-1-BERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V3-SAIP2-1-BERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V3-SAIP2-1-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V3-SAIP2-1-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V3-SAIP2-3-BERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V3-SAIP2-3-BERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V3-SAIP2-3-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V3-SAIP2-3-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V4-SAIP2-1A-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V4-SAIP2-1A-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V4-SAIP2-1B-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V4-SAIP2-1B-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V4-SAIP2-3-BERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V4-SAIP2-3-BERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V4-SAIP2-3-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V4-SAIP2-3-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V5-SAIP2-1A-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V5-SAIP2-1A-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V5-SAIP2-1B-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V5-SAIP2-1B-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V5-SAIP2-3-BERTLV-SUCI-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V5-SAIP2-3-BERTLV-SUCI-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48V5-SAIP2-3-NOBERTLV-UNIQUE.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48V5-SAIP2-3-NOBERTLV-UNIQUE.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v1_A.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v1_A.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v1_B.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v1_B.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v2_SAIP2.1_BERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v2_SAIP2.1_BERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v2_SAIP2.1_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v2_SAIP2.1_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v2_SAIP2.3_BERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v2_SAIP2.3_BERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v2_SAIP2.3_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v2_SAIP2.3_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v3_SAIP2.1_BERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v3_SAIP2.1_BERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v3_SAIP2.1_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v3_SAIP2.1_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v3_SAIP2.3_BERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v3_SAIP2.3_BERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v3_SAIP2.3_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v3_SAIP2.3_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v4_SAIP2.1A_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v4_SAIP2.1A_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v4_SAIP2.1B_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v4_SAIP2.1B_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v4_SAIP2.3_BERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v4_SAIP2.3_BERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v4_SAIP2.3_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v4_SAIP2.3_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v5_SAIP2.1A_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v5_SAIP2.1A_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v5_SAIP2.1B_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v5_SAIP2.1B_NoBERTLV.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v5_SAIP2.3_BERTLV_SUCI.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v5_SAIP2.3_BERTLV_SUCI.der -------------------------------------------------------------------------------- /smdpp-data/upp/TS48v5_SAIP2.3_NoBERTLV.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/smdpp-data/upp/TS48v5_SAIP2.3_NoBERTLV.der -------------------------------------------------------------------------------- /tests/card_sanitizer/card_data.csv: -------------------------------------------------------------------------------- 1 | iccid,adm1,name 2 | 8988219000000117833,CAE743DB9C5B5A58,Fairwaves-SIM 3 | 8988211000000467343,67225880,sysmoISIM-SJA2 4 | 8988211320300000028,55538407,sysmoUSIM-SJS1 5 | 89445310150011013678,15E31383624FDC8A,Wavemobile-SIM 6 | 8949440000001155314,34173960,sysmoISIM-SJA5-S17 7 | 2222334455667788990,DDDDDDDD,sysmosim-gr1 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/Fairwaves-SIM.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | IMSI=001010000000111 4 | ADM_HEX=CAE743DB9C5B5A58 5 | 6 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/Wavemobile-SIM.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | IMSI=001010000000102 4 | ADM_HEX=15E31383624FDC8A 5 | 6 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/fakemagicsim.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | ICCID=1122334455667788990 4 | KI=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 5 | OPC=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 6 | IMSI=001010000000102 -------------------------------------------------------------------------------- /tests/pySim-prog_test/fakemagicsim.ok: -------------------------------------------------------------------------------- 1 | Using PC/SC reader interface 2 | Reading ... 3 | Autodetected card type: fakemagicsim 4 | ICCID: 1122334455667788990 5 | IMSI: 001010000000102 6 | GID1: Can't read file -- SW match failed! Expected 9000 and got 9404. 7 | GID2: Can't read file -- SW match failed! Expected 9000 and got 9404. 8 | SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 9 | SPN: Magic 10 | Show in HPLMN: True 11 | Hide in OPLMN: False 12 | PLMNsel: 00f110ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 13 | PLMNwAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 14 | OPLMNwAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 15 | HPLMNAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 16 | ACC: ffff 17 | MSISDN: Not available 18 | Administrative data: 000000 19 | MS operation mode: normal 20 | Ciphering Indicator: disabled 21 | SIM Service Table: ff3fff0f0300f003000c 22 | Service 1 - CHV1 disable function 23 | Service 2 - Abbreviated Dialling Numbers (ADN) 24 | Service 3 - Fixed Dialling Numbers (FDN) 25 | Service 4 - Short Message Storage (SMS) 26 | Service 5 - Advice of Charge (AoC) 27 | Service 6 - Capability Configuration Parameters (CCP) 28 | Service 7 - PLMN selector 29 | Service 8 - RFU 30 | Service 9 - MSISDN 31 | Service 10 - Extension1 32 | Service 11 - Extension2 33 | Service 12 - SMS Parameters 34 | Service 13 - Last Number Dialled (LND) 35 | Service 14 - Cell Broadcast Message Identifier 36 | Service 17 - Service Provider Name 37 | Service 18 - Service Dialling Numbers (SDN) 38 | Service 19 - Extension3 39 | Service 20 - RFU 40 | Service 21 - VGCS Group Identifier List (EFVGCS and EFVGCSS) 41 | Service 22 - VBS Group Identifier List (EFVBS and EFVBSS) 42 | Service 23 - enhanced Multi-Level Precedence and Pre-emption Service 43 | Service 24 - Automatic Answer for eMLPP 44 | Service 25 - Data download via SMS-CB 45 | Service 26 - Data download via SMS-PP 46 | Service 27 - Menu selection 47 | Service 28 - Call control 48 | Service 33 - De-personalization Control Keys 49 | Service 34 - Co-operative Network List 50 | Service 53 - Mailbox Dialling Numbers 51 | Service 54 - Message Waiting Indication Status 52 | Service 55 - Call Forwarding Indication Status 53 | Service 56 - Service Provider Display Information 54 | Service 57 - Multimedia Messaging Service (MMS) 55 | Service 58 - Extension 8 56 | 57 | Done ! 58 | 59 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/sysmoISIM-SJA2.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | KI=AABBCCDDEEFFAABBCCDDEEFFAABBCCDD 4 | OPC=12345678901234567890123456789012 5 | IMSI=001010000000102 6 | ADM=67225880 7 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/sysmoISIM-SJA5.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | KI=AABBCCDDEEFFAABBCCDDEEFFAABBCCDD 4 | OPC=12345678901234567890123456789012 5 | IMSI=001010000000102 6 | ADM=34173960 7 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/sysmoUSIM-SJS1.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | ICCID=8988211320300000028 4 | KI=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 5 | OPC=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 6 | IMSI=001010000000102 7 | MSISDN=+77776336143 8 | ADM=55538407 9 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/sysmosim-gr1.data: -------------------------------------------------------------------------------- 1 | MCC=001 2 | MNC=01 3 | ICCID=2222334455667788990 4 | KI=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 5 | OPC=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 6 | IMSI=001010000000102 7 | ADM=DDDDDDDD 8 | -------------------------------------------------------------------------------- /tests/pySim-prog_test/sysmosim-gr1.ok: -------------------------------------------------------------------------------- 1 | Using PC/SC reader interface 2 | Reading ... 3 | Autodetected card type: sysmosim-gr1 4 | ICCID: 2222334455667788990 5 | IMSI: 001010000000102 6 | GID1: Can't read file -- SW match failed! Expected 9000 and got 9404. 7 | GID2: Can't read file -- SW match failed! Expected 9000 and got 9404. 8 | SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 9 | SPN: Not available 10 | Show in HPLMN: False 11 | Hide in OPLMN: False 12 | PLMNsel: 00f110ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 13 | PLMNwAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 14 | OPLMNwAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 15 | HPLMNAcT: Can't read file -- SW match failed! Expected 9000 and got 9404. 16 | ACC: 0008 17 | MSISDN: Not available 18 | Administrative data: 000000 19 | MS operation mode: normal 20 | Ciphering Indicator: disabled 21 | SIM Service Table: ff3fff0f0f0000030000 22 | Service 1 - CHV1 disable function 23 | Service 2 - Abbreviated Dialling Numbers (ADN) 24 | Service 3 - Fixed Dialling Numbers (FDN) 25 | Service 4 - Short Message Storage (SMS) 26 | Service 5 - Advice of Charge (AoC) 27 | Service 6 - Capability Configuration Parameters (CCP) 28 | Service 7 - PLMN selector 29 | Service 8 - RFU 30 | Service 9 - MSISDN 31 | Service 10 - Extension1 32 | Service 11 - Extension2 33 | Service 12 - SMS Parameters 34 | Service 13 - Last Number Dialled (LND) 35 | Service 14 - Cell Broadcast Message Identifier 36 | Service 17 - Service Provider Name 37 | Service 18 - Service Dialling Numbers (SDN) 38 | Service 19 - Extension3 39 | Service 20 - RFU 40 | Service 21 - VGCS Group Identifier List (EFVGCS and EFVGCSS) 41 | Service 22 - VBS Group Identifier List (EFVBS and EFVBSS) 42 | Service 23 - enhanced Multi-Level Precedence and Pre-emption Service 43 | Service 24 - Automatic Answer for eMLPP 44 | Service 25 - Data download via SMS-CB 45 | Service 26 - Data download via SMS-PP 46 | Service 27 - Menu selection 47 | Service 28 - Call control 48 | Service 33 - De-personalization Control Keys 49 | Service 34 - Co-operative Network List 50 | Service 35 - Short Message Status Reports 51 | Service 36 - Network's indication of alerting in the MS 52 | Service 57 - Multimedia Messaging Service (MMS) 53 | Service 58 - Extension 8 54 | 55 | Done ! 56 | 57 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/apdu/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | 27 | def test_apdu_legacy(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test_apdu_legacy.script", no_exceptions = True) 31 | 32 | def test_apdu_legacy_scp02(self): 33 | cardname = 'sysmoISIM-SJA5-S17' 34 | 35 | self.equipTemplate("test_apdu_legacy_scp02.script", SEC_LEVEL = 3) 36 | self.runPySimShell(cardname, "test_apdu_legacy_scp02.script", no_exceptions = True, add_csv = True) 37 | self.equipTemplate("test_apdu_legacy_scp02.script", SEC_LEVEL = 1) 38 | self.runPySimShell(cardname, "test_apdu_legacy_scp02.script", no_exceptions = True, add_csv = True) 39 | 40 | def test_apdu_legacy_scp03(self): 41 | cardname = 'sysmoEUICC1-C2T' 42 | 43 | self.equipTemplate("test_apdu_legacy_scp03.script", SEC_LEVEL = 3) 44 | self.runPySimShell(cardname, "test_apdu_legacy_scp03.script", no_exceptions = True, add_csv = True) 45 | self.equipTemplate("test_apdu_legacy_scp03.script", SEC_LEVEL = 1) 46 | self.runPySimShell(cardname, "test_apdu_legacy_scp03.script", no_exceptions = True, add_csv = True) 47 | 48 | def test_apdu(self): 49 | cardname = 'sysmoISIM-SJA5-S17' 50 | 51 | self.runPySimShell(cardname, "test_apdu.script", no_exceptions = True) 52 | 53 | def test_apdu_legacy_scp02(self): 54 | cardname = 'sysmoISIM-SJA5-S17' 55 | 56 | self.equipTemplate("test_apdu_scp02.script", SEC_LEVEL = 3) 57 | self.runPySimShell(cardname, "test_apdu_scp02.script", no_exceptions = True, add_csv = True) 58 | self.equipTemplate("test_apdu_scp02.script", SEC_LEVEL = 1) 59 | self.runPySimShell(cardname, "test_apdu_scp02.script", no_exceptions = True, add_csv = True) 60 | 61 | def test_apdu_legacy_scp03(self): 62 | cardname = 'sysmoEUICC1-C2T' 63 | 64 | self.equipTemplate("test_apdu_scp03.script", SEC_LEVEL = 3) 65 | self.runPySimShell(cardname, "test_apdu_scp03.script", no_exceptions = True, add_csv = True) 66 | self.equipTemplate("test_apdu_scp03.script", SEC_LEVEL = 1) 67 | self.runPySimShell(cardname, "test_apdu_scp03.script", no_exceptions = True, add_csv = True) 68 | 69 | if __name__ == "__main__": 70 | unittest.main() 71 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | set apdu_strict true 5 | 6 | # Case #1: (open channel #1) 7 | # No command data field, No response data field present 8 | apdu 00700001 --expect-sw 9000 --expect-response-regex '^$' 9 | 10 | # Case #2: (status) 11 | # No command data field, Response data field present 12 | apdu 80F2000000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 13 | 14 | # Case #3: (terminal capability) 15 | # Command data field present, No response data field 16 | apdu 80AA000005a903830180 --expect-sw 9000 --expect-response-regex '^$' 17 | 18 | # Case #4: (select MF) 19 | # Command data field present, Response data field present 20 | apdu 00a40004023f0000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu_legacy.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | 5 | # Case #1: (open channel #1) 6 | # No command data field, No response data field present 7 | # (in ISO/IEC 7816-3 format, this APDU would lack the 0x00 at the end) 8 | apdu 0070000100 --expect-sw 9000 --expect-response-regex '^$' 9 | 10 | # Case #2: (status) 11 | # No command data field, Response data field present 12 | apdu 80F2000000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 13 | 14 | # Case #3: (terminal capability) 15 | # Command data field present, No response data field 16 | apdu 80AA000005a903830180 --expect-sw 9000 --expect-response-regex '^$' 17 | 18 | # Case #4: (select MF) 19 | # Command data field present, Response data field present 20 | # (in ISO/IEC 7816-3 format, this APDU would have an additional 0x00 at the end) 21 | apdu 00a40004023f00 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu_legacy_scp02.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | 5 | # Establish secure channel: 6 | select ADF.ISD 7 | establish_scp02 --key-provider-suffix 1 --key-ver 112 --security-level $SEC_LEVEL 8 | 9 | # Case #1: (get status with no data field to mimic a case #1 APDU) 10 | # No command data field, No response data field present 11 | # (in ISO/IEC 7816-3 format, this APDU would lack the 0x00 at the end) 12 | apdu 80F2200200 --expect-sw 6a80 --expect-response-regex '^$$' 13 | 14 | # Case #2: (get data) 15 | # No command data field, Response data field present 16 | apdu 80ca006600 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 17 | 18 | # Case #3: (get status with wrong parameters to mimic a case #3 APDU) 19 | # Command data field present, No response data field 20 | apdu 80F220020a4f0212345c054f9f70c5 --expect-sw 6a80 --expect-response-regex '^$$' 21 | 22 | # Case #4: (initialize update, to mimic a case #4 APDU, this will unfortunately kill the session but we are done anyway) 23 | # Command data field present, Response data field present 24 | # (in ISO/IEC 7816-3 format, this APDU would have an additional 0x00 at the end) 25 | apdu 805000000855baa7eca1cd629e --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 26 | 27 | release_scp -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu_legacy_scp03.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | 5 | # Establish secure channel: 6 | select ADF.ISD-R 7 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level $SEC_LEVEL 8 | 9 | # Case #1: (get status with no data field to mimic a case #1 APDU) 10 | # No command data field, No response data field present 11 | # (in ISO/IEC 7816-3 format, this APDU would lack the 0x00 at the end) 12 | apdu 80F2200200 --expect-sw 6a80 --expect-response-regex '^$$' 13 | 14 | # Case #2: (get data) 15 | # No command data field, Response data field present 16 | apdu 80ca006600 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 17 | 18 | # Case #3: (get status with wrong parameters to mimic a case #3 APDU) 19 | # Command data field present, No response data field 20 | apdu 80F220020a4f0212345c054f9f70c5 --expect-sw 6a88 --expect-response-regex '^$$' 21 | 22 | # Case #4: (get eid) 23 | # Command data field present, Response data field present 24 | # (in ISO/IEC 7816-3 format, this APDU would have an additional 0x00 at the end) 25 | apdu 80E2910006bf3e035c015a --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 26 | 27 | release_scp -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu_scp02.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | set apdu_strict true 5 | 6 | # Establish secure channel: 7 | select ADF.ISD 8 | establish_scp02 --key-provider-suffix 1 --key-ver 112 --security-level $SEC_LEVEL 9 | 10 | # Case #1: (get status with no data field to mimic a case #1 APDU) 11 | # No command data field, No response data field present 12 | apdu 80F22002 --expect-sw 6a80 --expect-response-regex '^$$' 13 | 14 | # Case #2: (get data) 15 | # No command data field, Response data field present 16 | apdu 80ca006600 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 17 | 18 | # Case #3: (get status with wrong parameters to mimic a case #3 APDU) 19 | # Command data field present, No response data field 20 | apdu 80F220020a4f0212345c054f9f70c5 --expect-sw 6a80 --expect-response-regex '^$$' 21 | 22 | # Case #4: (initialize update, to mimic a case #4 APDU, this will unfortunately kill the session but we are done anyway) 23 | # Command data field present, Response data field present 24 | apdu 805000000855baa7eca1cd629e00 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 25 | 26 | release_scp -------------------------------------------------------------------------------- /tests/pySim-shell_test/apdu/test_apdu_scp03.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | set apdu_trace true 4 | set apdu_strict true 5 | 6 | # Establish secure channel: 7 | select ADF.ISD-R 8 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level $SEC_LEVEL 9 | 10 | # Case #1: (get status with no data field to mimic a case #1 APDU) 11 | # No command data field, No response data field present 12 | apdu 80F22002 --expect-sw 6a80 --expect-response-regex '^$$' 13 | 14 | # Case #2: (get data) 15 | # No command data field, Response data field present 16 | apdu 80ca006600 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 17 | 18 | # Case #3: (get status with wrong parameters to mimic a case #3 APDU) 19 | # Command data field present, No response data field 20 | apdu 80F220020a4f0212345c054f9f70c5 --expect-sw 6a88 --expect-response-regex '^$$' 21 | 22 | # Case #4: (get eid) 23 | # Command data field present, Response data field present 24 | apdu 80E2910006bf3e035c015a00 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$$' 25 | 26 | release_scp -------------------------------------------------------------------------------- /tests/pySim-shell_test/ara_m/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/ara_m/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/ara_m/adf_ara-m.script.ok: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # MF/ADF.ARA-M # 3 | ################################################################################ 4 | # directory: MF/ADF.ARA-M (3f00/a00000015141434c00) 5 | # file: ADF.ARA-M (None) 6 | # RAW FCP Template: None 7 | # Decoded FCP Template: None 8 | select MF/ADF.ARA-M 9 | aram_delete_all 10 | aram_store_ref_ar_do --aid "" --device-app-id a1234567890123bb1f140de987aaa891bbbf0bdd --apdu-filter aabbccdd010203041122334405060708 --nfc-never --android-permissions 0000000000000004 11 | aram_store_ref_ar_do --aid ffffffffffcc --device-app-id a1234567890aaabb1f140de987657891a04f0bdd --apdu-filter aabbccdd01020304 --nfc-always --android-permissions 0000000000000004 12 | aram_store_ref_ar_do --aid ffffffffffbb --device-app-id aa6872f28b340b2345678905d5c2bbd5a04f0bdd --apdu-always --nfc-always --android-permissions 0000000000000004 13 | aram_store_ref_ar_do --aid ffffffffffaa --device-app-id aa6872787654334567840de535c2bbd5a04f0baa --apdu-never --nfc-never --android-permissions 0000000000000004 14 | # 15 | ################################################################################ 16 | # Export summary # 17 | ################################################################################ 18 | # total files visited: 1 19 | # bad files: 0 20 | # skipped dedicated files(s): 0 21 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/ara_m/adf_ara-m_empty.cfg.ok: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "response_all_ref_ar_do": null 4 | } 5 | ] 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/ara_m/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | 29 | self.runPySimShell(cardname, "test.script") 30 | self.assertEqualFiles("adf_ara-m.script.tmp") 31 | self.assertEqualFiles("adf_ara-m.cfg.tmp") 32 | self.assertEqualFiles("adf_ara-m_empty.cfg.tmp") 33 | 34 | if __name__ == "__main__": 35 | unittest.main() 36 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/ara_m/test.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Export existing ARA-M configuration 5 | export --filename ADF.ARA-M > restore_adf_ara_m.script.tmp 6 | 7 | # Create a known config in ADF.ARA-M 8 | select ADF.ARA-M 9 | aram_delete_all 10 | aram_store_ref_ar_do --aid ffffffffffaa --device-app-id aa6872787654334567840de535c2bbd5a04f0baa --apdu-never --nfc-never --android-permissions 0000000000000004 11 | aram_store_ref_ar_do --aid ffffffffffbb --device-app-id aa6872f28b340b2345678905d5c2bbd5a04f0bdd --apdu-always --nfc-always --android-permissions 0000000000000004 12 | aram_store_ref_ar_do --aid ffffffffffcc --device-app-id a1234567890aaabb1f140de987657891a04f0bdd --apdu-filter aabbccdd01020304 --nfc-always --android-permissions 0000000000000004 13 | aram_store_ref_ar_do --aid "" --device-app-id a1234567890123bb1f140de987aaa891bbbf0bdd --apdu-filter aabbccdd010203041122334405060708 --nfc-never --android-permissions 0000000000000004 14 | 15 | # Export ADF.ARA-M to a temporary script file 16 | export --filename ADF.ARA-M > adf_ara-m.script.tmp 17 | 18 | # Ensure ADF.ARA-M is empty 19 | aram_delete_all 20 | 21 | # Check that ADF.ARA-M is empty 22 | aram_get_all > adf_ara-m_empty.cfg.tmp 23 | 24 | # Run the temporary script file to restore ADF.ARA-M again 25 | run_script adf_ara-m.script.tmp 26 | 27 | # Read out ADF.ARA-M using aram_get_all 28 | aram_get_all > adf_ara-m.cfg.tmp 29 | 30 | # Restore ARA-M configuration to its original state 31 | run_script restore_adf_ara_m.script.tmp 32 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/authenticate/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/authenticate/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/authenticate/auth_result.ok: -------------------------------------------------------------------------------- 1 | { 2 | "successful_3g_authentication": { 3 | "res": "13484811d553ab35", 4 | "ck": "0f93c4807f4ff57c6cd348fea590c06d", 5 | "ik": "608e7bff4856c73e363e795b165a4158", 6 | "kc": "35f08eda84d3b377" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/authenticate/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | 29 | # Perform authentication 30 | self.runPySimShell(cardname, "test.script", add_adm = True) 31 | self.assertEqualFiles("auth_result.tmp") 32 | 33 | if __name__ == "__main__": 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/authenticate/test.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.USIM/EF.USIM_SQN > restore_ef_usim_sqn.script.tmp 6 | export --filename MF/ADF.USIM/EF.USIM_AUTH_KEY > restore_ef_usim_auth_key.script.tmp 7 | 8 | # Write known configuration with KI and OPc value 9 | select MF/ADF.USIM/EF.USIM_AUTH_KEY 10 | update_binary 0456c3a6da347ae7e43c69d37576725d81e0012b514f84eca9bfd6182bee345e2cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 11 | 12 | # Reset SQN counter 13 | select MF/ADF.USIM/EF.USIM_SQN 14 | update_binary d503000200000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 15 | 16 | # Perform authentication 17 | select ADF.USIM 18 | authenticate e85b2b7fe58f0e6239b32543d3e3259a 7928ea47ae090000ca8ab1f93c7cb03a > auth_result.tmp 19 | 20 | # Restore modified files to their original state 21 | run_script restore_ef_usim_sqn.script.tmp 22 | run_script restore_ef_usim_auth_key.script.tmp 23 | 24 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/card_data.csv: -------------------------------------------------------------------------------- 1 | eid,iccid,adm1,pin1,puk1,SCP02_DEK_1,SCP02_ENC_1,SCP02_MAC_1,SCP03_DEK_1,SCP03_ENC_1,SCP03_MAC_1 2 | 0,8949440000001155314,34173960,0000,15091909,FFB53E96E5FF99731D51AD7BEAFD0E23,51D4FC44BCBA7C4589DFADA3297720AF,0449699C472CE71E2FB7B56245EF7684,0,0,0 3 | 0,8988211000000467343,67225880,5563,42936344,AD1AF0EC5643FFD4986F0F00A48FF244,112788F75D15F678F51A8EB606766B16,02A6FC022F8F871611237F2A9FC72315,0,0,0 4 | 89049044900000000000000000102355,0,0,0,0,0,0,0,9b3bf6fda1bc88d9bd6083bb704243f920702a9bd744a484482049ebdab40ef3,67230241fd09e4ff46f4b4db3450dd839bf8b545bdd70199ac2a7788e87e2243,f80f4a71f6dbf7eca8cdc18a9c65c59abdd07e3da74b1c48e106954d76cb793f 5 | 0,2222334455667788990,0,0,0,0,0,0,0,0,0 -------------------------------------------------------------------------------- /tests/pySim-shell_test/card_init/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/card_init/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/card_init/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | 27 | def test_card_init(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test_card_init.script", no_exceptions = True, skip_card_init = True) 31 | 32 | if __name__ == "__main__": 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/card_init/test_card_init.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # In this test we start without initializing any card profile. In this situation 5 | # only the "apdu" command and the "reset" command will work. 6 | 7 | # Select a file deep in the file system using APDUs only 8 | apdu 00a40004023f0000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 9 | apdu 00a4040410a0000000871002ffffffff890709000000 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 10 | apdu 00a40004026f0700 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 11 | 12 | # Try a reset 13 | reset 14 | 15 | # If the reset had an effect, selecting a file at MF level should work 16 | apdu 00a40004022fe200 --expect-sw 9000 --expect-response-regex '^[a-fA-F0-9]+$' 17 | 18 | # Equip the card, this will do the profile initialization. After this, 19 | # pySim-shell commands should work normally. 20 | equip 21 | 22 | # Select a file deep in the file system 23 | select MF/ADF.USIM/EF.IMSI 24 | 25 | # Try again to reset the card 26 | reset 27 | 28 | # If the reset had an effect, selecting a file at MF level should work 29 | select EF.ICCID 30 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/cardinfo/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/sysmoEUICC1-C2T-cardinfo.ok: -------------------------------------------------------------------------------- 1 | Card info: 2 | Name: UICC 3 | ATR: 3b9f96803f87828031e073fe211f574543753130136502 4 | EID: 89049044900000000000000000102355 5 | ICCID: 89000123456789012341 6 | Class-Byte: 00 7 | Select-Ctrl: 0004 8 | AIDs: 9 | a0000000871002 10 | a0000000871004 11 | a0000005591010ffffffff8900000200 12 | a0000005591010ffffffff8900000100 13 | a00000015141434c00 14 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/sysmoISIM-SJA2-cardinfo.ok: -------------------------------------------------------------------------------- 1 | Card info: 2 | Name: UICC 3 | ATR: 3b9f96801f878031e073fe211b674a4c753034054ba9 4 | ICCID: 8988211000000467343 5 | Class-Byte: 00 6 | Select-Ctrl: 0004 7 | AIDs: 8 | a0000000871002 9 | a0000000871004 10 | a000000003000000 11 | a00000015141434c00 12 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/sysmoISIM-SJA5-S17-cardinfo.ok: -------------------------------------------------------------------------------- 1 | Card info: 2 | Name: UICC 3 | ATR: 3b9f96801f878031e073fe211b674a357530350265f8 4 | ICCID: 8949440000001155314 5 | Class-Byte: 00 6 | Select-Ctrl: 0004 7 | AIDs: 8 | a0000000871002 9 | a0000000871004 10 | a000000003000000 11 | a00000015141434c00 12 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/sysmoSIM-GR1-cardinfo.ok: -------------------------------------------------------------------------------- 1 | Card info: 2 | Name: SIM 3 | ATR: 3b991800118822334455667760 4 | ICCID: 2222334455667788990 5 | Class-Byte: a0 6 | Select-Ctrl: 0000 7 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | 27 | def test(self): 28 | for cardname in self.cards: 29 | self.equipTemplate("test.script", CARDNAME=cardname) 30 | self.runPySimShell(cardname, "test.script") 31 | self.assertEqualFiles(cardname + "-cardinfo.tmp", 32 | mask_regex_list = [' [A-Fa-f0-9]*$'], 33 | interesting_regex_list = ['^ a0.*', '^ ATR.*', '^ Cla.*', '^ Sel.*']) 34 | 35 | if __name__ == "__main__": 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/cardinfo/test.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Export the entire file system 5 | cardinfo > $CARDNAME-cardinfo.tmp 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/chv/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test_manage(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | pin1 = self.cards[cardname]['pin1'] 29 | puk1 = self.cards[cardname]['puk1'] 30 | 31 | # Provide PIN via commandline directly 32 | self.equipTemplate("test_manage_direct.script", PIN1=pin1) 33 | self.runPySimShell(cardname, "test_manage_direct.script") 34 | self.assertEqualFiles("test_manage_direct.tmp") 35 | os.remove("test_manage_direct.script") 36 | 37 | # Provide PIN via CSV file (CardKeyProvider) 38 | self.equipTemplate("test_manage_csv.script", PIN1=pin1) 39 | self.runPySimShell(cardname, "test_manage_csv.script", add_csv = True) 40 | ignore_regex_list = ['\'[A-Fa-f0-9]*\''] # do not compare the actual PIN and ICCID values echoed by the commands 41 | self.assertEqualFiles("test_manage_csv.tmp", 42 | ignore_regex_list=ignore_regex_list) 43 | 44 | def test_unblock(self): 45 | cardname = 'sysmoISIM-SJA5-S17' 46 | pin1 = self.cards[cardname]['pin1'] 47 | puk1 = self.cards[cardname]['puk1'] 48 | 49 | # Provide PIN via commandline directly 50 | self.equipTemplate("test_unblock_direct.script", PIN1=pin1, PUK1=puk1) 51 | self.runPySimShell(cardname, "test_unblock_direct.script") 52 | self.assertEqualFiles("test_unblock_direct.tmp") 53 | 54 | # Provide PIN via CSV file (CardKeyProvider) 55 | self.runPySimShell(cardname, "test_unblock_csv.script", add_csv = True) 56 | ignore_regex_list = ['\'[A-Fa-f0-9]*\''] # do not compare the actual PIN and ICCID values echoed by the commands 57 | self.assertEqualFiles("test_unblock_csv.tmp", 58 | ignore_regex_list=ignore_regex_list) 59 | 60 | if __name__ == "__main__": 61 | unittest.main() 62 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_manage_csv.ok: -------------------------------------------------------------------------------- 1 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 2 | CHV enable successful 3 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 4 | CHV verification successful 5 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 6 | CHV change successful 7 | CHV verification successful 8 | CHV change successful 9 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 10 | CHV disable successful 11 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_manage_csv.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Enable PIN1 5 | enable_chv > test_manage_csv.tmp 6 | reset 7 | 8 | # Verify PIN1 9 | verify_chv >> test_manage_csv.tmp 10 | reset 11 | 12 | # Change PIN1 to some arbitrary value 13 | change_chv 1234 >> test_manage_csv.tmp 14 | reset 15 | 16 | # Verify PIN1 17 | verify_chv 1234 >> test_manage_csv.tmp 18 | reset 19 | 20 | # Change PIN1 back to its original value 21 | change_chv $PIN1 1234 >> test_manage_csv.tmp 22 | reset 23 | 24 | # Disable PIN1 again 25 | disable_chv >> test_manage_csv.tmp 26 | reset 27 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_manage_direct.ok: -------------------------------------------------------------------------------- 1 | CHV enable successful 2 | CHV change successful 3 | CHV verification successful 4 | CHV change successful 5 | CHV disable successful 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_manage_direct.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Enable PIN1 5 | enable_chv $PIN1 > test_manage_direct.tmp 6 | reset 7 | 8 | # Change PIN1 to some arbitrary value 9 | change_chv 1234 $PIN1 >> test_manage_direct.tmp 10 | reset 11 | 12 | # Verify PIN1 13 | verify_chv 1234 >> test_manage_direct.tmp 14 | reset 15 | 16 | # Change PIN1 back to its original value 17 | change_chv $PIN1 1234 >> test_manage_direct.tmp 18 | reset 19 | 20 | # Disable PIN1 again 21 | disable_chv $PIN1 >> test_manage_direct.tmp 22 | reset 23 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_unblock_csv.ok: -------------------------------------------------------------------------------- 1 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 2 | CHV enable successful 3 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 4 | found PUK1 '3135303931393039' for ICCID '8949440000001155314' 5 | CHV unblock successful 6 | found PIN1 '30303030ffffffff' for ICCID '8949440000001155314' 7 | CHV disable successful 8 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_unblock_csv.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Enable PIN1 5 | enable_chv > test_unblock_csv.tmp 6 | reset 7 | 8 | # Enter the wrong PIN1 more than 3 times to block it (we will see some exceptions, which is normal) 9 | verify_chv 2468 10 | verify_chv 2468 11 | verify_chv 2468 12 | verify_chv 2468 13 | reset 14 | 15 | # Unblock the PIN again 16 | unblock_chv >> test_unblock_csv.tmp 17 | reset 18 | 19 | # Disable PIN1 20 | disable_chv >> test_unblock_csv.tmp 21 | reset 22 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_unblock_direct.ok: -------------------------------------------------------------------------------- 1 | CHV enable successful 2 | CHV unblock successful 3 | CHV disable successful 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/chv/test_unblock_direct.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Enable PIN1 5 | enable_chv $PIN1 > test_unblock_direct.tmp 6 | reset 7 | 8 | # Enter the wrong PIN1 more than 3 times to block it (we will see some exceptions, which is normal) 9 | verify_chv 2468 10 | verify_chv 2468 11 | verify_chv 2468 12 | verify_chv 2468 13 | reset 14 | 15 | # Unblock the PIN again 16 | unblock_chv $PUK1 $PIN1 >> test_unblock_direct.tmp 17 | reset 18 | 19 | # Disable PIN1 20 | disable_chv $PIN1 >> test_unblock_direct.tmp 21 | reset 22 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/config.yaml: -------------------------------------------------------------------------------- 1 | regenerate: False 2 | keepfiles: False 3 | print_content: True 4 | cards: 5 | - name : "sysmoISIM-SJA5-S17" 6 | atr : "3B9F96801F878031E073FE211B674A357530350265F8" 7 | iccid : "8949440000001155314" 8 | - name : "sysmoISIM-SJA2" 9 | atr : "3B9F96801F878031E073FE211B674A4C753034054BA9" 10 | iccid : "8988211000000467343" 11 | - name : "sysmoEUICC1-C2T" 12 | atr : "3B9F96803F87828031E073FE211F574543753130136502" 13 | eid : "89049044900000000000000000102355" 14 | - name : "sysmoSIM-GR1" 15 | atr : "3B991800118822334455667760" 16 | iccid : "2222334455667788990" 17 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/euicc/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/enable_disable_profile.ok: -------------------------------------------------------------------------------- 1 | { 2 | "disable_result": "ok" 3 | } 4 | { 5 | "enable_result": "ok" 6 | } 7 | { 8 | "disable_result": "ok" 9 | } 10 | { 11 | "enable_result": "ok" 12 | } 13 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/euicc_info1.ok: -------------------------------------------------------------------------------- 1 | { 2 | "svn": "2.3.0", 3 | "euicc_ci_pki_list_for_verification": { 4 | "subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3" 5 | }, 6 | "euicc_ci_pki_list_for_signing": { 7 | "subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/euicc_info2.ok: -------------------------------------------------------------------------------- 1 | { 2 | "profile_version": "2.3.1", 3 | "svn": "2.3.0", 4 | "euicc_firmware_ver": "35.6.35", 5 | "ext_card_resource": "810108820400045bf883022419", 6 | "uicc_capability": "067f36f3c0", 7 | "ts102241_version": "15.1.0", 8 | "global_platform_version": "2.3.0", 9 | "rsp_capability": "0398", 10 | "euicc_ci_pki_list_for_verification": { 11 | "subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3" 12 | }, 13 | "euicc_ci_pki_list_for_signing": { 14 | "subject_key_identifier": "f54172bdf98a95d65cbeb88a38a1c11d800a85c3" 15 | }, 16 | "unknown_ber_tlv_ie_99": { 17 | "raw": "0640" 18 | }, 19 | "pp_version": "1.0.0", 20 | "ss_acreditation_number": "SYSMOCOM-TEST-1" 21 | } 22 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/get_eid.ok: -------------------------------------------------------------------------------- 1 | { 2 | "eid_value": "89049044900000000000000000102355" 3 | } 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/get_profiles_info.ok: -------------------------------------------------------------------------------- 1 | { 2 | "profile_info_seq": [ 3 | { 4 | "profile_info": { 5 | "iccid": "89000123456789012341", 6 | "isdp_aid": "a0000005591010ffffffff8900001000", 7 | "profile_state": "enabled", 8 | "profile_nickname": "this-is-a-testprofile", 9 | "service_provider_name": "SP Name 1", 10 | "profile_name": "Operational Profile Name 1", 11 | "icon_type": "png", 12 | "icon": "89504e470d0a1a0a0000000d49484452000000400000004008040000000060b9550000000774494d4507e00b091007364c956f97000000097048597300000b1200000b1201d2dd7efc0000000467414d410000b18f0bfc61050000021f4944415478daed99cd1583200c803d32000b3004abb00ecbb0822338578af559223f49b0a8175f2ec023e1238410db09a667e5e1e55f80bf00f686060b1e66b80420c02a32550d0e966e8cc6f0128d193460635fa66a3b7d511db48dd94788b655d7815071ba26e61b9000acc711841085eb398d84c0cd94f921ebe2ddab18db6b5005b055c3bc752b4038745c5339449cd4950248100e1d4528fac207b228e3101a4bd4ae52ba96a603808b05d44c27adab2af8807a00a6184b228014807566eca13538e5008ac890bf06be809e4dbebe0b808a842a009ffd7b010436af06b04f034c8d47ea46004703e034e4d95b90a98a447300dc353c9f07a843404d9b2d904bca84f62480a7013c39351431225b722de9f6ad591a0047c194e5ae19bd865afc1a26976f088603c0a7ac9117fce131f64200bcdfed8e290ee058906c46f2fad09dac885ab1550c68d2a8b426dcf69b8e71f76d195b15cd368207463513fd2dea6648476b2500eb999b6250fa5dc0499e0b88b921f2bbaf782e877588930370724e4d3f0dd01d49dbe7e92cb940423172008f3ed3c6011c03b1396bce6ec24800c703b862682480a20142250b8c05c081385186cd65009607d059dd772b80ae3cb963010205b054436414808abb0ff237752480a996fb3702d8334fda0bf002bc002fc0488053b5f5380005dc0a1703f03ffdfdc433a6fa010cf1ef4165c831e602b40134844c66e67fa4c1000618e5ab8f6008c03faab7028c9117e0036baf44917035af0e0000000049454e44ae426082", 13 | "profile_class": "test" 14 | } 15 | }, 16 | { 17 | "profile_info": { 18 | "iccid": "8949449999999990031f", 19 | "isdp_aid": "a0000005591010ffffffff8900001200", 20 | "profile_state": "disabled", 21 | "service_provider_name": "OsmocomSPN", 22 | "profile_name": "TS48V1-B-UNIQUE", 23 | "profile_class": "operational" 24 | } 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/notifications.ok: -------------------------------------------------------------------------------- 1 | { 2 | "notification_metadata_list": null 3 | } 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/set_nickname.ok: -------------------------------------------------------------------------------- 1 | { 2 | "set_nickname_result": "ok" 3 | } 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_enable_disable_profile.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | # by ICCID (pre-installed test profile on sysmoEUICC1-C2T) 7 | disable_profile --iccid 89000123456789012341 > enable_disable_profile.tmp 8 | enable_profile --iccid 89000123456789012341 >> enable_disable_profile.tmp 9 | 10 | # by ISDP AID (pre-installed test profile on sysmoEUICC1-C2T) 11 | disable_profile --isdp-aid a0000005591010ffffffff8900001000 >> enable_disable_profile.tmp 12 | enable_profile --isdp-aid a0000005591010ffffffff8900001000 >> enable_disable_profile.tmp 13 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_gen_notif.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | # Generate two (additional) notifications by quickly enabeling the test profile 7 | enable_profile --iccid 8949449999999990031f 8 | enable_profile --iccid 89000123456789012341 9 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_get_eid.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | get_eid > get_eid.tmp 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_get_euicc_info.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | get_euicc_info1 > euicc_info1.tmp 6 | get_euicc_info2 > euicc_info2.tmp 7 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_get_profiles_info.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | get_profiles_info > get_profiles_info.tmp 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_list_notif.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | # List notifications 7 | list_notification > notifications.tmp 8 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_rm_notif.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | remove_notification_from_list $SEQ_NUMBER 7 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/euicc/test_set_nickname.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | # (pre-installed test profile on sysmoEUICC1-C2T) 7 | set_nickname --profile-nickname "this-is-a-testprofile" 89000123456789012341 > set_nickname.tmp 8 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/export/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/export/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/export/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test_export(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | 29 | # Generate an export script and verify it 30 | self.runPySimShell(cardname, "test_export.script") 31 | ignore_regex_list = [ 32 | '^#.*$', # Ignore all generated comments 33 | ' [A-Fa-f0-9]*$', # Ignore hex-strings from update_record, update_binary 34 | '^aram_store_ref_ar_do.*' # Ignore ara-m config (already covered by testcase "export_adf_ara_m") 35 | ] 36 | self.assertEqualFiles("export.script.tmp", 37 | ignore_regex_list=ignore_regex_list) 38 | 39 | # Try to import the export script we have just generated. Since there are no changes in the file contents, 40 | # we won't actually write the files, but we will verify that the generated script makes sense and can be 41 | # executed without causing exceptions. 42 | self.runPySimShell(cardname, "test_import.script", no_exceptions = True) 43 | 44 | 45 | if __name__ == "__main__": 46 | unittest.main() 47 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/export/test_export.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Export the entire file system 5 | export > export.script.tmp 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/export/test_import.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Export the entire file system 5 | run_script export.script.tmp -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/file_admin/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/activate_deactivate_file.ok: -------------------------------------------------------------------------------- 1 | { 2 | "file_descriptor": { 3 | "file_descriptor_byte": { 4 | "shareable": true, 5 | "file_type": "working_ef", 6 | "structure": "transparent" 7 | }, 8 | "record_len": null, 9 | "num_of_rec": null 10 | }, 11 | "file_identifier": "6f7e", 12 | "proprietary_information": { 13 | "unknown_ber_tlv_ie_d0": { 14 | "raw": "20" 15 | }, 16 | "toolkit_access_conditions": { 17 | "rfm_create": true, 18 | "rfm_delete_terminate": true, 19 | "other_applet_create": true, 20 | "other_applet_delete_terminate": true 21 | } 22 | }, 23 | "life_cycle_status_integer": "operational_activated", 24 | "security_attrib_referenced": { 25 | "ef_arr_file_id": "6f06", 26 | "ef_arr_record_nr": 4 27 | }, 28 | "file_size": 11, 29 | "short_file_identifier": 11 30 | } 31 | { 32 | "file_descriptor": { 33 | "file_descriptor_byte": { 34 | "shareable": true, 35 | "file_type": "working_ef", 36 | "structure": "transparent" 37 | }, 38 | "record_len": null, 39 | "num_of_rec": null 40 | }, 41 | "file_identifier": "6f7e", 42 | "proprietary_information": { 43 | "unknown_ber_tlv_ie_d0": { 44 | "raw": "20" 45 | }, 46 | "toolkit_access_conditions": { 47 | "rfm_create": true, 48 | "rfm_delete_terminate": true, 49 | "other_applet_create": true, 50 | "other_applet_delete_terminate": true 51 | } 52 | }, 53 | "life_cycle_status_integer": "operational_deactivated", 54 | "security_attrib_referenced": { 55 | "ef_arr_file_id": "6f06", 56 | "ef_arr_record_nr": 4 57 | }, 58 | "file_size": 11, 59 | "short_file_identifier": 11 60 | } 61 | { 62 | "file_descriptor": { 63 | "file_descriptor_byte": { 64 | "shareable": true, 65 | "file_type": "working_ef", 66 | "structure": "transparent" 67 | }, 68 | "record_len": null, 69 | "num_of_rec": null 70 | }, 71 | "file_identifier": "6f7e", 72 | "proprietary_information": { 73 | "unknown_ber_tlv_ie_d0": { 74 | "raw": "20" 75 | }, 76 | "toolkit_access_conditions": { 77 | "rfm_create": true, 78 | "rfm_delete_terminate": true, 79 | "other_applet_create": true, 80 | "other_applet_delete_terminate": true 81 | } 82 | }, 83 | "life_cycle_status_integer": "operational_activated", 84 | "security_attrib_referenced": { 85 | "ef_arr_file_id": "6f06", 86 | "ef_arr_record_nr": 4 87 | }, 88 | "file_size": 11, 89 | "short_file_identifier": 11 90 | } 91 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | import json 24 | from utils import * 25 | 26 | class test_case(UnittestUtils): 27 | def test_activate_deactivate(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test_activate_deactivate_file.script", add_adm = True) 31 | self.assertEqualFiles("activate_deactivate_file.tmp", 32 | ignore_regex_list = ['.*'], 33 | interesting_regex_list = ['.*"life_cycle_status_integer.*"']) 34 | 35 | def test_create_delete_df(self): 36 | cardname = 'sysmoISIM-SJA5-S17' 37 | 38 | self.runPySimShell(cardname, "test_create_delete_df.script", 39 | add_adm = True, no_exceptions = True) 40 | 41 | def test_create_resize_delete_transparent_ef(self): 42 | cardname = 'sysmoISIM-SJA5-S17' 43 | 44 | self.runPySimShell(cardname, "test_create_resize_delete_transparent_ef.script", 45 | add_adm = True, no_exceptions = True) 46 | 47 | def test_create_resize_delete_linear_fixed_ef(self): 48 | cardname = 'sysmoISIM-SJA5-S17' 49 | 50 | self.runPySimShell(cardname, "test_create_resize_delete_linear_fixed_ef.script", 51 | add_adm = True, no_exceptions = True) 52 | 53 | if __name__ == "__main__": 54 | unittest.main() 55 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/test_activate_deactivate_file.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select /ADF.USIM/EF.LOCI > activate_deactivate_file.tmp 5 | deactivate_file 6 | select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp 7 | activate_file EF.LOCI 8 | select /ADF.USIM/EF.LOCI >> activate_deactivate_file.tmp 9 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/test_create_delete_df.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we 5 | # temporarily modify EF.ARR 6 | select /EF.ARR 7 | export --filename /EF.ARR > restore_ef_arr.script.tmp 8 | update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 9 | 10 | # Create a new DF and select it 11 | select MF 12 | create_df --ef-arr-file-id 2f06 --ef-arr-record-nr 1 1234 13 | select 1234 14 | 15 | # Delete the DF that we have created 16 | select MF 17 | delete_file --force-delete 1234 18 | 19 | # Restore EF.ARR to its original state 20 | run_script restore_ef_arr.script.tmp 21 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/test_create_resize_delete_linear_fixed_ef.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we 5 | # temporarily modify EF.ARR 6 | select /EF.ARR 7 | export --filename /EF.ARR > restore_ef_arr.script.tmp 8 | update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 9 | 10 | # Create a new DF (10 records with 10 bytes each) and select it 11 | select MF 12 | create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 100 --structure linear_fixed --record-length 10 4321 13 | select 4321 14 | 15 | # Resize the new DF (double the number of available records) and select it again 16 | select MF 17 | resize_ef --file-size 200 4321 18 | select 4321 19 | 20 | # Delete the DF that we have created 21 | select MF 22 | delete_file --force-delete 4321 23 | 24 | # Restore EF.ARR to its original state 25 | run_script restore_ef_arr.script.tmp 26 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_admin/test_create_resize_delete_transparent_ef.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Before we start, we will grant ourselves the right to delete ef-arr-record-nr 1 files at any time. For this we 5 | # temporarily modify EF.ARR 6 | select /EF.ARR 7 | export --filename /EF.ARR > restore_ef_arr.script.tmp 8 | update_record 1 800101a40683010a950108800106900080016090008401d4a40683010a950108ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 9 | 10 | # Create a new DF and select it 11 | select MF 12 | create_ef --ef-arr-file-id 2f06 --ef-arr-record-nr 1 --file-size 23 --structure transparent 5678 13 | select 5678 14 | 15 | # Resize the new DF and select it again 16 | select MF 17 | resize_ef --file-size 42 5678 18 | select 5678 19 | 20 | # Delete the DF that we have created 21 | select MF 22 | delete_file --force-delete 5678 23 | 24 | # Restore EF.ARR to its original state 25 | run_script restore_ef_arr.script.tmp 26 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/file_content/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | import json 24 | from utils import * 25 | 26 | class test_case(UnittestUtils): 27 | def test_binary_uicc(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test_binary_uicc.script") 31 | self.assertEqualFiles("test_binary_uicc.tmp") 32 | 33 | def test_binary_sim(self): 34 | cardname = 'sysmoSIM-GR1' 35 | 36 | self.runPySimShell(cardname, "test_binary_sim.script") 37 | self.assertEqualFiles("test_binary_sim.tmp") 38 | 39 | def test_record_uicc(self): 40 | cardname = 'sysmoISIM-SJA5-S17' 41 | 42 | self.runPySimShell(cardname, "test_record_uicc.script") 43 | self.assertEqualFiles("test_record_uicc.tmp") 44 | 45 | def test_record_sim(self): 46 | cardname = 'sysmoSIM-GR1' 47 | 48 | self.runPySimShell(cardname, "test_record_sim.script") 49 | self.assertEqualFiles("test_record_sim.tmp") 50 | 51 | def test_ber_tlv_uicc(self): 52 | cardname = 'sysmoISIM-SJA5-S17' 53 | 54 | self.runPySimShell(cardname, "test_ber_tlv_uicc.script", add_adm = True) 55 | self.assertEqualFiles("test_ber_tlv_uicc.tmp") 56 | 57 | 58 | if __name__ == "__main__": 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_ber_tlv_uicc.ok: -------------------------------------------------------------------------------- 1 | [129, 130, 131, 132] 2 | 8106aabbccddeeff 3 | 820a11223344556677889900 4 | 830d187216fff38bbcc22110ffffff 5 | 840123 6 | [130, 132] 7 | [] 8 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_ber_tlv_uicc.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.ISIM/EF.IMSConfigData > restore_ef_IMSConfigData.script.tmp 6 | 7 | select MF/ADF.ISIM/EF.IMSConfigData 8 | 9 | # Empty the file 10 | delete_all 11 | retrieve_tags > test_ber_tlv_uicc.tmp 12 | 13 | # Set some tags 14 | set_data 129 aabbccddeeff 15 | set_data 130 11223344556677889900 16 | set_data 131 187216fff38bbcc22110ffffff 17 | set_data 132 23 18 | 19 | # Readback tags 20 | retrieve_tags > test_ber_tlv_uicc.tmp 21 | retrieve_data 129 >> test_ber_tlv_uicc.tmp 22 | retrieve_data 130 >> test_ber_tlv_uicc.tmp 23 | retrieve_data 131 >> test_ber_tlv_uicc.tmp 24 | retrieve_data 132 >> test_ber_tlv_uicc.tmp 25 | 26 | # Delete some tags 27 | delete_data 131 28 | delete_data 129 29 | retrieve_tags >> test_ber_tlv_uicc.tmp 30 | 31 | # Empty file again 32 | delete_all 33 | retrieve_tags >> test_ber_tlv_uicc.tmp 34 | 35 | # Restore modified files to their original state 36 | run_script restore_ef_IMSConfigData.script.tmp 37 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_binary_sim.ok: -------------------------------------------------------------------------------- 1 | ffffffffffffffffffffff 2 | 01234567890abcdeffffff 3 | 01234567890abcdeffaaaa 4 | 001abcd3440abcdeffaaaa 5 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_binary_sim.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/DF.GSM/EF.LOCI > restore_ef_loci.script.tmp 6 | 7 | # Select an arbitrary file to work with 8 | select MF/DF.GSM/EF.LOCI 9 | 10 | # Clear file contents 11 | update_binary ffffffffffffffffffffff 12 | read_binary > test_binary_sim.tmp 13 | 14 | # Write some short pattern to the file 15 | update_binary 01234567890abcdeff 16 | read_binary >> test_binary_sim.tmp 17 | 18 | # Write some pattern to the file 19 | update_binary 01234567890abcdeffaaaa 20 | read_binary >> test_binary_sim.tmp 21 | 22 | # Write some short pattern to the file, we expect the tail to remain unchanged 23 | update_binary 001abcd344 24 | read_binary >> test_binary_sim.tmp 25 | 26 | # Restore modified files to their original state 27 | run_script restore_ef_loci.script.tmp 28 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_binary_uicc.ok: -------------------------------------------------------------------------------- 1 | ffffffffffffffffffffff 2 | 01234567890abcdeffffff 3 | 01234567890abcdeffaaaa 4 | 001abcd3440abcdeffaaaa 5 | { 6 | "tmsi": "12345678", 7 | "lai": { 8 | "mcc_mnc": "262-42", 9 | "lac": "9876" 10 | }, 11 | "rfu": 0, 12 | "lu_status": 1 13 | } 14 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_binary_uicc.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.USIM/EF.LOCI > restore_ef_loci.script.tmp 6 | 7 | # Select an arbitrary file to work with 8 | select MF/ADF.USIM/EF.LOCI 9 | 10 | # Clear file contents 11 | update_binary ffffffffffffffffffffff 12 | read_binary > test_binary_uicc.tmp 13 | 14 | # Write some short pattern to the file 15 | update_binary 01234567890abcdeff 16 | read_binary >> test_binary_uicc.tmp 17 | 18 | # Write some pattern to the file 19 | update_binary 01234567890abcdeffaaaa 20 | read_binary >> test_binary_uicc.tmp 21 | 22 | # Write some short pattern to the file, we expect the tail to remain unchanged 23 | update_binary 001abcd344 24 | read_binary >> test_binary_uicc.tmp 25 | 26 | # Write some json encoded content to the file 27 | update_binary_decoded '{"tmsi": "12345678", "lai": { "mcc_mnc": "262-42", "lac": "9876" }, "rfu": 0, "lu_status": 1 }' 28 | 29 | # Read the file, we expect the same json encoded content to show up again. 30 | read_binary_decoded >> test_binary_uicc.tmp 31 | 32 | # Restore modified files to their original state 33 | run_script restore_ef_loci.script.tmp 34 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_record_sim.ok: -------------------------------------------------------------------------------- 1 | 001 ffffffffffffffffffffffffffff 2 | 001 abcdefffffffffffffffffffffff 3 | 001 12345678900aabbccdd098765434 4 | 002 ffffffffffffffffffffffffffff 5 | 003 12345678900aabbccdd098765434 6 | 004 ffffffffffffffffffffffffffff 7 | 005 12345678900aabbccdd098765434 8 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_record_sim.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/DF.TELECOM/EF.CCP > restore_ef_ccp.script.tmp 6 | 7 | # Select an arbitrary file to work with 8 | select MF/DF.TELECOM/EF.CCP 9 | 10 | # Clear file contents 11 | update_record 1 ffffffffffffffffffffffffffff 12 | read_record 1 > test_record_sim.tmp 13 | 14 | # Write some short pattern to the file, expect tail to be padded with 0xff 15 | update_record 1 abcdef 16 | read_record 1 >> test_record_sim.tmp 17 | 18 | # Write some pattern to three different records 19 | update_record 1 12345678900AABBCCDD098765434 20 | update_record 3 12345678900AABBCCDD098765434 21 | update_record 5 12345678900AABBCCDD098765434 22 | read_records >> test_record_sim.tmp 23 | 24 | # Restore modified files to their original state 25 | run_script restore_ef_ccp.script.tmp 26 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_content/test_record_uicc.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.USIM/EF.BDN > restore_ef_bdn.script.tmp 6 | 7 | # Select an arbitrary file to work with 8 | select MF/ADF.USIM/EF.BDN 9 | 10 | # Clear file contents 11 | update_record 1 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 12 | read_record 1 > test_record_uicc.tmp 13 | 14 | # Write some short pattern to the file, expect tail to be padded with 0xff 15 | update_record 1 abcdef 16 | read_record 1 >> test_record_uicc.tmp 17 | 18 | # Write some pattern to three different records 19 | update_record 1 0123456789abcdef0123456789abcdef0123456789abcdef0123456789 20 | update_record 5 0123456789abcdef0123456789abcdef0123456789abcdef0123456789 21 | update_record 10 0123456789abcdef0123456789abcdef0123456789abcdef0123456789 22 | read_records >> test_record_uicc.tmp 23 | 24 | # Write some json encoded content to three different records 25 | update_record_decoded 1 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }' 26 | update_record_decoded 5 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }' 27 | update_record_decoded 10 '{ "alpha_id": "", "len_of_bcd": 7, "ton_npi": { "ext": true, "type_of_number": "reserved_for_extension", "numbering_plan_id": "reserved_for_extension" }, "dialing_nr": "1234567", "cap_conf_id": 42, "ext4_record_id": 23 }' 28 | read_records_decoded >> test_record_uicc.tmp 29 | read_record_decoded 1 >> test_record_uicc.tmp 30 | 31 | # Restore modified files to their original state 32 | run_script restore_ef_bdn.script.tmp 33 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/file_specific/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/ef_imsi.ok: -------------------------------------------------------------------------------- 1 | { 2 | "imsi": "262421414141414" 3 | } 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test_update_imsi_plmn(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | 29 | self.runPySimShell(cardname, "test_update_imsi_plmn.script", add_adm = True) 30 | self.assertEqualFiles("ef_imsi.tmp") 31 | 32 | def test_ef_ust(self): 33 | cardname = 'sysmoISIM-SJA5-S17' 34 | 35 | self.runPySimShell(cardname, "test_ef_ust.script", add_adm = True) 36 | self.assertEqualFiles("test_ef_ust.tmp") 37 | 38 | def test_ef_ist(self): 39 | cardname = 'sysmoISIM-SJA5-S17' 40 | 41 | self.runPySimShell(cardname, "test_ef_ist.script", add_adm = True) 42 | self.assertEqualFiles("test_ef_ist.tmp") 43 | 44 | if __name__ == "__main__": 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/test_ef_ist.ok: -------------------------------------------------------------------------------- 1 | Checking service No 2 (inactive) 2 | Checking service No 5 (active) 3 | Checking service No 6 (inactive) 4 | Checking service No 7 (inactive) 5 | Checking service No 8 (inactive) 6 | Checking service No 10 (active) 7 | Checking service No 17 (inactive) 8 | Checking service No 18 (inactive) 9 | Checking service No 19 (inactive) 10 | Checking service No 20 (active) 11 | Checking service No 21 (inactive) 12 | Checking service No 22 (inactive) 13 | ===> 7 service / file inconsistencies detected 14 | 190208 15 | 190208 16 | 190208 17 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/test_ef_ist.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.ISIM/EF.IST > restore_ef_ist.script.tmp 6 | 7 | # Write some known default 8 | select MF/ADF.ISIM/EF.IST 9 | update_binary 190208 10 | 11 | # Run check 12 | ist_service_check > test_ef_ist.tmp 13 | 14 | # Make changes and see if they were applied 15 | read_binary >> test_ef_ist.tmp 16 | ust_service_activate 7 17 | read_binary >> test_ef_ist.tmp 18 | ust_service_deactivate 7 19 | read_binary >> test_ef_ist.tmp 20 | 21 | # Restore modified files to their original state 22 | run_script restore_ef_ist.script.tmp 23 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/test_ef_ust.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.USIM/EF.UST > restore_ef_ust.script.tmp 6 | 7 | # Write some known default 8 | select MF/ADF.USIM/EF.UST 9 | update_binary beff9f9de73e04080000ff730000000600000000 10 | 11 | # Run check 12 | ust_service_check > test_ef_ust.tmp 13 | 14 | # Make changes and see if they were applied 15 | read_binary >> test_ef_ust.tmp 16 | ust_service_activate 150 17 | read_binary >> test_ef_ust.tmp 18 | ust_service_deactivate 150 19 | read_binary >> test_ef_ust.tmp 20 | 21 | # Restore modified files to their original state 22 | run_script restore_ef_ust.script.tmp 23 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/file_specific/test_update_imsi_plmn.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Create a backup the files we will modify 5 | export --filename MF/ADF.USIM/EF.IMSI > restore_ef_imsi.script.tmp 6 | 7 | select MF/ADF.USIM/EF.IMSI 8 | update_binary 084941414141414141 9 | update_imsi_plmn 26242 10 | read_binary_decoded > ef_imsi.tmp 11 | 12 | # Restore modified files to their original state 13 | run_script restore_ef_imsi.script.tmp 14 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/fsdump/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/fsdump/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/fsdump/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | import json 24 | from utils import * 25 | 26 | class test_case(UnittestUtils): 27 | def test(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test.script") 31 | 32 | # Try to load/parse the resulting json file to verify that the resulting JSON file is well formed 33 | fsdump_json = open("fsdump.json.tmp") 34 | json.load(fsdump_json) 35 | fsdump_json.close() 36 | 37 | # TODO: create a JSON schema and validate the contents of fsdump.json.tmp against it 38 | 39 | # Ignore hex-strings sine we are not so much interested in the actual contents 40 | ignore_regex_list = ['\"[A-Fa-f0-9]*\",', '\"[A-Fa-f0-9]*\"'] 41 | self.assertEqualFiles("fsdump.json.tmp", 42 | ignore_regex_list=ignore_regex_list) 43 | 44 | if __name__ == "__main__": 45 | unittest.main() 46 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/fsdump/test.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Dump the entire file system 5 | fsdump > fsdump.json.tmp 6 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/get_identity/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/get_identity/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/get_identity/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | from pySim.utils import is_hex 25 | 26 | class test_case(UnittestUtils): 27 | def test(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test.script", add_adm = True) 31 | suci = self.getFileContent("suci.tmp", substr_regex = ': (.*?)$') 32 | self.assertTrue(is_hex(suci, minlen = 108, maxlen = 108), 33 | "calculated SUCI (%s) is not a valid hex string or has a wrong length (%u)" % 34 | (suci, len(suci))) 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/get_identity/test.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # This test requires a sysmoISIM-SJA5 with S17 chip variant. The file DF.SAIP/EF.SUCI_Calc_Info has the same format 5 | # as DF.5GS/EF.SUCI_Calc_Info, but its location is propritary. The contents of this file are accessed only by the card 6 | # OS to calculate the SUCI, not by the UE (see also sysmoISIM-SJA5 User Manual, section 3.5.1) 7 | 8 | # Create a backup the files we will modify 9 | export --filename MF/ADF.USIM/DF.SAIP/EF.SUCI_Calc_Info > restore_ef_suci_calc_info.script.tmp 10 | export --filename MF/ADF.USIM/DF.5GS/EF.Routing_Indicator > restore_ef_routing_indicator.script.tmp 11 | export --filename MF/ADF.USIM/EF.UST > restore_ef_ust.script.tmp 12 | 13 | # Program SUCI calc info (see also 3GPP TS 31.121, section 4.9.4) 14 | select MF/ADF.USIM/DF.SAIP/EF.SUCI_Calc_Info 15 | update_binary_decoded '{ "prot_scheme_id_list": [ {"priority": 0, "identifier": 2, "key_index": 1}, {"priority": 1, "identifier": 1, "key_index": 2}, {"priority": 2, "identifier": 0, "key_index": 0}], "hnet_pubkey_list": [ {"hnet_pubkey_identifier": 27, "hnet_pubkey": "0472DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD15A7DED52FCBB097A4ED250E036C7B9C8C7004C4EEDC4F068CD7BF8D3F900E3B4"}, {"hnet_pubkey_identifier": 30, "hnet_pubkey": "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"}]}' 16 | 17 | # Set routing indicator (see also 3GPP TS 31.102, section 4.4.11.11) 18 | select MF/ADF.USIM/DF.5GS/EF.Routing_Indicator 19 | update_binary 17ffffff 20 | 21 | # Enable services (see also 3GPP TS 31.102, section 5.3.48) 22 | select MF/ADF.USIM/EF.UST 23 | ust_service_activate 124 24 | ust_service_activate 125 25 | 26 | # Calculate SUCI (see also 3GPP TS 31.102, section 7.5) 27 | select ADF.USIM 28 | get_identity > suci.tmp 29 | 30 | # Restore modified files to their original state 31 | run_script restore_ef_suci_calc_info.script.tmp 32 | run_script restore_ef_routing_indicator.script.tmp 33 | run_script restore_ef_ust.script.tmp 34 | 35 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/gp/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/get_status_isd.ok: -------------------------------------------------------------------------------- 1 | { 2 | "gp_registry_related_data": [ 3 | { 4 | "application_aid": "a000000151000000" 5 | }, 6 | { 7 | "life_cycle_state": "personalized" 8 | }, 9 | { 10 | "privileges": { 11 | "security_domain": true, 12 | "dap_verification": false, 13 | "delegated_management": false, 14 | "card_lock": false, 15 | "card_terminate": false, 16 | "card_reset": false, 17 | "cvm_management": true, 18 | "mandated_dap_verification": false, 19 | "trusted_path": true, 20 | "authorized_management": true, 21 | "token_management": false, 22 | "global_delete": true, 23 | "global_lock": true, 24 | "global_registry": true, 25 | "final_application": false, 26 | "global_service": false, 27 | "receipt_generation": false, 28 | "ciphered_load_file_data_block": false, 29 | "contactless_activation": false, 30 | "contactless_self_activation": false 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_est_scp02_csv.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD 5 | 6 | establish_scp02 --key-provider-suffix 1 --key-ver 112 --security-level 3 7 | get_data issuer_identification_number 8 | get_status isd 9 | release_scp 10 | 11 | establish_scp02 --key-provider-suffix 1 --key-ver 112 --security-level 1 12 | get_data issuer_identification_number 13 | get_status isd 14 | release_scp 15 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_est_scp02_direct.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD 5 | 6 | establish_scp02 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 112 --security-level 3 7 | get_data issuer_identification_number 8 | get_status isd 9 | release_scp 10 | 11 | establish_scp02 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 112 --security-level 1 12 | get_data issuer_identification_number 13 | get_status isd 14 | release_scp 15 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_est_scp03_csv.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3 7 | get_data issuer_identification_number 8 | get_status isd 9 | release_scp 10 | 11 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 1 12 | get_data issuer_identification_number 13 | get_status isd 14 | release_scp 15 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_est_scp03_direct.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | 6 | establish_scp03 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 50 --security-level 3 7 | get_data issuer_identification_number 8 | get_status isd 9 | release_scp 10 | 11 | establish_scp03 --key-dek $KEY_DEK --key-enc $KEY_ENC --key-mac $KEY_MAC --key-ver 50 --security-level 3 12 | get_data issuer_identification_number 13 | get_status isd 14 | release_scp 15 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_get_status.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select ADF.ISD-R 5 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3 6 | 7 | get_status isd > get_status_isd.tmp 8 | 9 | release_scp 10 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/gp/test_put_delete_key.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Establish secure channel 5 | select ADF.ISD-R 6 | establish_scp03 --key-provider-suffix 1 --key-ver 50 --security-level 3 7 | 8 | # Put a keyset 9 | put_key --key-version-nr 42 --key-id 1 --key-type aes --key-data 11111111111111111111111111111111 --key-type aes --key-data 22222222222222222222222222222222 --key-type aes --key-data 33333333333333333333333333333333 10 | 11 | # Read key information to see if the keyset was actually stored 12 | get_data key_information > key_information.tmp 13 | 14 | # Delete the keyset again 15 | delete_key --key-id 1 --key-ver 42 16 | delete_key --key-id 2 --key-ver 42 17 | delete_key --key-id 3 --key-ver 42 18 | 19 | # Release secure channel 20 | release_scp 21 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/lchan/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/lchan/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/lchan/test.ok: -------------------------------------------------------------------------------- 1 | -> 00700001 2 | <- 9000: 3 | -> 00700002 4 | <- 9000: 5 | -> 00700003 6 | <- 9000: 7 | currently selected file: MF/DF.TELECOM/EF.MSISDN (3f00/7f10/6f40) 8 | currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07) 9 | currently selected file: MF/ADF.ISIM/EF.AD (3f00/a0000000871004/6fad) 10 | [ 11 | { 12 | "response_all_ref_ar_do": null 13 | } 14 | ] 15 | -> 00708001 16 | <- 9000: 17 | -> 00708002 18 | <- 9000: 19 | -> 00708003 20 | <- 9000: 21 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/lchan/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | import json 24 | from utils import * 25 | 26 | class test_case(UnittestUtils): 27 | def test(self): 28 | cardname = 'sysmoISIM-SJA5-S17' 29 | 30 | self.runPySimShell(cardname, "test.script") 31 | self.assertEqualFiles("test.tmp") 32 | 33 | if __name__ == "__main__": 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/lchan/test.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Open all three additional logical channels 5 | set apdu_trace true 6 | open_channel 1 > test.tmp 7 | open_channel 2 >> test.tmp 8 | open_channel 3 >> test.tmp 9 | set apdu_trace false 10 | 11 | # Switch through the channels and produce a different state on each channel 12 | select DF.TELECOM 13 | switch_channel 1 14 | select ADF.USIM 15 | switch_channel 2 16 | select ADF.ISIM 17 | switch_channel 3 18 | select ADF.ARA-M 19 | 20 | # Switch through the channels and do something to prove that we are still in the expected state 21 | switch_channel 0 22 | select EF.MSISDN 23 | select >> test.tmp 24 | switch_channel 1 25 | select EF.IMSI 26 | select >> test.tmp 27 | switch_channel 2 28 | select EF.AD 29 | select >> test.tmp 30 | switch_channel 3 31 | aram_delete_all 32 | aram_get_all >> test.tmp 33 | 34 | # Close all logical channels again 35 | switch_channel 0 36 | set apdu_trace true 37 | close_channel 1 >> test.tmp 38 | close_channel 2 >> test.tmp 39 | close_channel 3 >> test.tmp 40 | set apdu_trace false 41 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/navigate_fs/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/checkpoints_sim.ok: -------------------------------------------------------------------------------- 1 | currently selected file: MF/DF.GSM/EF.IMSI (3f00/7f20/6f07) 2 | currently selected file: MF/DF.TELECOM/EF.MSISDN (3f00/7f10/6f40) 3 | currently selected file: MF/DF.GSM (3f00/7f20) 4 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/checkpoints_uicc.ok: -------------------------------------------------------------------------------- 1 | currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07) 2 | currently selected file: MF/ADF.ISIM/EF.AD (3f00/a0000000871004/6fad) 3 | currently selected file: MF/ADF.ARA-M (3f00/a00000015141434c00) 4 | currently selected file: MF (3f00) 5 | currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07) 6 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 7 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 8 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 9 | currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07) 10 | currently selected file: MF/ADF.USIM/EF.AD (3f00/a0000000871002/6fad) 11 | currently selected file: MF/ADF.ARA-M (3f00/a00000015141434c00) 12 | currently selected file: MF (3f00) 13 | currently selected file: MF/ADF.USIM/EF.IMSI (3f00/a0000000871002/6f07) 14 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 15 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 16 | currently selected file: MF/DF.TELECOM/DF.MCS/EF.MST (3f00/7f10/5f3d/4f01) 17 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test_uicc(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | 29 | self.runPySimShell(cardname, "test_uicc.script") 30 | self.assertEqualFiles("checkpoints_uicc.tmp") 31 | 32 | def test_sim(self): 33 | # This test is to make sure that we still can navigate classic SIM cards 34 | cardname = 'sysmoSIM-GR1' 35 | 36 | self.runPySimShell(cardname, "test_sim.script") 37 | self.assertEqualFiles("checkpoints_sim.tmp") 38 | 39 | if __name__ == "__main__": 40 | unittest.main() 41 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/test_sim.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | select DF.GSM 5 | select EF.IMSI 6 | select > checkpoints_sim.tmp 7 | 8 | select MF 9 | select DF.TELECOM 10 | select EF.MSISDN 11 | select >> checkpoints_sim.tmp 12 | 13 | select MF 14 | select EF.ICCID 15 | select DF.GSM 16 | select >> checkpoints_sim.tmp 17 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/navigate_fs/test_uicc.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Navigate using filenames 5 | 6 | select ADF.USIM 7 | select EF.IMSI 8 | select > checkpoints_uicc.tmp 9 | 10 | select ADF.ISIM 11 | select EF.AD 12 | select >> checkpoints_uicc.tmp 13 | 14 | select ADF.ARA-M 15 | select >> checkpoints_uicc.tmp 16 | select MF 17 | select >> checkpoints_uicc.tmp 18 | 19 | select ADF.USIM/EF.IMSI 20 | select >> checkpoints_uicc.tmp 21 | 22 | select ADF.USIM 23 | select DF.5GS 24 | select ../../DF.TELECOM/DF.MCS/EF.MST 25 | select >> checkpoints_uicc.tmp 26 | 27 | select ADF.USIM 28 | select DF.5GS 29 | select /DF.TELECOM/DF.MCS/EF.MST 30 | select >> checkpoints_uicc.tmp 31 | 32 | select ADF.USIM 33 | select DF.5GS 34 | select /DF.TELECOM/../DF.TELECOM/DF.MCS/EF.MST 35 | select >> checkpoints_uicc.tmp 36 | 37 | # Navigate using FIDs 38 | 39 | select a0000000871002 40 | select 6f07 41 | select >> checkpoints_uicc.tmp 42 | 43 | select a0000000871002 44 | select 6fad 45 | select >> checkpoints_uicc.tmp 46 | 47 | select a00000015141434c00 48 | select >> checkpoints_uicc.tmp 49 | select 3f00 50 | select >> checkpoints_uicc.tmp 51 | 52 | select ADF.USIM/EF.IMSI 53 | select >> checkpoints_uicc.tmp 54 | 55 | select a0000000871002 56 | select 5fc0 57 | select ../../7f10/5f3d/4f01 58 | select >> checkpoints_uicc.tmp 59 | 60 | select a0000000871002 61 | select 5fc0 62 | select 3f00/7f10/5f3d/4f01 63 | select >> checkpoints_uicc.tmp 64 | 65 | select a0000000871002 66 | select 5fc0 67 | select 3f00/7f10/../7f10/5f3d/4f01 68 | select >> checkpoints_uicc.tmp 69 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/verify_adm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-shell_test/verify_adm/__init__.py -------------------------------------------------------------------------------- /tests/pySim-shell_test/verify_adm/test.py: -------------------------------------------------------------------------------- 1 | # Testsuite for pySim-shell.py 2 | # 3 | # (C) 2024 by sysmocom - s.f.m.c. GmbH 4 | # All Rights Reserved 5 | # 6 | # Author: Philipp Maier 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | import unittest 22 | import os 23 | from utils import * 24 | 25 | class test_case(UnittestUtils): 26 | def test(self): 27 | cardname = 'sysmoISIM-SJA5-S17' 28 | adm1 = self.cards[cardname]['adm1'] 29 | 30 | # Provide ADM pin via commandline on startup 31 | self.runPySimShell(cardname, "test_cmdline.script", add_adm = True, no_exceptions = True) 32 | 33 | # Provide ADM pin via CSV file (CardKeyProvider) 34 | self.runPySimShell(cardname, "test_csv.script", add_csv = True, no_exceptions = True) 35 | 36 | # Privide ADM pin via direct input 37 | self.equipTemplate("test_direct.script", ADM=adm1) 38 | self.runPySimShell(cardname, "test_direct.script", no_exceptions = True) 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/verify_adm/test_cmdline.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # (No extra ADM pin verification required) 5 | 6 | # Perform an operation that requires ADM access 7 | select DF.SYSTEM 8 | select EF.SIM_AUTH_KEY 9 | read_binary 10 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/verify_adm/test_csv.script: -------------------------------------------------------------------------------- 1 | set debug true 2 | set echo true 3 | 4 | # Verify ADM PIN 5 | verify_adm 6 | 7 | # Perform an operation that requires ADM access 8 | select DF.SYSTEM 9 | select EF.SIM_AUTH_KEY 10 | read_binary 11 | -------------------------------------------------------------------------------- /tests/pySim-shell_test/verify_adm/test_direct.template: -------------------------------------------------------------------------------- 1 | set debug true 2 | 3 | # Verify ADM PIN 4 | verify_adm $ADM 5 | 6 | # Perform an operation that requires ADM access 7 | select DF.SYSTEM 8 | select EF.SIM_AUTH_KEY 9 | read_binary 10 | -------------------------------------------------------------------------------- /tests/pySim-trace_test/pySim-trace_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Utility to verify the functionality of pySim-trace.py 4 | # 5 | # (C) 2023 by Sysmocom s.f.m.c. GmbH 6 | # All Rights Reserved 7 | # 8 | # Author: Philipp Maier 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 . 22 | 23 | PYSIM_TRACE=./pySim-trace.py 24 | GSMTAP_TRACE=./tests/pySim-trace_test/pySim-trace_test_gsmtap.pcapng 25 | TEMPFILE=temp.tmp 26 | 27 | export PYSIM_INTEGRATION_TEST=1 28 | # to avoid termcolor.colored generating colors; https://github.com/termcolor/termcolor 29 | export ANSI_COLORS_DISABLED=1 30 | 31 | echo "pySim-trace_test - a test program to test pySim-trace.py" 32 | echo "========================================================" 33 | 34 | function usage { 35 | echo "Options:" 36 | echo "-o: generate .ok file" 37 | } 38 | 39 | function gen_ok_file { 40 | $PYSIM_TRACE gsmtap-pyshark-pcap -f $GSMTAP_TRACE > $GSMTAP_TRACE.ok 41 | echo "Generated file: $GSMTAP_TRACE.ok" 42 | echo "------------8<------------" 43 | cat $GSMTAP_TRACE.ok 44 | echo "------------8<------------" 45 | } 46 | 47 | function run_test { 48 | $PYSIM_TRACE gsmtap-pyshark-pcap -f $GSMTAP_TRACE | tee $TEMPFILE 49 | if [ ${PIPESTATUS[0]} -ne 0 ]; then 50 | echo "" 51 | echo "========================================================" 52 | echo "Testrun with $GSMTAP_TRACE failed (exception)." 53 | rm -f $TEMPFILE 54 | exit 1 55 | fi 56 | 57 | DIFF=`diff $GSMTAP_TRACE.ok $TEMPFILE` 58 | if ! [ -z "$DIFF" ]; then 59 | echo "Testrun with $GSMTAP_TRACE failed (unexpected output)." 60 | echo "------------8<------------" 61 | diff $GSMTAP_TRACE.ok $TEMPFILE 62 | echo "------------8<------------" 63 | rm -f $TEMPFILE 64 | exit 1 65 | fi 66 | 67 | echo "" 68 | echo "========================================================" 69 | echo "trace parsed without problems -- everything ok!" 70 | rm -f $TEMPFILE 71 | } 72 | 73 | OPT_GEN_OK_FILE=0 74 | while getopts ":ho" OPT; do 75 | case $OPT in 76 | h) 77 | usage 78 | exit 0 79 | ;; 80 | o) 81 | OPT_GEN_OK_FILE=1 82 | ;; 83 | \?) 84 | echo "Invalid option: -$OPTARG" >&2 85 | exit 1 86 | ;; 87 | esac 88 | done 89 | 90 | if [ $OPT_GEN_OK_FILE -eq 1 ]; then 91 | gen_ok_file 92 | exit 0 93 | else 94 | run_test 95 | exit 0 96 | fi 97 | -------------------------------------------------------------------------------- /tests/pySim-trace_test/pySim-trace_test_gsmtap.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/pySim-trace_test/pySim-trace_test_gsmtap.pcapng -------------------------------------------------------------------------------- /tests/unittests/test_euicc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import unittest 4 | 5 | from pySim.euicc import * 6 | 7 | class TestEid(unittest.TestCase): 8 | 9 | def test_eid_verify(self): 10 | for eid in ['89049032123451234512345678901235', '89086030202200000022000023022943', 11 | '89044045116727494800000004479366', 89044045116727494800000004479366]: 12 | self.assertTrue(verify_eid_checksum(eid)) 13 | 14 | def test_eid_verify_wrong(self): 15 | self.assertFalse(verify_eid_checksum('89049032123451234512345678901234')) 16 | self.assertFalse(verify_eid_checksum(89049032123451234512345678901234)) 17 | 18 | def test_eid_encode_with_32_digits(self): 19 | self.assertEqual(compute_eid_checksum('89049032123451234512345678901200'), '89049032123451234512345678901235') 20 | self.assertEqual(compute_eid_checksum('89086030202200000022000023022900'), '89086030202200000022000023022943') 21 | 22 | def test_eid_encode_with_30digits(self): 23 | self.assertEqual(compute_eid_checksum('890490321234512345123456789012'), '89049032123451234512345678901235') 24 | 25 | def test_eid_encode_with_wrong_csum(self): 26 | # input: EID with wrong checksum 27 | self.assertEqual(compute_eid_checksum('89049032123451234512345678901299'), '89049032123451234512345678901235') 28 | self.assertEqual(compute_eid_checksum(89049032123451234512345678901299), '89049032123451234512345678901235') 29 | 30 | if __name__ == "__main__": 31 | unittest.main() 32 | -------------------------------------------------------------------------------- /tests/unittests/test_javacard.cap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/pysim/c7c48718ba3637e29fc6a7af4e2e39ba0679bb8d/tests/unittests/test_javacard.cap -------------------------------------------------------------------------------- /tests/unittests/test_javacard.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import unittest 5 | from pySim.javacard import * 6 | 7 | class TestJavacard(unittest.TestCase): 8 | 9 | def test_CapFile(self): 10 | loadfile="01000fdecaffed010204000105d07002ca4402001f000f001f000c002800420018006d00320017000000a900040002002203010004002803020107a0000000620101060210a0000000090003ffffffff8910710002000107a000000062000103000c0108d07002ca44900101002006001843800301ff0007020000002f00398002008101010881000007006d000911188c00048d00012c18197b0002037b00029210240303038b000388007a02318f00053d8c00062e1b8b00077a0120188b000860037a7a02228d00092d1d10076b101a8b000a321fae006b06188c000b7a06118d000c2c1903077b000d037b000d928b000e198b000f3b7a08003200040002000203001857656c636f6d6520746f20546f6f7243616d70203230313203000a48656c6c6f2c2053544b0000000005004200100200000006810900050000020381090b0680030001000000060000010380030103800303068108000381080c0600005306810a000500000003810a1303810a1609001700021e2d0011050306040908040507090a0a06070404040b00a901000100000300030005800281018100ff080000000028ff08000002002800020000008003ff820001002f001d0000000000090020003f000d000000000701002f0042000800000000080100390046001800000000ff020053002f0018000000000010002200240028002a002fffff002f002f003100330022002f00370028003b002201300568109001b008b44323430110012005681080056810a00633b44104b431066800a10231" 11 | cap = CapFile(os.path.dirname(os.path.abspath(__file__)) + "/test_javacard.cap") 12 | self.assertTrue(b2h(cap.get_loadfile()) == loadfile) 13 | self.assertTrue(cap.get_loadfile_aid() == "d07002ca44") 14 | self.assertTrue(cap.get_applet_aid() == "d07002ca44900101") 15 | 16 | 17 | if __name__ == "__main__": 18 | unittest.main() 19 | --------------------------------------------------------------------------------