AgeCommit message (Collapse)AuthorFilesLines
2018-07-19cards: Add support for Wavemobile SIMpmaier/wmsimPhilipp 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-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
2018-01-10pySim-prog: Replace magic numbers with a readable EF file name.Alexander Chemeris1-1/+1
Change-Id: Ibda7d5a4132971e884f6d760baf20cd33025a2af
2018-01-10pySim-prog: ADM code can be longer 8 digits, it's implementation specific.Alexander Chemeris1-4/+3
E.g. Fairwaves SIM cards have longer ADM codes. Change-Id: I87d61764eeba4bcf7525ee4778cb8f244930db9b
2018-01-10cards: Extend Card class with access functions for some of the standard EF ↵Alexander Chemeris1-2/+67
files. Change-Id: Icb7227fa7ebc837fccab456cbfad529f6ee81a28
2018-01-10Add methods to get ATR for a card or a link.Alexander Chemeris3-2/+19
Implemented for both serial and PCSC readers. Change-Id: Ic12e4b115d24a8b7e483a5603dd6cec90ad289cc
2018-01-10utils: Fix documentation. 3+3=6 digits equals 3 bytes, not 6Alexander Chemeris1-1/+1
Change-Id: I2722d788a69976e1c64a9caf6cf3049af27f9a30
2018-01-10utils: Functions to encode/decode EF SPN.Alexander Chemeris1-0/+19
According to TS 51 011. Change-Id: Ida184bc5c81cc8c228b8981b703f77d017e53334
2018-01-10ts_51_011: A file with MF/DF/EF constants from TS 51 011Alexander Chemeris1-0/+251
pySim has been using magic numbers to access various files which makes it hard to read, maintain and extend. With this file in place we can start replacing all those magic numbers with human readable names lile EF['IMSI'] instead of ['3F00', '7F20', '6F07']. Change-Id: I38f5d36d16b41b5d516a6a3e2ec1d09637883932
2018-01-10Fix comment: Ki -> OPCAlexander Chemeris1-1/+1
Change-Id: I566cf7bc658c730b4381c0f145bfc4f805cca42a
2018-01-02utils.py: dec_imsi: Fix ValueErrorPau Espin Pedrol1-1/+1
It should fix the following observed error: ~/pysim$ ./pySim-read.py -p0 Reading ... ICCID: Traceback (most recent call last): File "./pySim-read.py", line 99, in <module> print("IMSI: %s" % (dec_imsi(res),)) File "/home/lab434/pysim/pySim/utils.py", line 57, in dec_imsi l = int(ef[0:2]) * 2 # Length of the IMSI string ValueError: invalid literal for int() with base 10: 'ff' Change-Id: I7d3ecbf9edd190d1941816796cee60e3957d5943
2017-12-29pySim-prog.py: Fix trailing whitespacePau Espin Pedrol1-1/+0
Change-Id: I735dc7bb774d77d3b60b1712b0f0afcbb81dc726
2017-12-29pySim-*.py: Set shebang to use python v2Pau Espin Pedrol2-2/+2
Nowadays bin/python usually points to python3, and this script is written in python2, which means if run directly from terminal it will fail with some print syntax errors. Change-Id: I6ab4e9edc44a8045915d4828c6de2fa98027fb7e
2017-09-01Support writing SMSP for sysmoUSIM-SJS1Daniel Willmann1-0/+3
Closes: OS#1989 Change-Id: I6cbf69be3d410c18a509b98a63cb69bab74a528a
2017-04-06fix writing of ICCID for sysmo-usim-sjs1Philipp Maier1-7/+7
The programming procedure for sysmo-usim-sjs1 lacks writing the ICCID. This commit adds the missing call to update_binary() Change-Id: Ief85aa07c562d8d7b2a6dec302d2f485d0b1e577
2017-04-06Fix select control parameterPhilipp Maier2-1/+9
sysmo-usim-sjs1 requires P2 to be set to 0x0C (request FCI) when using the USIM application commands. The FCI is not used by pysim anyway and might even cause problems with other cards. This commit adds a pair of get/set methods to the SimCardCommands class in order to set a default for the selection control parameters (P1, P2). (Similar to the set/get methods for the class byte) The SysmoUSIMSJS1 class now calls the setter method for the selection control parameters inside of its constructuor and sets the selection control parameter default to "000C". This way we can be sure that we only change the behaviour for sysmo-usim-sjs1 and do not break support for any other cards. Change-Id: I1993a267c952bf37d5de1cb4e1107f445614c17b
2017-03-21cosmetic: missing newlines on last line of 2 filesNeels Hofmeyr2-1/+2
It's hard to keep this out of real patches, since normally editors add the final newline automatically.
2017-03-17README.md: Cosmetic/Formatting fixesHarald Welte1-4/+4
2017-03-17Update README with general project information and convert to MarkdownHarald Welte2-38/+91
2016-10-27Revert "Do not return the FCI information while selecting a file"Harald Welte1-1/+1
This reverts commit 8c1b33c439fef423c3536e9243035722c52aba4c.
2016-05-22re-program: Instead of specifying the IMSI, read it from the card.Holger Hans Peter Freyther1-6/+16
2015-08-20Do not return the FCI information while selecting a fileJan Balke1-1/+1
The sysmoUSIM-SJS1 card does not support returning the FCI information. Plus, the FCI information are not used anyway.
2015-08-20Add provision support for sysmoUSIM-SJS1 cardsJan Balke1-1/+50
The PIN-ADM has to given on the command line as it is provisioned different for each card. Currently only Ki, Op and IMSI are provisioned.
2015-08-20Add PIN-ADM argument to the command lineJan Balke2-4/+26
Allow overwriting the default PIN-ADM set in the card implementation.
2015-08-20Allow changing the class byte for pdu messagesJan Balke1-7/+16
2015-08-20Introduce a '--dry-run' option to skip actual card accessHarald Welte1-21/+31
This can be used for example to batch convert from CSV input to HLR output without writing cards.
2015-08-20read_params_csv: Make sure we don't end up in endless loopHarald Welte1-7/+13
as a side effect, the first line is now specified with '-j 0' and not '-j 1'
2015-08-20pySim-prog: Add mode where it can re-generate a card from CSVHarald Welte1-5/+54
Rather than just having the capability of writing to CSV, it now has the capability to (re)write a card based on data from the CSV: ./pySim-prog.py -S csv --read-csv /tmp/sim.csv -i 901701234567890 or in batch mode (from the first line onwards): ./pySim-prog.py -S csv --read-csv /tmp/sim.csv --batch -j 1
2015-08-20split parameter writing for CSV and SQL into separate functionsHarald Welte1-2/+7
2013-12-23cards: sysmocom SysmoSIM-GR2 support added to cardsSylvain Munaut1-2/+67
Written-by: Kevin Redon Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-07-18pySim-read: MISDN is not mandatorySylvain Munaut1-8/+11
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-07-13Move encoder functions for ICCID, IMSI and PLMN to pySim.utils for consistency.Alexander Chemeris2-28/+28