aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2019-09-03pySim-prog: Add option for hex ADM keysDaniel Willmann4-10/+28
pySim-prog would implicitly try to use the raw or hex-escaped format depending on the length of the parameter, now there is the option "-A" to explicitly specify the hex-escaped ADM1 key. pysim-test.sh: Explicitly use the "-A" option to pass the hex adm1 key for wavemobile cards Change-Id: Id75a03482aa7f8cc3bdbb8d5967f1e8ab45c179a
2019-09-03pySim-prog: Use CSV format with headersDaniel Willmann2-15/+44
This way we can have optional fields like pin_adm in the file Also require iccid as identifier for the SIM card Set defaults for optional card parameters. Change-Id: I0d317ea51d0cf582b82157eec6cdec074001a236
2019-09-03pySim-prog: Print out hex-escaped pin_adm in card parametersDaniel Willmann2-9/+10
Use h2b to convert pin_adm back to binary form for sysmoSIMgr2 Change-Id: Ia178c9938f3e6a4fbac24d767437894297d1e708
2019-09-02pysim-testdate: Add test data for Wavemobile-simPhilipp Maier2-0/+53
Change-Id: Id2baedf5ac6396a643f36444e8f570ad9c41fafb
2019-08-28make writing SMSP optionalHarald Welte1-5/+8
Change-Id: Ic5fdd397244cfe73b5b6a12883316072cc10f7b4
2019-08-28Make programming OPC optionalDaniel Willmann1-3/+3
Change-Id: Ic600c325557918cb7d5b1fb179c01936a078c96c
2019-05-10pySim-*.py: print info about selected reader interfaceVadim Yanitskiy5-0/+15
Change-Id: Idd791d7ef635e15915aab13274aefc15e70777b0
2019-05-10Don't try to parse result if select_file() failedMax1-0/+2
Change-Id: I25b859374e33654e58d07061926bf8529eab87f3
2019-05-10Use reference array for reading ICCIDMax1-1/+1
Change-Id: Iad0a328c6f0c9a4ab678efe068801849be48d8fc
2019-05-10utils: add EF [H|O]PLMNwAcT decoding.Daniel Laszlo Sitzer4-7/+195
Allow decoding and pretty printing of PLMNwAcT, HPLMNwAcT and OPLMNwAct. Includes unit tests for the added functions. Change-Id: I9b8ca6ffd98f665690b84239d9a228e2c72c6ff9
2019-05-10import pysim-testdata of automatic testing to this repositoryHarald Welte7-3/+61
This test data is used by the jenkins build verification for pySim, and it was previously located locally on the build slave. By moving the testdata to this repository, any contributor can modify both the code and the expected test results simultaneously. Change-Id: I6714b091a114035d6aab8ba750c5f2b86e438467
2019-04-01wavemobile-sim: write mnc-length field ine EF.ADPhilipp Maier1-0/+6
The length field in wavemobile sim cards is not set, so that the field stays at its initial value, which is 0xFF. Lets write the correct mnc length here. Change-Id: Ieda0ce864bf3e8c7b92f062eaa3a5482c98507e2 Related: OS#3850
2019-04-01cosmetic: fix sourecode formattingPhilipp Maier1-5/+5
Change-Id: I4836826811ffb0aeb103d32eb874f5fa52af4186
2019-04-01sysmo-usim-sjs1: update EF.AD with correct MNC lengthPhilipp Maier2-0/+26
At the moment EF.AD, which contains the length of the MNC is not updated. For two digit MNC (the usual case) this is fine since the length is set to 2 by default. However, when one wants to set an MNC with 3 digit length the file must be updated, otherwise the third digit of the MNC is recognized as part of the MSIN. Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65 Related: OS#3850
2019-03-21cards: sysmo-usim-sjs1: add programming of EF.PLMNsel, EF.PLMNwAcT and ↵Philipp Maier1-1/+20
EF.OPLMNwAcT The files EF.PLMNsel, EF.PLMNwAcT and EF.OPLMNwAcT are currently not programmed for sysmo-usim-sjs1, lets add them. Change-Id: I0cac3041f1902383d98d6dc211cf31ae6e3a610b Related: OS#3850
2019-03-21commands: correct case of a TLV tag (A5 => a5)Philipp Maier1-1/+1
The hexadecimal tag defintions of pytlv are case sensitive strings. So 'A5' is something different than 'a5'. Pytlv uses lower case letters for the upper hexadecimal digits. Lets correct this. Change-Id: I41a9933707783f6b1b68ebd91a365405ac0892d0 Related: OS#3850
2018-10-29pySim-*.py: add command line option for Calypso readerVadim Yanitskiy2-0/+14
Change-Id: Ia895ced62d29e06ae8af05cd95c9d181fb53b9df
2018-10-29pySim-*.py: refactor card reader driver initializationVadim Yanitskiy2-10/+10
This would facilitate adding new card reader drivers. Change-Id: Ia893537786c95a6aab3a51fb1ba7169023d5ef97
2018-10-29pySim/transport: introduce Calypso based reader interfaceVadim Yanitskiy2-0/+160
This interface allows to use a Calypso based phone (e.g. Motorola C1XX) as a SIM card reader. It basically implements a few L1CTL messages that are used to interact with the SIM card through the OsmocomBB 'layer1' firmware. Please note, that this is an experimental implementation, and there is a risk that SIM programming would fail. Nevertheless, I've managed to program and read one of my SIMs a few times. Change-Id: Iec8101140581bf9e2cf7cf3a0b54bdf1875fc51b
2018-10-05pySim-prog: Honor international '+' in SMSC numberDaniel Willmann1-3/+8
The smsc no. programmed by pySim-prog would always be a national number in the past. Check whether the first 'digit' is a + and indicate that it is an international number. Change-Id: Ia79913f5b0307e9786a5acea75c0811927be2eef
2018-09-26utils: fix encoding/decoding of IMSI valueBen Fox-Moore1-6/+26
When programming or reading a SIM with an IMSI shorter than 15, the IMSI value is incorrectly encoded/decoded. The code pads the the IMSI value with 0xF from the left but padding from the right would be correct. It also encodes the length as half the number of digits in the IMSI (rounded up). This isn't correct for even length IMSIs. With even length IMSIs, the odd/even parity bit bumps the last digit into an extra byte, which should be counted as well. - Fix endcoding of IMSI value - Fix decoding of IMSI value Change-Id: I9ae4ca4eb7c2965e601a7108843d052ff613beb9 Patch-by: Ben Foxmoore Closes: SYS#3552
2018-09-13tests: add example test data for Wavemobile-SIMPhilipp Maier1-0/+5
Change-Id: If69cd2d8af6d544155b3088f77eb6ea4b789901d Related: SYS#4245
2018-09-13cards: Add support for Wavemobile SIMPhilipp Maier1-1/+112
Add support to handle Wavemobile sim cards. The support excludes some parameters. For example it is not possible to write own KI keys yet. Support covers the following files: EF.SMSP EF.IMSI EF.ACC EF.PLMNsel EF.PLMNwAcT EF.OPLMNwAcT Not yet supported are: EF.ICCID KI (propretary file) OPc (propritary file) Change-Id: Ida3f37bd6e3ac995812aeddc9770f1ccd54ecf3f Related: SYS#4245
2018-08-23tests: add example file for sysmosim-gr1Philipp Maier1-0/+7
Change-Id: I36cfa81f9029bfaedd2e802a2d709596dbeb20ab Related: OS#3405
2018-08-23cards: do not feed ascii as adm for sysmosim-gr1Philipp Maier1-1/+1
When sysmosom-gr1 is used with a custom ADM key, then the ADM string is not fed through h2b() like we see it with sysmo-usim-sjs1 for example. - feed the ADM to h2b() before use Change-Id: I0b7cab380b89612ed3b8318e014161038335fe1b Related: OS#3405
2018-08-23cards: autodetect sysmosim-gr1Philipp Maier1-0/+9
The sysmosim-gr1 lacks the auto detection feature because no autodetect is yet programmed inside the related class. - add autodetect for sysmosim-gr1 Change-Id: Iec1f1ab6824ff2328baedd731b08df997df4da01 Related: OS#3405
2018-08-20readme: add 'serial' dep, cosmetically rearrangeNeels Hofmeyr1-3/+10
Change-Id: I414b897ba4911b7428ddf807cb04a93700ee0193
2018-07-25commands: depend on pytlv only when it is actually neededPhilipp Maier1-1/+1
Some of the USIM-Card programming implementations do not need to look at card responses, which means they also do not have to parse TLV data. Lets depend on pytlv only in cases where TLV data has to be parsed so that useser of cards that do not need at can go without installing pytlv. Change-Id: Ida841d74d9581e7f395751b0f74556a06a038de6
2018-07-25readme: add info about dependenciesPhilipp Maier1-0/+9
So far, the README.md file does not mention much about the dependencies. This commt adds at lest the most important ones Change-Id: I912bbf787e1408100183cade2113bf7617b86ffa
2018-07-19add .gitreviewAlexander Couzens1-0/+3
git review uses this file to build the git url. Change-Id: Ia35aeb33d43ace3c71689d5acbb8d1259ccb7b42
2018-07-19contrib: add jenkins.shAlexander Couzens1-0/+19
Run the tests. Change-Id: I9308f097bf77d82e5ef78d1be551baf127726f74
2018-07-19tests: add test program to verify pysim-prog.py (and pysim-read.py)Philipp Maier3-0/+234
Pysim now supports quite a number of different cards. Estimating if changes in pysim introce regressions becomes increasingly difficult The script that is added with this patch is intended to run as atomated testsuit on real cards attached to a test system. However, it can also be used by developers locally to check for regressions. Change-Id: I8c6f95998272333bc757b34e3ab6be004e8cd674 Related: OS#3376
2018-07-13cards: return SW in method update_plmnsel() of class CardPhilipp Maier1-1/+2
The method update_plmnsel() does not return the status word yet, which causes pysim-prog.py to print an error message that does not influence the functionality but does not look nice. - preserve the status word that is returned with update_binary() and return it properly like the other methods do. Change-Id: I54e8e165f87365e8162b36d24efc8f0db62b66da Related: SYS#4245
2018-07-13cosmetic: fix cut and paste error in commentPhilipp Maier1-1/+1
Change-Id: I506585f8b300bb7a3e20edad7eca134374581d76
2018-07-13pySim-read: read contents of PLMN related files.Philipp Maier1-8/+40
The files EF.PLMNsel, EF.PLMNwAcT, EF.OPLMNwAcT, EF.HPLMNAcT are not yet printed by pysim-read. Lets add support for those files. Change-Id: Ice802033adfa6fc1bccc76da47495eb29c3aef6c Related: SYS#4245
2018-07-13pySim-read: Print exception when reading of EF.MSISDN failsPhilipp Maier1-2/+2
At the moment the exception is catched, but there is only a vague error message printed. However, the exception string usually tells us the status word, so it is very valuable to see it. Lets make sure that the exception string is printed here. Change-Id: Icb30470b1c0eee6a15fc028da820e92bf9ded27a
2018-07-13cosmetic: fix excess space in log output (typo)Philipp Maier1-1/+1
There shouldn't be a space between the end of a sentence and a punctuation mark. Change-Id: I33f9b8c803ccd185ffa370d235363423d82ba9c7
2018-07-11cards: add update method for EF:PLMNsel to Card classPhilipp Maier1-0/+6
The Card class offers update methods for various EF, but for PLMNsel there is no update method available yet. Lets add one. Change-Id: I832f7bef70c92dc101b94ad871b6cafaa626e134 Related: SYS#4245
2018-07-04pysim-prog: add commandline option to probe cardsPhilipp Maier1-2/+13
In some situations it may be helpful to know the card name (type) we deal with in advance. So lets ad an to probe that only detects the card and then exists. - Add commandline option -T --probe Change-Id: I57422d3819d52fd215ac8f13f890729aad2af76f Related: OS#3376
2018-07-03commands: get file/record length from FCP (USIM)Philipp Maier1-6/+56
Some of the methods SimCardCommands() have ways to determaine length information from the card response. Regular sims use a format where the length field is on a fixed position. USIMs use FCP templates (format control parameters), which is a TLV encodecs string. So lets distingish if we deal with an USIM (We can easily do this by looking at the select control parameters) and extract the length info from the FCP. - If we deal with USIMs, use the FCP to determine length information Change-Id: I068cf8a532e1c79a2d208e9d275c155ddb72713c Related: SYS#4245
2018-07-03__init__: also fetch response bytes for USIMs automaticallyPhilipp Maier1-1/+7
The method send_apdu() first transmits the APDU in the cards direction. The card may indicate that there is a response available by responding with SW1=9F, where SW2 is the number of bytes. send_apdu() will then craft a get-response APDU to pickup the response bytes. This mechanism works fine for SIM, but USIM uses SW1=61 to indicate the availability of a response, so lets also sense on SW1=61 to support USIMs as well. - Also check on SW1=61 to see if a response is available Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5 Related: SYS#4245
2018-07-03csv: fix missing import (broken CSV support)Philipp Maier1-1/+1
with Change I38f5d36d16b41b5d516a6a3e2ec1d09637883932, new constants for file identifiers were introduced. When csv file input is used, then pySim-prog.py uses one of these constans without importing it from ts_51_011.py - Add missing import Change-Id: Ic5b067b16ec204c2ba2264b1ffb48d37be8d5eb3
2018-06-18__init__: allow wildcards in expected SW for send_apdu_checksw()Philipp Maier1-2/+13
The method send_apdu_checksw() is used to check the SW of the final response against some pre defined value. However, in many cases the last two digits of the SW are used to return varying information (e.g. length information or a more specific status info). To cover those cases it would be helfpul to define status words that contain wildcards (e.g. 61**) in order to be able to accept all SWs from 6100 to 61ff. - When the user supplies an expected SW with wildcards, mask out those digits in the response before comparing Change-Id: I5bfc0522b4228b5d9b3415f6e708abcf0da0a7b7
2018-06-13pysim-prog: also allow raw hex adm pins besides numeric asciiPhilipp Maier1-4/+7
At the momemnt pysim takes the supplied ADM pin number and interprets it as ascii string. This ascii string (max 8 digitis) is then padded with 0xff bytes if necessary and sent to the card. This limits the range of possible ADM keys and it is not possible to deal with situataions where the ADM pin consists of arbitrary bytes. At the momemnt pysim-prog forbis anything that is longer than 8 digits. Lets also check if there are 16 digits and if yes interpret them as raw bytes. - when the adm pin is 16 digits long, interpret the string as raw bytes (hex). Change-Id: If0ac0d328c64b57bc4d45d985a4a516930053344 Related: SYS#4245
2018-04-26add support for open cells SIM cardsTodd Neal2-4/+54
Change-Id: I4df5681952eefd7a67f5e2b0a96a9e01c9d960d2
2018-02-18transport/serial: Fix serial transportMartin Hauke1-3/+3
Fix a typo that broke the serial transport. Change-Id: I7fcc97d505a5369f9f14d4a2abda92b7114a58cd
2018-01-23Revert "pySim-prog: ADM code can be longer 8 digits, it's implementation ↵Harald Welte1-3/+4
specific." This reverts commit a51592e1807c1d13f88b32275aa4a8a77d7d3b40, which broke the use of ADM pins on sysmoUSIM-SJS1 (and possibly others?) The ADM pins have so far always been specified as ASCII decimal digits, i.e. something like "-a 53204025" gets translated to hex "3533323034303235" After the above patch this is broken and gets instead translated to "53204025ffffffff" in hex which obviously breaks. Let's revert back to the old behavior to make it work again. Change-Id: I3d68b7e09938a2fcb7a9a6a31048388cc3141f79
2018-01-11Make derive_milenage_opc and calculate_luhn publicly available through utils.pyAlexander Chemeris2-19/+22
Change-Id: I2effc85fd55da0981de0ada74dcb28b7e8e56a01
2018-01-10cards: Add Fairwaves SIM implementation.Alexander Chemeris1-2/+145
Change-Id: Ia10ac433d3b0482bdf727c31f65a10042152797b
2018-01-10cards: Implement card type autodetection based on ATR.Alexander Chemeris1-2/+21
Change-Id: I1099a96626c0ce74243b47a8fdfa25b0d76a1ef3