aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2022-05-25ts_102_221: The BTLV IEs FILE SIZE and TOTAL FILE SIZE have a min lengthpmaier/updatesPhilipp Maier2-3/+6
The TLV IEs FILE SIZE and TOTAL FILE SIZE have a minimum length of 2 byte. Even when the length is in the single digit range two bytes must be used. See also: ETSI TS 102 221, section 11.1.1.4.1 and 11.1.1.4.2 Change-Id: Ief113ce8fe3bcae2c9fb2ff4138df9ccf98d26ff
2022-05-25ts_102_221: fix SFI generationPhilipp Maier1-3/+4
The generation of the SFI does not work. The result is always a zero length TLV IE. Change-Id: Iaa38d2be4719f12c1d7b30a8befe278f1ed78ac1
2022-05-20filesystem: also return the encoded FCP from probe_filePhilipp Maier1-2/+3
The method probe_file returns the decoded FCP after it managed to successfully probe the file. Lets also return the encoded FCP string, as it is needed by the caller. Change-Id: Ia5659e106fb0d6fb8b77506a10eba309e764723e
2022-05-20pySim-shell: match SW in apdu commandPhilipp Maier1-1/+5
The apdu command has no option to match the resulting SW. Lets add a new option for this. Change-Id: Ic5a52d7cf533c51d111850eb6d8147011a48ae6c
2022-05-20pySim-shell: make APDU command available on the lowest levelPhilipp Maier1-15/+21
The apdu command is used to communicate with the card on the lowest possible level. Lets make it available even before a card profile (rs) is avalable. This is especially useful when the card has no files on it, in this situation pySim-shell will not be able to assign a profile to the card at all. We can then use the apdu command to equip the card with the most basic files and start over. Change-Id: I601b8f17bd6af41dcbf7bbb53c75903dd46beee7
2022-05-19pySim-shell: catch exceptions from walk() while exportingPhilipp Maier1-5/+12
When we run the exporter we also get an error summary at the end. However, if walk() throws an eception this stops the exporter immediately and we won't get the summpary. Lets catch exceptions from walk as well so that we are able to end gracefully. Change-Id: I3edc250ef2a84550c5b821a72e207e4d685790a5
2022-05-19pySim-shell: add export option to add CREATE FILE APDUsPhilipp Maier1-3/+45
Export currently only exports the contents of the files. When running the resulting script it is expected that the files already exist. This is normaly the case. However, when replaying the script on a blank card the files do not exist yet. The CREATE FILE parameters are created based on the FCP template that the card returns when the file is selected. In some cases the returned FCP template may lacl data that the card needs to create the file properly. This means that the --create parameter must be used with caution and possibly manual re-work of the result is necessary. Change-Id: If529b86062f7c678c9c75f46ce9ca116cea8b47b
2022-05-19pySim-shell: extend walk() so that we can also have action of ADF or DFPhilipp Maier1-9/+15
The walk() method that we use to traverse the whole file system tree is currently only able to execute action callbacks on EFs. Lets add a mechanism that allows us to have a second callback that is executed when we hit a DF or ADF. Change-Id: Iabcd78552a14a2d3f8f31273dda7731e1f640cdb
2022-05-19pySim-shell: more generic export optionsPhilipp Maier1-6/+8
The as_json parameter has been added as an additional parameter to the export function. Lets use a dictionary here and put the parameter in it. This makes it easier to add more options in the future Change-Id: Ie860eec918e7cdb01651642f4bc2474c9fb1924f
2022-05-19pySim-shell: explain why we insist on a DF or ADFPhilipp Maier1-0/+4
Change-Id: I155cefb10864432d59a0a66410783b4c9772f8a4
2022-05-06ts_102_222: Set number of records when creating linear filesChristian Amsüss1-0/+3
This information is mandatory for linear files as per TS 102 221 V15 section 11.1.1.4.3. This might not have been spotted earlier because cards of type sysmoISIM-SJA2 accept creation without it as well. Change-Id: I8aeb869c601ee5d1c8b02da6d72eb3c50e347982
2022-04-25transport/pcsc: throw ReaderError with a messageVadim Yanitskiy1-1/+1
Before this patch: $ ./pySim-shell.py -p 0 Card reader initialization failed with an exception of type: <class 'pySim.exceptions.ReaderError'> after: $ ./pySim-shell.py -p 0 Card reader initialization failed with exception: No reader found for number 0 Change-Id: Id08c4990857f7083a8d1cefc90ff85fc20ab6fef
2022-04-21SimCard.reset(): fix SyntaxWarning: 'is' with a literalVadim Yanitskiy1-1/+1
Change-Id: I5860179acd1cb330e91dbe5b57cd60cd520f2d9d
2022-04-05ts_102_221: Add encode/write support of EF.ARR recordsHarald Welte1-0/+5
With this change, we can also encode/write EF.ARR records, not just decode/read. Change-Id: Id0da2b474d05aba12136b9cae402ad8326700182
2022-04-05utils: Add DataObjectSequence.encode_multi()Harald Welte1-0/+12
This is the analogous to the decode_multi() method. Change-Id: Ifdd1b1bd4d67f447638858c3e92742ca6f884bfa
2022-04-05utils: Fix bugs in DataObject encodersHarald Welte2-2/+19
The DataObject is some weird / rarely used different code than the normal TLV encoder/decoder. It has apparently so far only been used for decoding, without testing the encoding side, resulting in related bugs. Let's fix those that I encountered today, and add a test case. Change-Id: I31370066f43c22fc3ce9e2b9ee75986a652f6fc4
2022-03-27ts_31_103: Correct file-id of EF.DOMAIN in ADF.ISIMæstrid smith1-1/+1
While the short ID of this file is 05, the actual file-id is 6f03. Reference to TS 31.103 section 4.2.3. Change-Id: Idd572ab064ea38e74dffd583c27ea505b23214a2
2022-03-27ts_31_102: Avoid pylint false positiveHarald Welte1-0/+1
This should avoid the following pylint error: ************* Module pySim.ts_31_102 pySim/ts_31_102.py:621:100: E0601: Using variable 'sw' before assignment (used-before-assignment) Change-Id: I0bb9607cdab0e6e3cd17b4d27129a51a607bc0f2
2022-03-01pySim-shell: Add 'decode_hex' command for transparent + linear EFHarald Welte2-0/+36
These commands can be used to decode a user-provided hex-string, instead of decoding the data read from the file. This is useful for quickly manually decoding some values read from other locations, such as e.g. copy+pasted from a eSIM profile in ASN.1 value notation. Change-Id: I81f73bce2c26e3e5dfc7538d223bb2d2483c7fa0
2022-03-01Initial support for GlobalPlatformHarald Welte3-0/+262
One can now select the Issuer Security Domain (hard-coded to a000000003000000) and issue get_data requests. FCI and other TLV objects are dcoded, e.g. pySIM-shell (MF)> select ADF.ISD { "application_id": "a000000003000000", "proprietary_data": { "maximum_length_of_data_field_in_command_message": 255 } } pySIM-shell (MF/ADF.ISD)> get_data CardData { "card_data": [ { "card_recognition_data": [ { "object_identifier": "2a864886fc6b01" }, { "card_management_type_and_version": [ { "object_identifier": "2a864886fc6b02020101" } ] }, { "card_identification_scheme": [ { "object_identifier": "2a864886fc6b03" } ] }, { "secure_channel_protocol_of_isd": [ { "object_identifier": "2a864886fc6b040215" } ] } ] } ] } Change-Id: If11267d45ab7aa371eea8c143abd9320c32b54d0
2022-02-25ts_31_102: Further decode TAI in EF.OPL5GHarald Welte1-1/+2
The TAI is not just an opaque bytestring but it consists of 3 fields. Change-Id: Ie5a5ce74713deb0e151218ae553d3f3d96cef17d
2022-02-25ts_31_102: Further decode LAI in EF_LOCIHarald Welte1-2/+2
Change-Id: I21d9356e541eb320848a373804781ae0bef7d012
2022-02-25ts_51_011: Better decode of EF_OPL LAIHarald Welte1-1/+1
before: { "lai": "62f2300000fffe", "pnn_record_id": 1 } after: { "lai": { "mcc_mnc": "262f03", "lac_min": "0000", "lac_max": "fffe" }, "pnn_record_id": 1 } Change-Id: I82581220e9c33a8e67cbefd5dfeb40bbc2c31179
2022-02-25ts_51_011: Properly decode EF.OPLHarald Welte1-1/+1
The OPL has 7 bytes "LAI" as the LAI actually contains a LAC range (so two more bytes for the end of the 16bit range). Change-Id: I74bcf10b0a8977af0f2844044a812c5780af1706
2022-02-25ts_31_102: Fix decoding of UServiceTableHarald Welte1-1/+1
range(0,7) in python is 0..6, and not 0..7, so we need range(0.8) to produce the desired range covering all bits of a byte. This resulted in services 8,16,24,... not being displayed in the decoded output of EF.UST / EF.IST. Change-Id: I22bbc481de342685352bf5b13d54931d3f37f9b7
2022-02-25ts_102_221: Fix decoding the 'num_of_rec' fieldHarald Welte1-1/+1
It is a 8bit integer, not a 16bit integer. See TS 102 221 11.1.1.4.3 Change-Id: I3e258547dad21a248650cfbc02e0576268d3b3fd
2022-02-25ts_102_221: properly decode short file identifierHarald Welte1-1/+8
The SFI TLV contanins not the raw SFI, but it contains the SFI shifted to left by 3 bits (for some strange reason). So let's un-shift it. Change-Id: Ibc69b99010d2a25cbb69b6a3d1585d0cb63f1345
2022-02-21add scripts/deactivate-ims.script to deactivate IMS related servicesHarald Welte1-0/+74
Change-Id: I0cd93c8fa0024dd9d93647c565190abe94d3097e
2022-02-17Add scripts/deacivate-5g.scriptHarald Welte1-0/+69
This script can be used to deactivate all 5G related services and files. Change-Id: I5dc3e9f0ae76a7ae57484e5a3369e11ff02c7eca
2022-02-15doc: Improve documentation in various placesHarald Welte6-28/+91
* don't duplicate information between .rst files and docstrings * if there's more than a trivial single-line documentation, put it as docstring into the python source and use ".. argparse" to pul it into the manual * add documentation for some commands for which it was missing * show one level deeper in the navigation table, listing the commands Change-Id: Ib88bb7d12faaac7d149ee1f6379bc128b83bbdd5
2022-02-15docs: Document missing 'status' command in 7816 sectionHarald Welte1-0/+35
Change-Id: I9af85a36bc4f24c3a22b9b2a6b8e2abd86edfe4e
2022-02-15shell: Proper argparser (for help + manual) activate_fileHarald Welte2-4/+11
Change-Id: I5929ae3deff4d15b5db4a1d866576271c57a955f
2022-02-15pySim-shell: export: Add FCP template to exportHarald Welte2-1/+6
The FCP template provides us a lot of context, like the permissions of a given file. Let's make it part of the 'export' output, both in raw and in decoded form. Change-Id: I05f17bbebd7a9b3535204b821900851a5f66e88f Closes: OS#5457
2022-02-15docs/legcay.txt: Point to pySim-shell as replacementHarald Welte1-0/+8
Change-Id: I9ca6b9d8c35e23be2ec8752107bb7d1e4f6f9bc1
2022-02-15pySim-shell: support TS 102 222 administrative commandsHarald Welte5-5/+260
This adds support for creating/deleting and terminating files, as well as support for permanent card termination. Change-Id: I5b1ffb1334afa18d62beb642268066a30deb7ea6
2022-02-15ts_102_221: Implement File Descriptor using constructHarald Welte5-43/+50
This automatically adds encoding support, which is needed for upcoming CREATE FILE support. Change-Id: Ia40dba4aab6ceb9d81fd170f7efa8dad1f9b43d0
2022-02-15pySim-shell: Allow selecting of deep paths like DF.GSM/EF.IMSIHarald Welte1-0/+16
With this patch applied, users can directly enter commands like select DF.GSM/EF.IMSI or select ADF.USIM/DF.5GS/EF.5GAUTHKEYS This feature doesn't have tabl completion, so it's mostly useful for when you know what to select, or for use within scripts. Change-Id: I681a132eb2df4b2aba4c2ccbdd21c6d5b88443e3
2022-02-15ts_31_103: TLV definitions for IMS, XCAP and MudMid configurationHarald Welte1-0/+56
Change-Id: I9a90ee978db668a70259eb48085ff5384cf696d6
2022-02-15ts_51_011: EF_CMI: Decoder the alpha_id stringHarald Welte1-1/+1
Change-Id: I45efe29ab98972945b4257229a995815f5632536
2022-02-15ts_51_011: Convert EF_ADN and EF_ACC to ConstructHarald Welte1-13/+7
this has the benefit of providing encoding support for free. Change-Id: I31c118082e92892486c3688de2197c0c6dd2750e
2022-02-15ts_51_011: Proper decode of EF.SMSPHarald Welte2-1/+62
Full decode of the SSM Parameters File Change-Id: Iac5bb87ed3350978dc8b207f052510fdba2e4883
2022-02-15Improve IST/UST check documentation (for the user manual)Harald Welte2-10/+15
Change-Id: I18093d795721f2e729eff858c8922edde9e84451
2022-02-15ust_service_check: proper treatment of files in sub-directoriesHarald Welte2-15/+71
We must not only consider files in the current directory (ADF.USIM) but also in its sub-directories. This requires us to be able to determine the path we need to traverse between the currently selected file (EF.UST) and the respective file in some other directory, which is implemented via CardFile.build_select_path_to(). Change-Id: I61797fefa9dafa36a8a62c11aa2cfaeecb015740
2022-02-15ts_31_102: service annotations for DF.{5GS,WLAN,HNB}Harald Welte2-46/+51
We had service annotations only for ADF.USIM so far, but not for the related sub-directories. Change-Id: Iaa56a26ba53eaf18fce14845ae07a27c52a2c58a Note: The code doesn't make use of them in any reasonable way yet!
2022-02-15ts_31_102: Use perror() instead of poutput() for errorsHarald Welte1-5/+5
This adds colorization and ensures they go to stderr and not stdout Change-Id: I34b8f974b4ff13002679c4700bdf604db7d7f3cd
2022-02-15ts_31_102: Add more EF.UST checks to 'ust_service_check' commandHarald Welte1-3/+30
* check for service dependencies listed in TS 31.102 * print number of errors encountered Change-Id: Id47f8f2c8de299bbf91243d0c8900d22a7d35b10
2022-02-15filesystem: Fix CardMF.get_app_names()Harald Welte1-1/+1
This function was not used and doesn't work without this patch. Change-Id: Id3dad7d97fe29a25792d2f8f0e879666c1d9c136
2022-02-15Split EF.UST handling from EF.IST and EF.SSTHarald Welte3-39/+114
The existing code had the following serious problems: * when trying to update EF.SST or EF.IST, it would write to EF.UST ! * shell commands were called ust_* even for the EST/IST files Let's introduce the proper separation between what is shared and what is file-specific. Change-Id: Ie55669ca37a4762fac9f71b1db528ca67056e8dd
2022-02-15ts_31_102: Add "ust_service_check" command.Harald Welte1-0/+36
This command performs a consistency check between the services activated in EF.UST/EF.IST and the files that should (or should not) be active/selectable for the given service. Produces output like: Checking service No 48 (inactive) ERROR: File EF(EF.MWIS) is selectable but should not! Checking service No 49 (active) ERROR: File EF(EF.CFIS) is not selectable (SW=6a82) but should! Change-Id: Iea7166959e2015eb8fa34d86036560c9e42ce4d3
2022-02-15README.md: Remove old usage examples, refer to user manual insteadHarald Welte1-36/+20
We want people to use pySim-shell and should not mislead them by having usage examples of old tools in README.md. Also, all documentation should be in the manuals, let's try to have bits and pieces in various places. Change-Id: I8c07a2e0778ab95fb42be6074acb80874e681d20