+-----------------------------+ + Cardem v1.100.000 + +-----------------------------+ + ISO 7816 SDL Sender + +-----------------------------+ IMPORTANT: ---------- All rights reserved. No part of the executable file Cardem.exe and code therein and/or this document may be reproduced, altered or transmitted in any form or by any means - electronic, electro static, mechanical, photocopying, recording or otherwise, either for profit or non-profit, without the prior permission of the author. Copyright of the executable file Cardem.exe and code therein remains the property of the author. Usage of Cardem.exe is limited by license to one-user. Additional copies of the executable file cannot be made with the authors prior consent. Any breach of the above terms may result in legal action against the user. In short, if you did not receive this copy directly from the author you are in violation of the above terms. Legal action could be taken against you by the author. Please send email to : jc@eurosat.com, to receive a free, registered copy. The author does not guarantee the safety of the code and is not liable for any damage the use of this program may cause - use at your own risk. If in doubt, email the author at : jc@eurosat.com Introduction ------------ Cardem is an MS-DOS based utility to send Smartcard Data Log (SDL) files to an ISO 7816 Asyncronous Contact Smartcard. The SDL file format is detailed in SDLNOTES.TXT, included in this archive. For current information and revision history of the SDL file format see : http://www.eurosat.com/jc/sdl - The SDL www Homepage http://www.wedzboyz.demon.co.uk/ - The SDL mirror site The purpose of this utility is to aid in the design of smartcards, by allowing the developer to test the card in a pseudo operating environment. It might not always be economically viable or possible to test the normal operation of the developing smartcard in its true application so a bridging application such as Cardem would be used to emulate the host for the smartcard. Using Cardem ------------ Cardem requires an interface between the PC and the smartcard. Such interfaces are available from PayTV enthusiasts' internet sites. Contact the author for further details. Full assembly instructions for a compatible interface are included in this archive should you wish to do so, see ADAPTER.TXT. Various options are passed to Cardem by either the SDL file or by command line options. If given, command line options override SDL file settings (see examples of usage below). Once communication is established, each line of the SDL file is sent to the smartcard, one by one. A processing delay is available by command line option 'd' specified in milliseconds, which introduces a delay inbetween SDL file line processing. The program can be terminated during this delay by pressing the ESC key. Please note that some command structures in smartcards require the host ie PC, to return within a designated time. This processing delay can sometimes cause an error in such communications so it is suggested that the output file be used for debugging purposes, rather than using the PC screen. SDL file v1.1 and above makes use of a comment to ignore a specified data or header string. This is achieved by replacing the initial colon at the start of the line, with a semi-colon ie. :01,00::20,20,00,00,20 -- line is used to/from smartcard ;01,00::20,20,00,00,20 -- line is ignored, Cardem moves to next line Known Card Acceptance --------------------- Cardem has been fully tested working on the following smartcards : PayTV Smartcards ---------------- VideoCrypt1 : BSkyB Original Viewing Card - Series 03 Series 04 Series 06 Series 07 Series 09 Series 10 Series 11 09->D2MAC Amiga A0 Smartcards (VideoCrypt1 0a battery card) CardMate 3 Smartcards (VideoCrypt1 0a battery card) EuroCrypt1 : (D2MAC) COP8 Smartcards - 200 series 300 series 400 series Astra ADR (DMX) - Series 1 GSM Smartcards -------------- Vodafone GSM Cellnet GSM Orange Pseudo-GSM Mercury One2One Pseudo-GSM If you have luck with successful communication on smartcards not listed above, please send email to jc@eurosat.com with full details, including the SDL file used. Interfaces tested ----------------- Cardem has been fully tested on the following interfaces : . Mk12 by Paul Maxwell-King information available at : http://www.maxking.demon.co.uk . Interesting Devices Smartcard Reader/Writer information available at : http://users.aol.com/devices232 . Clanzers Smartcard Reader/Writer information available at : http://www.wedzboyz.demon.co.uk CARDEM.EXE: usage for v1.100.000 ------------------------------------ Syntax: CARDEM [] [wa] [wb] [b] [c] [d] [i] [o] [r] select port use com port wa byte delay specify in uS wb procedure delay specify in uS b operating baud operating baud rate c config file Cardem configuration file, see config.txt d process delay optional processing delay in ms i input SDL file input SDL file o write file screen output is written to named file r reset baud reset baud rate defaults are: com: 2 wa: 1000 wb: 15000 d: 0 r: 09600 b: 09600 interface: Phoenix type Cardem autodetects between a standard Phoenix type interface and SmartMouse interface. Example Usage ------------- All command line options are interchangeable - they are not set in order. 1. Cardem idata.sdl This will use the SDL file named 'data.sdl' 2. Cardem 1 idata.sdl This will change the comport used to COM 1, and use the SDL file named 'data.sdl' 3. Cardem idata.sdl d1000 This will use the SDL file named 'data.sdl' and set a processing delay of 1000ms ( 1 second ) inbetween each line of commands to the smartcard. 4. Cardem idata.sdl r19200 This will use the SDL file named 'data.sdl' and reset the smartcard at 19200bps. Please note that the 'r' command line option will override the reset baud rate specified in the SDL file. 5. Cardem idata.sdl b19200 This will use the SDL file named 'data.sdl' and operate the smartcard at 19200bps. Please note that the 'b' command line option will override the operating baud rate specified in the SDL file. 6. Cardem 1 idata.sdl d2000 r19200 b19200 This will change the comport used to COM 1 and use the SDL file named 'data.sdl'. It will set a processing delay of 2000ms ( 2 seconds ) and reset the smartcard at 19200bps. Lastly, it will operate the smartcard at 19200bps. Please note that the 'r' and 'b' command line options will override the relevant baud rates specified in the SDL file. 7. Cardem idata.sdl cconfig.cfg This will use the SDL file named 'data.sdl' and the configuration file 'config.cfg'. Cardem will superimpose the scan over the information held in the SDL file, and assume processing for the duration of the scan. Please read 'config.txt' before making use of the scan function in Cardem v1.1 and above. The wa delays are as per alternative software making use of such delays. Cardem will autodetect whether a Phoenix or SmartMouse type interface is being used. Cardem Version History ---------------------- Version Date Notes 1.100.000 3-Apr-97 : . scan routines improved and fully implemented : . v1.1 assuming header byte scan only : . configuration file check added : . SW1 SW2 code meanings improved : . GSM returns added : . bug fixes 1.000.450 24-Mar-97 : . first implementation of scan routines used : . bug fixes 1.000.440 18-Mar-97 : . SDL v1.0 revision 1.2 developed - : . instruction bytes changed to : . alphanumeric - increases permutations : . from 65,536 to 1,679,616 : . (see http://www.eurosat.com/jc) : . error detection routines improved : . configuration file routines improved (not implemented in this build) : . bug fixes 1.000.420 15-Mar-97 : . ATR v1.0 added to Cardem : . comment entry added to SDL file - : . SDL v1.0 revision 1.1 developed (see http://www.eurosat.com/jc) : . configuration file routines added (not implemented in this build) : . bug fixes 1.000.414 11-Mar-97 : . -- First Public Release -- : . improvements made to outputfile : . bug fixes 1.000.401 2-Mar-97 : . 2nd evaluation release : . bug fixes 1.000.384 15-Feb-97 : . 1st evaluation release The Smartcard Data Log (SDL) File Format. Developed 10-Feb-97 by JC. Copyright and update of the SDL1 are currently held by JC. Overview -------- The Smartcard Data Log (SDL) file format is used to universally record data communication to ISO 7816 Asyncronous Contact Smartcards. It comprises of file header information outlining basic communications protocol to the smartcard, as well as information to describe the smartcard and data communication recorded against it. SDL Version 1.0, Revision 1.1 ----------------------------- 1. The SDL file header. ------------------------ The SDL1 file header is made up as follows : SDL1 - Identification of the file as a Smartcard Data Log. Also informs that file is type version 1. : - Packing character. xxxxx - Number of lines held in the SDL file. This information is in decimal. : - Packing character. xxxxxx - Reset baud rate necessary for the smartcard to accept the SDL file. This information is in decimal and relates directly to the reset baud rate. 5 characters long. : - Packing character. xxxxxx - Operating baud rate necessary for the smartcard to sustain communication with the PC for the duration of the SDL file. This information is in decimal and relates directly to the operating baud rate. 5 characters long. : - Packing character. ssssssssss - Brief description of the smartcard to be used. 16 characters long. : - Packing character. ssssssssss - Brief description of the data held in the SDL file. 33 characters long. : - Packing character. 2. The structure of the SDL file. ---------------------------------- The purpose of the SDL file is to effectively hold data communication to ISO 7816 Asyncronous Contact Smartcards for future playback to similar smartcards. For universal acceptance, it is necessary to allow updating of all possible commands, also of the ISO header information. This is achieved by breaking down the information to its primitive components. All data is stored with additional flags to ascertain both the data flow ie. to smartcard / from smartcard, and whether the data refers to header changes or data for the smartcard. An example of the SDL information : :01,01::53,70,00,00,06 This is translated to : : - Control character. By default the ':' character specifies data line is to be issued to the smartcard. Possible values : : - This line is to be issued ; - This line is to be ignored 01 - Data type flag. This refers to : 00 - Data information 01 - Header information This is a hexadecimal value. , - Packing character. 01 - Direction flag. This refers to : 00 - Data to be sent to PC 01 - Data to be sent to Smartcard This is a hexadecimal value. :: - Packing characters. 53,70,00,00,06 - ISO 7816 header information. As suggested by the data type flag, the data refers to CLA, INS, P1, P2 and P3 ( Length ). All values are hexadecimal. SDL Version 1.0, Revision 1.0 ----------------------------- 1. The SDL file header. ------------------------ The SDL1 file header is made up as follows : SDL1 - Identification of the file as a Smartcard Data Log. Also informs that file is type version 1. : - Packing character. xxxxx - Number of lines held in the SDL file. This information is in decimal. : - Packing character. xxxxxx - Reset baud rate necessary for the smartcard to accept the SDL file. This information is in decimal and relates directly to the reset baud rate. 5 characters long. : - Packing character. xxxxxx - Operating baud rate necessary for the smartcard to sustain communication with the PC for the duration of the SDL file. This information is in decimal and relates directly to the operating baud rate. 5 characters long. : - Packing character. ssssssssss - Brief description of the smartcard to be used. 16 characters long. : - Packing character. ssssssssss - Brief description of the data held in the SDL file. 33 characters long. : - Packing character. 2. The structure of the SDL file. ---------------------------------- The purpose of the SDL file is to effectively hold data communication to ISO 7816 Asyncronous Contact Smartcards for future playback to similar smartcards. For universal acceptance, it is necessary to allow updating of all possible commands, also of the ISO header information. This is achieved by breaking down the information to its primitive components. All data is stored with additional flags to ascertain both the data flow ie. to smartcard / from smartcard, and whether the data refers to header changes or data for the smartcard. An example of the SDL information : :01,01::53,70,00,00,06 This is translated to : : - Packing character. 01 - Data type flag. This refers to : 00 - Data information 01 - Header information This is a hexadecimal value. , - Packing character. 01 - Direction flag. This refers to : 00 - Data to be sent to PC 01 - Data to be sent to Smartcard This is a hexadecimal value. :: - Packing characters. 53,70,00,00,06 - ISO 7816 header information. As suggested by the data type flag, the data refers to CLA, INS, P1, P2 and P3 ( Length ). These values are hexadecimal. 3. Notes. ---------- A few implications of the structure show that the Header information can show the direction to be to the smartcard. In this case, the data is to be held in the following SDL line. Also, it is irrelevant to show the direction is to the PC in the data information if the preceding header information shows that the data is to be sent to the smartcard. In this case, the direction flag should be declared NULL. By implementing the SDL file in this way, header information declaration is only necessary for a command change. Once this is initialised, numerous data lines can be sent, or requested, to/from the smartcard. 4. Future updates to the SDL file format. ------------------------------------------ The SDL file is constantly being revised to cope with acceptance with the various uses of smartcards worldwide. At present, the ISO7816/4 command set is not implemented, with reference to the file storage options therein. This is an anticipated update. For current information on the SDL file format, visit: http://www.eurosat.com/jc http://www.wedzboyz.demon.co.uk