aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2020-04-01Use read_binary function of card class to read GID2 and reduce code duplicationSupreeth Herle2-8/+1
Change-Id: I5d80fcc1446a6691b8e2a09bcec558148fa31ab2
2020-04-01cards.py: Add generic function to read EF record in card classSupreeth Herle1-0/+4
This is a generic function applicable for reading EF records which doesnt require further processing such EF.SMSP etc while decoding and also to avoid code duplication. Change-Id: Ic0b4aa11e962b4bb328447b11533136a29ff72d3
2020-04-01cards.py: Add generic function to read EF binary to card classSupreeth Herle1-0/+4
This is a generic function applicable for reading EFs which doesnt require further processing such as GID1, GID2 etc while decoding and also to avoid code duplication. Change-Id: If3d8fdddb26f9776c89fd442d1d95b83e0d1476b
2020-03-22Move parsing of GID2 to generic Card classSupreeth Herle2-1/+8
Change-Id: I3fe4b08c888a39cda7e7fce7a467f17908bdc3ad
2020-03-22Move parsing of GID1 to generic Card classSupreeth Herle2-1/+8
Change-Id: Ie96408b1eecd6fc2595d619f6f0e3af851dacecb
2020-03-22pySim-read.py: Use the method declared in cards.py to read IMSISupreeth Herle1-2/+2
Change-Id: I2709b040d956a3a2b9210aa78c82a6ccf482f761
2020-03-22pySim-read.py: Use the method declared in cards.py to read ICCIDSupreeth Herle1-2/+2
Change-Id: I0dcda1ea617f3febe246b360b95887c04e5d2629
2020-03-22pySim-read.py: Added a common card detection function for both pySim-prog.py ↵Supreeth Herle9-36/+44
and pySim-read.py This function is used to detect the card type and return Card class/Card subclasses object if its a know card or else None. Also, an initial step towards refactoring of code. Change-Id: I71f57c6403dc933bd9d54f90df3d3fe105b4f66f
2020-03-19cards.py: Added parsing of all the AIDs in the UICCSupreeth Herle1-0/+15
Introduced a new member variable and a member function to Card class to fetch and store the AIDs present in UICC. And, this variable (a list) is populated by reading the EF 2f00 under MF 3f00 (function read_aids()). Change-Id: I7ca77a73ebb42a8ba1381588d878040675d3019a
2020-03-13pySim-read.py: support for reading GID2 from SIMSupreeth Herle7-0/+16
Change-Id: I0e893c3929aa1be6b55af296484811a7b94db560
2020-03-13pySim-read.py: support for reading GID1 from SIMSupreeth Herle7-0/+16
Change-Id: I15d061daed20f770b9041977a0b1fc4fe44a8f95
2020-03-11sysmoISIM-SJA2: Add suport for USIM-only and ISIM-only cardsPhilipp Maier1-10/+12
When pysim-prog programms the application specific files of ISIM and USIM it selects the application by its AID first. If depending on the card profile one of the applications is missing the selection of the related ADF will fail. Lets check the presence of the AID first and if it is not present lets skip the programming of the related files. Change-Id: I0eec6ed244320fcd4dc410b6fab20df9c64ff906 Related: SYS#4817
2020-03-11sysmiISIM-SJA2: add support for new card model / os versionPhilipp Maier1-0/+5
There is a new card version with a different ATR, lets add the ATR for this card to support it as well. Change-Id: I222faea89c1df58c36a19b28449dffb84a956e74 Related: SYS#4817
2020-02-27cards: Python 3 fix: use the floor division operator //Vadim Yanitskiy1-4/+4
Change-Id: I21de34133dbc5d859a5b744adc74f706ba2f0dd8
2020-02-27commands: Python 3 fix: properly distinguish str and listVadim Yanitskiy1-8/+2
Unlike Python 2, in Python 3 strings also have attribute '__iter__'. Because of that, a string could be passed to select_file(), that actually expects a list as the first parameter. P.S. Madness, Python 3 is just a new different language... P.P.S. They should have renamed it not to confuse people. Change-Id: I92af47abb6adff0271c55e7f278e8c5188f2be75 Fixes: OS#4419
2020-02-27transport/pcsc: explicitly specify T0 protocolVadim Yanitskiy1-1/+5
From pyscard user's guide [1]: == Selecting the card communication protocol == By defaults, the connect() method of the CardConnection object will try to connect using either the T=0 or T=1 protocol. To force a connection protocol, you can pass the required protocol to the connect() method. This means that a PC/SC ifd handler may automatically choose T=1 as the highest protocol if the card indicates both in its ATR [2]. Since pySim only supports T=0, let's select it explicitly. [1] https://pyscard.sourceforge.io/user-guide.html [2] https://github.com/acshk/acsccid/issues/16#issuecomment-501101972 Change-Id: Ifed4574aab98a86c3ebbeb191f36a8282103e775
2020-02-27transport/pcsc: cosmetic: reuse the existing code of PcscSimLinkVadim Yanitskiy1-5/+2
Change-Id: I5360df644032b95654e99ccaa5118952e8d55faf
2020-02-27utils: fix dec_msisdn(): properly detect international numbersVadim Yanitskiy1-1/+1
We should match the whole value of ToN, not just one LSB bit. Change-Id: Idc51f09b3420d827a75a1161372e4e97c3ddfbc1
2020-02-15Py2 -> Py3: use the floor division operator // where possibleVadim Yanitskiy3-12/+12
In Python 3, traditional division operator returns a float, while we need a floor integer in the most cases. Change-Id: I5565eb64a1ddea7075cbb142eaacaa5d494c87bb
2020-02-15pySim-read.py: do not import json, it is not neededVadim Yanitskiy1-6/+0
Change-Id: I4ae1d71c5695c9cd8ddebea514847b0be6a24c6c
2020-02-15pySim-prog.py: add support for MSISDN programmingSupreeth Herle7-3/+57
This change implements programming of EF.MSISDN as per 3GPP TS 31.102, sections 4.2.26 and 4.4.2.3, excluding the following fields: - Alpha Identifier (currently 'FF'O * 20), - Capability/Configuration1 Record Identifier ('FF'O), - Extension1 Record Identifier ('FF'O). This feature is introduced exclusively for sysmoUSIM-SJS1. Othere SIM card types need to be tested. Change-Id: Ie033a0ffc3697ae562eaa7a241a0f6af6c2b0594
2020-02-15pySim-read.py: fix reading and parsing of EF.MSISDNSupreeth Herle4-5/+48
This change implements parsing of EF.MSISDN (and thus EF.ADN) as per 3GPP TS 31.102, sections 4.2.26 and 4.4.2.3. Example (commercial SIM card from 401/02): EF.MSISDN: ffffffffffffffffffffffffffff07917787028982f7ffffffffffff Decoded (NPI=1 ToN=1): +77782098287 Note that sysmoUSIM-SJS1 in the test setup has malformed EF.MSISDN, so that's why the test output is changed. Change-Id: Ie914ae83d787e3f1a90f9f305bffd45053b8c863
2020-02-15Fix MCC and MCC representation in the output of pySim-readSupreeth Herle5-23/+48
Change-Id: Ie699c0a38d5ae90e4d6109e4574ce860e4044096
2020-02-15cards/sysmoUSIM-SJS1: support programming of EF.HPLMNwAcTSupreeth Herle1-0/+6
Change-Id: Ida93f4a00fe3b1d0f05d6eeda0e7873ce16d4c17
2020-02-15cards/sysmoUSIM-SJS1: support programming of ACC bitsSupreeth Herle1-0/+3
Change-Id: Id0ed9e5654dc0a70a4732bbe5787f1900789d580
2020-02-15cards: fix reading of EF.HPLMNwAcT in Card.update_hplmn_act()Supreeth Herle1-2/+2
Change-Id: I35848059d6082c379246c8d695cb094c20780d15
2020-02-15cards: cosmetic/indentation fix: use tabs, not spacesSupreeth Herle1-1/+1
Change-Id: I5d9cbdb0ecbee783729d0a208d12f8e59ca957ff
2020-02-15pySim-prog.py: add presence/length checks for user-provided SPNSupreeth Herle2-2/+7
Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
2020-02-15pySim-read.py: print meaningful message when SPN is not setSupreeth Herle3-3/+5
Change-Id: I1d98520f33a8564c7d69f50a0811204f138f9dca
2020-02-14pySim-read.py: fix copy-paste: s/HPLMNAcT/PLMNsel/Vadim Yanitskiy1-1/+1
Change-Id: I4a452a2e439cb713621a028cf0046339f50864b6
2020-02-14Fix compatibility with Python 3: print() is a functionVadim Yanitskiy5-51/+51
Change-Id: I5dd8e5daf420fc8667c5156bfacc8763d8895993
2020-02-14testdata/sysmoUSIM-SJS1.ok: make it match the actual EF.HPLMNAcTVadim Yanitskiy1-12/+12
Change-Id: Ibe1bf274c15a3159b012c6fe07ef6a7cbf0adbdb Related: OS#4383
2020-01-21Fix file permissionSupreeth Herle1-0/+0
Change-Id: I893869329e9547e06386baf4d16a18e545042d62
2020-01-21Added feature to program SPN into sysmoUSIM-SJS1 SIM cardsSupreeth Herle2-3/+7
Change-Id: Ia0f1a36ecb3898eaa1cf9925864e13369b1f31ce
2020-01-21Added feature to read Service Provider Name (SPN) from the SIM cardSupreeth Herle7-1/+30
Change-Id: I8dc599a76c260ec2823ba5c9b22375b04a50daa8
2019-12-31cards: Add support for sysmo-isim-sja2Philipp Maier4-1/+199
The sysmo-isim-sja2 cards are not yet supported by pysim. Lets add support for writing KI and OPC in ADF.USIM and ADF.ISIM as well as the remaining common simcard parameters. Related: SYS#4466 Change-Id: I23e2b46eac0e0dbc2b271983d448999f6a459ecf
2019-12-31Fixup: Fix automated testsPhilipp Maier1-2/+5
The Change I12e6b46787efb39c5745f4e7f3cdcca9209881b8 was not as effective as expected. Diff is used wrongly so that no lines are compared. Lets fix this Change-Id: I1601d8a2b3e1c07fe1eba375ea8deae3d50bbef0
2019-12-20commands: fix __record_len()Philipp Maier1-7/+9
When working with USIM/ISIMs, The method __record_len() that is used by the record_count() method returns the length of the file instead the actual record count. This causes record_count() to return always 1 Change-Id: If810c691893c022e9e9d87218dd0a334c5b2d579
2019-12-16Fix automated testsPhilipp Maier6-6/+11
- The .ok files currently dictate in which pysical reader device the card must be placed. Lets remove this dependncy to make the setup more reliable. Testing in which reade a card is placed is not in the scope of our tests. - Fix bug in pysim-test.sh (test runner), so that the veriable $ADM_HEX gets reset after the execution of the tests. Change-Id: I12e6b46787efb39c5745f4e7f3cdcca9209881b8
2019-11-12Fairwaves-SIM: Add test dataPhilipp Maier2-0/+46
Add test-data in order to be able to run our hardware read/write tests on Fairwaves-SIM as well. Change-Id: I04713e8cb1098521eafa4594100fcc7226978e21
2019-11-11cards.py: do not use spaces in card namesPhilipp Maier1-2/+2
pySim-prog.py features a way to detect which card type is in the reader. The returned value is often used as filename for testfiles and other automated operations. Therefore lets not have spaces in simcard names Change-Id: Ib7428fab767874dd53478d7c64601ff8938e05aa
2019-09-28python3 conversion: Use python 2 and 3 compatible exceptionsDenis 'GNUtoo' Carikli1-5/+8
Without that we have: $ python3 pySim-read.py Using serial reader (port=/dev/ttyUSB0, baudrate=9600) interface Traceback (most recent call last): File "pySim-read.py", line 91, in <module> from pySim.transport.serial import SerialSimLink File "/home/gnutoo/work/projects/osmocom/pysim/pySim/transport/serial.py", line 29, in <module> from pySim.exceptions import NoCardError, ProtocolError File "/home/gnutoo/work/projects/osmocom/pysim/pySim/exceptions.py", line 26, in <module> import exceptions ModuleNotFoundError: No module named 'exceptions' Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Change-Id: Ie45dc7ccd72fe077ba3b424f221ff4ed02db436c
2019-09-15python3 conversion: fix tabs and spaces inconsistencyDenis 'GNUtoo' Carikli5-109/+108
Without that fix we have: $ python3 pySim-read.py File "pySim-read.py", line 135 try: ^ TabError: inconsistent use of tabs and spaces in indentation The following command was used to do the conversion: sed 's# #\t#g' -i $(find -name "*.py") Then the remaining spaces spotted during the review were addressed manually. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Change-Id: I83f76a8e9b6e36098f16552a0135a8c22dde545f
2019-09-13pySim-prog: use functions to derive MCC/MNC from IMSIPhilipp Maier2-2/+31
In case the MCC/MNC are not supplied with a CSV file we cut out the missing values from the IMSI string. Lets use a function to do this and also check the input parameters. Change-Id: I98e5bf8f9ff2a852efb190cc789edf42c5075bf8
2019-09-13cards: use string representation for MNC/MCCPhilipp Maier2-4/+4
At the moment MNC and MCC are represented as integer numbers inside the parameter array while all other parameters are represented as strings. Lets use strings for MNC/MCC as well to simplify the parameter handling. We will also not loose the length information in case of leading zeros. Change-Id: Ia2333921a4863f0f26ee923ca796e62ec5e2d59a
2019-09-13pySim-prog: check if CSV file existsPhilipp Maier1-0/+7
At the moment we do not chack if the CSV file exists at all. This may lead into a crash while programming the card. Lets check the CSV file before we start. Change-Id: I2643996282d88e512c17901ab0e1181677d5dd6c Related: SYS#4654
2019-09-13pySim-prog: use case insensitive CSV headers.Philipp Maier1-0/+4
Inside of pySim all CSV headers are defined in lower case and are evaluated case sensitive. This means that a CSV file that contains the headers in uppercase for example will not parse. Lets make sure that the CSV headers are evaluated case insensitive to increase compatibility with slightly different formats. Change-Id: I1a476e7fc521d1aad2956feec3db196156961d20
2019-09-13pySim-prog.py: use more expressive error message on CSV read failurePhilipp Maier1-1/+1
When the CSV file fails to read the error message is just "Error reading parameters". Lets make clear that this error is related to a problem with the CSV file Change-Id: If285c1fbf7d285f512b573040f1b8983e4e3087e
2019-09-12Add support for automatic card handlingPhilipp Maier3-78/+214
When using the batch mode of pySim-prog, the user has to insert/remove the cards from the cardreader manually. This is fine for small batches, but for high volume batches this method is not applicable. This patch adds support for the integration of an automatic card handler machine. The user can freely configure a custom commandline that is executed when a card should be inserted or moved to a good/bad collection bin. Change-Id: Icfed3cad7927b92816723d75603b78e1a4b87ef1 Related: SYS#4654
2019-09-05pySim-prog: generate a pin_adm from pin_adm_hex also for CSV filesPhilipp Maier1-0/+15
When reading CSV files we currently have no option to provide a pin_adm_hex field like we already have it as commandline option. Lets add an option pin_adm_hex for this. Change-Id: I53e8d666d26a06f580725a8443a335643d10192c