5321-903 b.4 Omnikey Contactless Developer Guide en
5321-903 b.4 Omnikey Contactless Developer Guide en
5321-903 b.4 Omnikey Contactless Developer Guide en
hidglobal.com
OMNIKEY Contactless Smart Card Readers Developers Guide, 5321-903, Rev. B.4
Contents
1 Purpose ................................................................................................................................................ 7
2 Contactless Reader Coverage ....................................................................................................... 7
3 Getting Started .................................................................................................................................. 8
3.1 Driver Installation.............................................................................................................................................................. 8
3.1.1 Reader Name for Contact/Contactless Slot................................................................................................................... 12
3.2 OMNIKEY Workbench ................................................................................................................................................... 12
3.2.1 PC/SC Functionality and Reader Availability ................................................................................................................ 12
3.2.2 Driver Version Detection ........................................................................................................................................................ 13
3.2.3 OMNIKEY Proprietary API Detection ................................................................................................................................ 13
3.2.4 Card and Reader Detection ................................................................................................................................................... 14
3.2.5 Card Type Detection and RFID Settings.......................................................................................................................... 16
3.2.6 Air Interface Baud Rate Configuration ............................................................................................................................. 17
4 PC/SC 2.0 ........................................................................................................................................... 18
4.1 How to Access Contactless Cards through PC/SC ........................................................................................... 18
4.2 ATR Generation .............................................................................................................................................................. 20
4.2.1 CPU Cards ....................................................................................................................................................................................20
4.2.2 Storage Cards .............................................................................................................................................................................20
5 Accessing Asynchronous Cards ................................................................................................... 21
5.1 MIFARE DESFire Card ................................................................................................................................................... 21
5.1.1 Example: Write Card Data through ISO 7816-4 Framed APDU ............................................................................. 21
5.1.2 Example: Read Card Data through ISO 7816-4 Framed APDU ............................................................................. 22
6 Accessing Synchronous Cards (Storage) ................................................................................. 23
6.1 MIFARE Card .................................................................................................................................................................... 23
6.1.1 MIFARE Increment (Card Command) .............................................................................................................................. 24
6.1.2 MIFARE Decrement (Card Command) ............................................................................................................................ 24
6.1.3 MIFARE Emulation Mode ....................................................................................................................................................... 25
6.1.4 MIFARE Application Directory (MAD) ............................................................................................................................. 25
6.2 iCLASS Card...................................................................................................................................................................... 26
6.2.1 Card Access through SCardCLICCTransmit .................................................................................................................. 26
6.3 ST LRI64 Support (PC/SC 2.0 add-on)................................................................................................................. 27
6.3.1 Update Binary ............................................................................................................................................................................. 28
6.3.2 Read Binary ................................................................................................................................................................................. 29
6.4 ISO15693-3 Memory Card Support ......................................................................................................................... 29
7 Communication with MIFARE Plus ............................................................................................. 30
7.1 ISO 14443 A – Part 4 card communication ........................................................................................................ 30
7.2 ISO 14443 A – Part 3 card communication......................................................................................................... 30
7.3 Open Generic Session .................................................................................................................................................... 31
7.4 Generic Card Commands ............................................................................................................................................. 31
7.4.1 MIFARE Plus commands with the GENERIC INTERFACE Command APDU Samples ................................ 32
7.5 Close Generic Session................................................................................................................................................... 32
8 OMNIKEY Contactless Smart Card Reader Keys .................................................................... 33
8.1 Key Numbering Scheme .............................................................................................................................................. 33
8.2 Key Container and Slots .............................................................................................................................................. 35
8.3 Key Update Rules ...........................................................................................................................................................36
9 Standard Communication with iCLASS Card .......................................................................... 37
9.1 APDU Structure for Standard Communication.................................................................................................. 37
9.2 Commands Available in Standard Communication Mode ............................................................................ 37
Copyright
©2011 - 2015 HID Global Corporation/ASSA ABLOY AB. All rights reserved. This document
may not be reproduced, disseminated or republished in any form without the prior written
permission of HID Global Corporation.
Trademarks
HID GLOBAL, HID, the HID logo, iCLASS, iCLASS Elite, OMNIKEY, and Seos are the
trademarks or registered trademarks of HID Global Corporation, or its licensors, in the U.S.
and other countries.
MIFARE, MIFARE DESFire, MIFARE DESFire EV1, and MIFARE Ultralight are registered
trademarks of NXP B.V. and are used under license.
my-d is a registered trademark of Infineon Technologies
PayPass is a registered trademark of MasterCard
Document History
Version Author(s) Date Description
B.4 CT 2014-01-20 OMNIKEY 5421, reformat.
B.3 J. Maatuq 2012-03-23 - Corrected product name •OMNIKEY 5321 Pay ->
OMNIKEY 5321 PAY
- Some layout changes
- typo corrections
B.2 J. Maatuq 2012-02-09 Added new products 4121 CL, 5021 CL, 5321 CLi, 5321 Pay,
5325 Prox
Added new products and documented Workbench
Added Driver Configuration via ProxFormat and
ProxFormat Settings section
B.1 W Waitz 2010-11-10 Added iCLASS Elite enabled readers. Modified section
10.3.4 Get Security Status
B.0 W Waitz 2010-08-05 MIFARE Plus, PAY API and Review
A.1.19 S Schwab 2009-07-17 Chapter 9, supported tags
A.1.18 S Schwab 2009-07-16 Added footnotes for iCode SL2
A.1.17 W Waitz 2009-05-13 Review to version 1.16 and error correction
A.0 T Muth 2009-02-16 Updated to HID template
Firmware History
FW Version Special Features Remarks
5.20, 1.75 MIF, MKS, IST, ISE, EMD, iCLASS secured mode, HID application read,
HSK, iCLASS High Security Key supported,
EMD Suppression in firmware supported,
EMVCo Contactless L1
5.10 MIF, MKS, IST, ISE iCLASS secured mode, HID application read
5.00 MIF, MKS, IST, ISE iCLASS secured mode, HID application read
1.03, 1.04 MIF, MKS, IST iCLASS memory access
1.01, 1.02 MIF, MKS
1.00 MIF MIFARE support
Contacts
For additional offices around the world, see www.hidglobal.com corporate offices.
1 Purpose
This is a guide for developers integrating contactless storage or CPU cards using
®
OMNIKEY Contactless Smart Card readers.
3 Getting Started
This chapter describes how to install the drivers necessary to operate the OMNIKEY
Contactless Smart Card reader in a Windows based environment.
Note: Other operating systems, such as Linux, are also supported by the OMNIKEY
Contactless Smart Card reader.
Note: On Windows XP systems, the Microsoft Windows CCID Class driver may be
activated without showing the Found New Hardware Wizard. If this is the case,
replace the Microsoft PC/SC driver manually with the OMNIKEY proprietary PC/SC
driver using the Device Manager.
5. Select Search for a suitable driver for my device (recommended) and click Next.
7. Click Browse and go to the location where you previously installed the driver
package. To continue, click OK.
9. If the driver is a beta driver and not digitally signed, the following dialogue appears.
Click Continue Anyway.
10. The following message appears and the green LED illuminates on the OMNIKEY
Contactless Smart Card reader.
If the installation was successful, the green LED on the reader illuminates and the
reader is listed in the OMNIKEY Workbench as OMNIKEY Contactless Smart Card
reader.
Your reader is ready for use. Do a quick smart card system check using the OMNIKEY
Workbench described in Section 3.2 OMNIKEY Workbench.
Figure 3: API
The left pane contains a list of active card types. The right pane contains a list of available
card types that are supported by the reader but are not included in the card search. Move
card types from the left to the right pane using the and buttons. Change the search
order with the and buttons.
Activate this setting using the Apply button. The Reset button discards any unsaved
changes.
Note: The search order is forward-looking to improve system performance. The last
successfully detected card type automatically moves to the top of the search order,
regardless of its position within the order set on the RFID Settings tab.
4 PC/SC 2.0
With the OMNIKEY 5x21 PC/SC driver, access ISO14443A/B or ISO15693 contactless cards
through the same framework as ISO7816 contact cards. This makes card integration a snap
for any developer who is already familiar with PC/SC. Even valuable PC/SC resource
manager functions, such as card tracking, are available for contactless card integration.
® ®
The Microsoft Developer Network (MSDN ) Library contains valuable information and a
complete documentation of the SCard API within the MSDN Platform SDK.
See http://msdn.microsoft.com/en-us/library/ms953432.aspx.
You can directly access contactless CPU cards through the PC/SC driver. For storage cards
®
other than MIFARE , an additional library – the OMNIKEY synchronous API – is necessary.
Whether using direct PC/SC access or the OMNIKEY synchronous API, only a small set of
functions are required to write your first hello card program.
Integrate your card through:
PC/SC 2.0 compliant APDU’s OMNIKEY Synchronous API
MIFARE YES YES
iCLASS NO YES
LRI64 YES NO
3. List Readers
Gets a list of all PC/SC readers using the SCardListReaders function. Look for
OMNIKEY CardMan 5x21-CL 0 in the returned list. If multiple OMNIKEY Contactless
Smart Card readers are connected to your system, they will be enumerated.
Example: OMNIKEY CardMan 5x21-CL 1, and OMNIKEY CardMan 5x21-CL 2.
Analyze the complete string. OMNIKEY CardMan 5x21 also has a contact interface.
Look for -CL in the reader name to ensure you are referring to the contactless
interface in the following calls.
LONG SCardListReaders( IN SCARDCONTEXT hContext,
IN LPCTSTR mszGroups,
OUT LPTSTR mszReaders,
IN OUT LPDWORD pcchReaders);
4. Connect
Connect to the card. The SCardConnect function establishes a connection (using a
specific resource manager context) between the calling application and a smart card
contained by a specific reader. If no card exists in the specified reader, an error is
returned.
LONG SCardConnect( IN SCARDCONTEXT hContext,
IN LPCTSTR szReader,
IN DWORD dwShareMode,
IN DWORD dwPreferredProtocols,
OUT LPSCARDHANDLE phCard,
OUT LPDWORD pdwActiveProtocol);
5. Exchange Data and Commands with the Card
Exchange command and data through APDUs. The SCardTransmit function sends a
service request to the smart card, expecting to receive data back from the card.
LONG SCardTransmit( IN SCARDHANDLE hCard,
IN LPCSCARD_I0_REQUEST pioSendPci,
IN LPCBYTE pbSendBuffer,
IN DWORD cbSendLength,
IN OUT LPSCARD_IO_REQUEST pioRecvPci,
OUT LPBYTE pbRecvBuffer,
IN OUT LPDWORD pcbRecvLength);
Note: For unsupported PC/SC 2.0 storage cards, call an OMNIKEY proprietary API
function such as SCardCLICCTransmit instead. This function exposes additional
functionality of the OMNIKEY 5x21-CL reader that is not yet defined in PC/SC
standards. Otherwise, you are still using the standard PC/SC framework to track
cards, list readers, etc. Even the smart card handle is the same.
6. Disconnect
It is not necessary to disconnect the card after the completion of transactions, but it
is recommended. The SCardDisconnect function terminates a connection previously
opened between the calling application and a smart card in the target reader.
LONG SCardDisconnect( IN SCARDHANDLE hCard,
IN DWORD dwDisposition);
7. Release
This step ensures all system resources are released. The SCardReleaseContext
function closes an established resource manager context, freeing any resources
allocated under that context.
LONG SCardReleaseContext( IN SCARDCONTEXT hContext);
5.1.1 Example: Write Card Data through ISO 7816-4 Framed APDU
Command Syntax
CLA INS P1 P2 Lc File No. Offset Length Data Le
‘90’ ‘3D’ ‘00’ ‘00’ ‘xx’ ‘xx’ ‘xxxxxx’ ‘xxxxxx’ ‘xx’ … ‘xx’ ‘00’
Status Codes
SW1 SW2 Description
'90' '00' success
'91’ 'xx error (see the MIFARE DESFire data sheet)
5.1.2 Example: Read Card Data through ISO 7816-4 Framed APDU
Command Syntax
CLA INS P1 P2 Lc File No. Offset Length Data Le
‘90’ ‘BD’ ‘00’ ‘00’ ‘07’ ‘xx’ ‘xxxxxx’ ‘LLLLLL’ empty ‘00’
Status Codes
SW1 SW2 Description
'90' '00' success
'91’ 'xx error (see to the MIFARE DESFire data sheet)
No special drivers are required for PC/SC 2.0 compliant card integration with Windows or
Linux. OMNIKEY’s latest drivers provide seamless cross-platform support allowing industry
standard-compliant contactless card integration.
Reference the [PCSC 2.01] and [MIFARE] for documentation of PC/SC 2.0 compliant
MIFARE card access. The following section only describes usage of functions that are not
already documented in [PCSC 2.01]. They are part of an OMNIKEY proprietary extension of
PC/SC.
Response Syntax
Data Field Empty
SW1 SW2 status word as described below
‘90’ ‘00’ Success
'65' ‘81’ memory failure (unsuccessful increment)
‘69’ ‘81’ incompatible command
‘69’ ‘82’ security status not satisfied
‘69’ ‘86’ command not allowed
‘6A’ ‘81’ function not supported
‘6A’ ‘82’ invalid block address
Response Syntax
Data Field Empty
SW1 SW2 status word as described below
‘90’ ‘00’ Success
'65' ‘81’ memory failure (unsuccessful decrement)
‘69’ ‘81’ incompatible command
‘69’ ‘82’ security status not satisfied
‘69’ ‘86’ command not allowed
‘6A’ ‘81’ function not supported
‘6A’ ‘82’ invalid block address
Note: Restart the OMNIKEY Contactless Smart Card driver after changing the registry keys
(disconnect and then reconnect the reader).
Parameter Description
handle to the card, provided from the PC/SC smart card resource
ulHandleCard
manager after connecting to the card with SCardConnect
pucSendData buffer for data sent to the reader/card, typically a command APDU
ulSendDataBufLen length of the data to be sent
pucReceivedData buffer for data received from reader/card, typically data and status
before the call: length (in bytes) of the receive buffer
pulReceivedDataBufLen
after the call: number of bytes actually received
Command Syntax
***
CLA INS P1 P2 Lc Input Data or Datagram Le
‘8x’ ‘xx’ ‘xx’ ‘xx’ ‘xx’ ‘xx’ ... ‘xx’ (Lc bytes) ‘xx’
Response Syntax
***
Response Data or Datagram SW1 SW2
‘xx’ .. ‘xx’ (Le or max bytes) ‘xx’ ‘xx’
Status Codes
SW1 SW2 Description
'90' '00' success
'64' '00' card execution error
'67' '00' wrong length
'68' '00' invalid class (CLA) byte
security status not satisfied. This can include wrong data structure, wrong
'69' '82'
keys, incorrect padding.
'6A' '81' invalid instruction (INS) byte
'6B' '00' wrong parameter P1 or P2
The error codes defined in the previous Status Codes table are valid for all the commands.
Command specific error codes are documented with their respective command
documentation.
Note: The error code 6982 security status not satisfied, received during secured
communication, blocks any further commands. Remove and reinsert the card to reactivate
communication with the card.
This ISO15693 compliant IC is not accessible with standard driver settings. It requires the
following registry key setting:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CardMan\RFID]
"ControlFlags"=dword:00000010
See the [PCSC 2.01] and [LRI64] for documentation of PC/SC 2.0 compliant LRI64 card
access. The following section describes usage of functions that are not already
documented in [PCSC 2.01].
The response is ‘6282’ or End of file reached before reading expected number of
bytes. Even though the warning ‘6282’ is returned, all bytes from block 0 up to block
14 are read correctly.
The response is the error code ‘6A82’ because block number 15 does not exist.
Note: The OMNIKEY synchronous API does not support the new MIFARE Plus cards (for
example SL1 cards). Use the command set from PC/SC 2.01 part 3. The MIFARE functions
from the sample application, contactlessdemoVC and contactlessdemoVB require the
synchronous API. These applications do not work with MIFARE Plus cards.
At first the application must send the following APDU with SCardTransmit.
Send FFA0000703010001
Receive 9000
The green labeled PCB, CID filed is only available if the card is switched to ISO14443-4. If
desired, leave the data field empty. The status code in this sample is successful code.
7.4.1 MIFARE Plus commands with the GENERIC INTERFACE Command APDU
Samples
Switching to ISO14443 part 4 (RATS) Sample
Send FFA00005080100F3000064E08100
Receive 00000C757784024D46505F454E479000
First Authentication Sample
Send FFA000050C0100F30000640A017002900000
Receive 00000A0190XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9000
SL1 authentication Sample
Send FFA00005090100F300006476049000
Receive 000090XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9000
After the generic interface session, close the session. Do not skip this step.
The application must send the following APDU with SCardTransmit.
Send FFA0000703010002
Receive 9000
Key Key
Key # Key Name Memory Type
Length Type
KMC4 (Default Master Key for application 8 bytes Card Non- volatile memory
‘2B’
2) of page 4 of iCLASS card Key
KMD5 (Default Master Key for application 8 bytes Card Non- volatile memory
‘2C’
1 of page 5 of iCLASS card) Key
KMC5 (Default Master Key for application 8 bytes Card Non- volatile memory
‘2D’
2 of page 5 of iCLASS card) Key
KMD6 (Default Master Key for application 8 bytes Card Non- volatile memory
‘2E’
1 of page 6 of iCLASS card) Key
KMC6 (Default Master Key for application 8 bytes Card Non- volatile memory
‘2F’
2 of page 6 of iCLASS card) Key
KMD7 (Default Master Key for application 8 bytes Card Non-volatile memory
‘30’
1 of page 7 of iCLASS card) Key
KMC7 (Default Master Key for application 8 bytes Card Non- volatile memory
‘31’
2 of page 7 of iCLASS card) Key
KMTD (Master Transport Key for 8 bytes Card Non volatile memory
‘32’
application 1 of Picopass cards) Key
KMTC (Master Transport Key for 8 bytes Card Non- volatile memory
‘33’
application 2 of Picopass cards) Key
KMD0B1 (Default Master Key for 8 bytes Card Non-volatile memory
‘34’ application 1 of page 0 on Book 1 of Key
iCLASS card)
‘35’..’7F’ RFU
16-byte keys
KCUR (Custom read key) 16 Reader Non-volatile memory
‘80’
bytes Key
KCUW (Custom write Key) 16 Reader Non- volatile memory
‘81’
bytes Key
KENC (Card data encryption key) 16 Card Non- volatile memory
‘82’
bytes Key
24- byte keys
‘B0’..’CF’ RFU
32-byte keys
‘D0’..’DF’ RFU
0xF0 to 0xFF are volatile keys
0xF0 KVAK (volatile application key) 8 bytes Card Volatile memory
Key
‘F1’...‘FF’ RFU
Note: OMNIKEY Contactless Smart Card reader firmware version 5.00 is the first to support
all keys listed above. Readers with firmware version 1.03 and 1.04 only support key
numbers 0x20 and 0xF0.
Key number 0x21 to Key number 0x31 (except 0x22) are the default keys for iCLASS cards.
Key number 0x32 and 0x33 are the default transport keys for Inside cards.
Keys 0x21 and 0x22 are stored in the reader. The remaining non-volatile keys 0x23 to 0x33
are stored in the registry.
Key 0x21 cannot be updated. Updates of key 0x22 are RFU and currently not supported.
Response Syntax
empty or
Data Field
8 byte card response, in case of a previous request for such data
SW1 SW2 status word as described below
‘90’ ‘00’ Success
‘62’ ‘83’ requested page number does not exist
‘6C’ ‘xx’ wrong length Le. xx returns the number of data available
Note: Only load a key in volatile memory once during any given card session. Unless you
need to authenticate to any additional application with a different key, you can use the
stored key throughout the session for more than one authentication.
Response Syntax
Data Field Empty
SW1 SW2 status word as described below
‘90’ ‘00’ success
‘63’ ‘00’ no further information given (warning)
‘63’ ‘81’ loading/updating is not allowed
‘63’ ‘82’ card key not supported
‘63’ ‘83’ reader key not supported
‘63’ ‘84’ plaintext transmission not supported
‘63’ ‘85’ secured transmission not supported
‘63’ ‘86’ volatile memory is not available
‘63’ ‘87’ non-volatile memory is not available
‘63’ ‘88’ key number not valid
‘63’ ‘89’ key length is not correct
Response Syntax
2 byte key information
Data Field
see Key Information and Key Access Option below
SW1 SW2 status word as described below
‘90’ ‘00’ success
‘63’ ‘00’ no further information given (warning)
‘63’ ‘01’ key slot does not contain valid key or empty key slot
‘62’ ‘83’ requested key slot does not exist
‘6C’ ‘xx’ more data available than requested; xx returns available data size
Response Syntax
Data Field empty
SW1 SW2 status word as described below
‘90’ ‘00’ success
‘63’ ‘00’ no further information given (warning)
‘69’ ‘83’ authentication cannot be done
‘69’ ‘84’ reference key not useable
‘69’ ‘88’ key number not valid
Response Syntax
8 byte block returned from the card (iCLASS)
Data Field
32 bytes returned if card supports it
SW1 SW2 status word as described below
‘90’ ‘00’ success
‘62’ ‘81’ part of returned data may be corrupted
‘62’ ‘82’ end of file reached before reading all requested bytes
‘69’ ‘81’ command incompatible
‘69’ ‘86’ command not allowed
‘6A’ ‘81’ function not supported
‘6A’ ‘82’ file not found or addressed block or byte does not exist
‘6C’ ‘xx’ more data available than requested; xx returns available data size, typically ‘08’
Note: Reading blocks without valid authentication or trying to read data without read
permission, will set all returned data to ‘FF’.
Response Syntax
Data Field empty
SW1 SW2 status word as described below
‘90’ ‘00’ success
‘62’ ‘82’ end of file reached before writing all Lc bytes
‘65’ ‘81’ memory failure (unsuccessful writing)
‘69’ ‘81’ command incompatible
‘69’ ‘86’ command not allowed
‘6A’ ‘81’ function not supported
‘6A’ ‘82’ file not found or addressed block or byte does not exist
1 Establish Context
3 Connect Card
4 Select Page
No
Yes
5 Load Key Same Page
6 Authenticate Application
7 Read/Update
Yes
Yes Same No
Further
Read/Update Application
No
8 Disconnect Card
9 Release Context
Response Syntax
Output Datagram (received from the reader) SW2 SW1
‘xx ... xx’ ‘xx’ ‘xx’
When the host system sends a Host Data Header (HDH) to the reader, the reader must
acknowledge the HDH in its response by returning the 1’s complement of the original HDH.
This allows the host to check whether it receives data originating from the correct data
header.
When the reader sends a Reader Data Header (RDH) to the host, the host must
acknowledge the RDH in its next request by sending the 1’s complement of the preceding
RDH. This allows the reader to check whether the data sent by the host follows a previous
reader response.
HDH RDH
HDH RDH
HDH RDH
HDH RDH
Note: This is a read-only session because KCUR was used in the start session command. If
KCUW were used to start the session, both read and write operations would be allowed. The
HID application is always read-only.
In the following sections the command structure is described. LcINS and INSData are part
of the OMNIKEY proprietary structure.
Notes:
Secured mode and Standard Mode use different formatting of P1, bit 7 and bit 6 of the
Read/Update commands (INS 0xB0 and 0xD6 respectively). Use the two LSBits of P1 to
control the encryption of data read or updated.
Lc must always be transmitted in secured mode.
Response Syntax
Data Field empty
SW1 SW2 status word as described below
‘90’ ‘00’ success
Data needs to be decrypted with the KENC to get the plaintext data.
Lc ‘00’: empty
Data Field empty
Le empty
Response Syntax
Data Field empty
SW1 SW2 status word as described below
‘90’ ‘00’ Success
'65' '81' Memory failure (unsuccessful writing)
Command incompatible
'69' '81' ‘86’
Command not allowed
'6A' '81' Function not supported
1 Establish Context
3 Connect Card
4 Start Session
5 Select Page
No
6 Yes Same
Load Key
Page
7 Authenticate Application
8 Read/Update Yes
No
9 End Session
10
Disconnect Card
11 Release Context
3-
DESDec{(4A895F20C2D30B5E9E5052819C5A8D3C),(A04B84A4DE515FD8A9D40DFFE7
03FBF1) }
= EBDDE00C00800000E367401E2DA8FACB
Signature = DESEn{(4A895F20C2D30B5E),( EBDDE00C00800000) }
= E367401E2DA8FACB
Note: A public source library to accomplish all security protocols introduced in the secured
communication mode is available from OMNIKEY upon request.
Signature = DESEn{(4A895F20C2D30B5E),(B3F11FF300800000)}
= B50318C9E871191A
3-DESDec{(4A895F20C2D30B5E9E5052819C5A8D3C),
(78A10C4FCC7EBC2C516354A56C4C7818) }
= 4C0E7D5500800000D2D0B0B4E34EBDBE
Note: A public source library to accomplish all security protocols introduced in the
secured communication mode is available from OMNIKEY upon request.
3. Read Block 6
SW1
OMNIKEY Proprietary Response Datagram
SW2
AA401E3D849B881044FF4D847977D9070C589338C097F163 9000
3-DESDec { (4A895F20C2D30B5E9E5052819C5A8D3C),
(AA401E3D849B881044FF4D847977D9070C589338C097F163)}
= 989D2A9408000000000000E4148000003101DDB971C922FF
Signature = DESEn{(4A895F20C2D30B5E),(
989D2A9408000000000000E414800000) }
= 1CDF21DCA31BABDB3101DDB971C922FF
= 3101DDB971C922FF (last 8-byte block)
Note: A public source library to accomplish all security protocols introduced in the secured
communication mode is available from OMNIKEY upon request.
11 Reading ISO15693
11.1 Products
This document describes the commands for ISO 15693 support of OMNIKEY Contactless
Smart Card reader.
Applicable readers are:
OMNIKEY 5321 USB
OMNIKEY 6321 USB
OMNIKEY 5321 CL
OMNIKEY 5321 CR
OMNIKEY 5421
Applicable drivers and operating system:
MS Windows Drivers Version from1.2.0.6.
11.2 Tags
The following tags and functions are covered by this document
• iCODE (see the following table)
• LRI 64
• SLC Montalbano Technology
1
• Texas Instruments Tag-it
2
• Infineon (MY-D, MY-D light)
• All ISO 15693-3 compliant Tags with support for functions marked as optional.
(Include tag functions Inventory, Stay Quiet …etc.)
1
Tag-it Standard and Pro do only support READ BINARY, UPDATE BINARY, GET DATA PICC memory and
LOCK, Applicable at MS Windows Drivers Version 1.2.0.14
2
Applicable at MS Windows Drivers Version 1.2.0.14
11.3 Commands
P1/P2 denotation
P1 P2 Description
0x00 0x00 RFU
0x01 0x00 RFU
0x02 0x00 AFI of a ISO 15693 card is returned if supported
0x03 0x00 DSFID of a ISO 15693 card is returned if supported
0x04 0x00 PICC memory size is returned if supported
0x05 0x00 IC reference is returned if supported
0x06 0x00 EAS sequence (only for I-CODE SLI cards) is returned ,
Note: EAS sequence is a bit stream which is sent LSB first !!!
SW1SW2 Examples
SW1 SW2 Meaning
Warning ‘62’ ‘82’ End of data reached before Le bytes (Le is greater than data
length).
Error ‘6A’ ‘81’ Function not supported
‘6C’ ‘xx’ Wrong length (wrong number Le; ‘XX’ encodes the exact
number) if Le is less than the available UID length)
3
EAS is supported by MY-D; EAS must be enabled in AFI byte (bit 2)!
4
The chip does not support the optional ISO15693-3 command type.
11.3.3 Lock
5
Use this command to lock the memory area of a contactless card.
Lock APDU
Command Class INS P1 P2 Lc Data In Le
Lock 0xFF 0x30 0x00 0x02 3+N See table -
5
Command is not supported by MY-D light; to set and get security you can use the generic command.
Reference the Infineon MY-D light specification and OK5x21_ISO15693_GenericCardCommands.doc
Le codes the number of bytes for which the security status should be retrieved.
6
Command is not supported by MY-D light; to set and get security, use the generic command. Reference the
Infineon MY-D light specification and OK5x21_ISO15693_GenericCardCommands.doc
For each address/block number/page number, retrieved is one byte with the security
status.
ICODE SLI Data 1, Data 2 contains the block number (0 – 27). Each block has 4 bytes.
LRI 64 Data 1, Data 2 contains the block number (0 – 14). Each block has 1 byte.
SLC
Montalbano Data 1, Data 2 contains the block number (0 – 63). Each block has 8 bytes.
Technology
Data1, Data2 contains the block number (0 - ((16 * 4) –1) )
Note: MIFARE 1k has 16 sectors. Each sector has 4 blocks.
MIFARE 1k
Each block has 16 bytes.
(Get Security Status currently not supported)
Data1, Data2 contains the block number (0 - ((32 * 4 + 16*4) –1) )
Note: MIFARE 4k has 32 sectors which have 4 blocks and 16 sectors which
MIFARE 4k have 16 blocks.
Each block has 16 bytes.
(Get Security Status currently not supported)
Data1, Data 2 contains the page number (0 – 15). Each page has 4 bytes.
MIFARE Ultralight
(Get Security Status currently not supported)
Data1, Data2 contains the block number (0 - ((5 * 4) –1) )
Note: MIFARE Mini has 5 sectors. Each sector has 4 blocks.
MIFARE Mini
Each block has 16 bytes.
(Get Security Status currently not supported)
Data 1, Data 2 contains the block number.
MY-D
(SRF55V10P: 0 – 247, SRF55V02P: 0 – 55) Each block has 4 bytes.
X ….. no meaning
The following table describes examples of SW1SW2 and their description:
Get Security Status Error Codes
SW1 SW2 Description
Warning '63' '00' No information is given
7
‘64’ ‘00’ Execution error
‘6A’ ‘81’ Function not supported
Error
'69' '82' Security status not satisfied
‘86’ Command not allowed, no ISO15693-3 chip
7
The chip does not support the optional ISO15693-3 command type.
8
Currently are extended APDU’s only supported for Texas Instruments Tag-it and Infineon MY-D.
9
Currently are extended APDU’s only supported for Texas Instruments Tag-it and Infineon MY-D.
For LED control, before receiving the PICC answer, the application must use Param1 = 01 as,
USB Pipe Control Command.
Param2 is coded as 0000 00xx ( bit 2…7 is RFU ).
Table 5 - Summary of Param2
LED status Value Description
1 bicolor green LED on
Bit 0
0 bicolor green LED off
1 bicolor red LED on
Bit 1
0 bicolor red LED off
For details, see the code example in Appendix A.7.12 PayPass Signal MAIN LED.
Summary of Param2
LED status Value Description
1 green LED2 on
Bit 0
0 green LED2 off
1 green LED3 on
Bit 1
0 green LED3 off
1 green LED4 on
Bit 2
0 green LED4 off
For details see the code example in Appendix A.7.13 PayPass Signal Additional LEDs.
If the reader is switched to ISO mode, use the complete functionality of a standard
OMNIKEY Contactless Smart Card reader.
Note: Currently the EMVCo type approval is confined to the firmware version 1.75. This
firmware version does not support the read and write operations of iCLASS cards.
For a static usage in ISO mode switch the reader behavior with the following registry entry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CardMan\CardInterface]
ContactlessDefault=dword:00000000
13.1 Overview
The OMNIKEY reader driver can be configured for a wide range of HID PROX card formats
both standard and custom, allowing the card reader system to process any Wiegand raw
bit stream. Driver settings control how raw data is being translated to data fields such as
facility code (FAC) and card number (CN) that are meaningful within the scope of physical
access control systems (PACS).
This chapter describes the ProxFormat setting available to control the OMNIKEY reader
driver. This document also describes how the system can be configured to return either
PACS facility code and card number or just raw Wiegand data.
The same card, with ProxFormat set to H10301 would return ATR=3B06010001004786 hex
– a card with FAC=1 and CN=4786.
Described later in this guide is how to parse and translate raw data to data fields according
to the applicable PROX Format.
14 ProxFormat Settings
This mode gives you the greatest flexibility. This is important in systems without a well-
known card population i.e. where the card format can vary or even is unknown. Having this
flexibility comes at a price though, any parsing that otherwise is done by the driver would
have to be done by the hoist application.
Example:
Setting ProxFormat to ‘01’ instructs the driver to interpret the series of bits received from a
PROX card as HID H10301 formatted PROX data. The rightmost six BCD formatted digits of
the historical byte block represent the card number CN. The card number can also be
found engraved on the card.
With ProxFormat set to ‘01’, a card with FAC=0001 and CN=000061 would return an ATR
of ‘3B 06 01 00 01 00 00 61’.
TIP: If you do not know whether you have a standard or custom formatted card, set
ProxFormat to hex FE (AUTO). Then present the card. If the reader can detect a standard
card format, it will return its respective ProxFormat value in the third ATR byte. This is a
quick way to find out the format of the most popular cards.
The following sections show CustomProxFormat entries for some standard PROX card
formats including the raw data and resulting parsed and interpreted data fields for facility
code and card number.
FAC = N/A
Sample code for Visual Basic is also available and found in:
c:\Program Files\Samples\contactlessdemovb.
The sample uses the OMNIKEY synchronous API and demonstrates how to select a reader,
connect a card, and access either a MIFARE or iCLASS card.
A.1 Overview
From the Connected Reader list (top-left corner), select the reader. The list contains all
readers available to the smart card resource manager. When a card is inserted, displayed
are the ATR, UID and Card Name fields. From the Reader Related Function frame, select
the functions with or without a card in the RF field.
Only use the MIFARE Functions using Sync API frame when a MIFARE card is in the field.
Use the ISO 7816/iCLASS/PCSC 2.01 frame for APDU exchange with a CPU card
(asynchronous card) in the field.
Each processed command produces output in the output log. Clear the log with the
Refresh Output Screen button. The return status of the last executed function is shown in
the Last Operation Status frame.
Close the application with the Exit button.
BYTE InBuffer[16];
BYTE OutBuffer[16];
DWORD dwInBufferSize ;
DWORD dwOutBufferSize;
DWORD dwBytesReturned;
DWORD *Mask = (DWORD *)InBuffer;
DWORD *Value = (DWORD *)InBuffer+1;
DWORD dwControlCode = CM_IOCTL_SET_RFID_CONTROL_FLAGS;
*Mask = 0x00000004;
*Value = dwControlFlag & *Mask;
dwInBufferSize = 8;
dwOutBufferSize = 0;
dwBytesReturned = 0;
SCard_Status = SCardControl(hCard,
dwControlCode,
(LPCVOID)InBuffer,
dwInBufferSize,
(LPVOID)OutBuffer,
dwOutBufferSize,
&dwBytesReturned);
if (SCard_Status == SCARD_S_SUCCESS)
{
if(dwControlFlag)
sprintf(szText,MIFARE\t);
else
sprintf(szText,T=CL\t);
}
else
{
sprintf(szText,IO Cntrol error\r);
}
SCard_Status = SCardCLICCTransmit(hCard,ucDataSend,ulNoOfDataSend,
ucReceivedData,&ulNoOfDataReceived);
if(SCard_Status!= SCARD_S_SUCCESS)
{
printf(Error in SCardCLICCTransmit, with error code %8X, SCard_Status);
exit(-1);
}
do
{
// wait for card
do
{
sReaderState.szReader = szReaderName;
sReaderState.dwCurrentState = SCARD_STATE_EMPTY;
sReaderState.dwEventState = SCARD_STATE_EMPTY;
SCardGetStatusChange(hContext,30,&sReaderState,1);
Sleep(20);
}
while((sReaderState.dwEventState & SCARD_STATE_PRESENT) == 0);
continue;
}
// Connect card
dwShareMode = SCARD_SHARE_SHARED;
dwPreferredProtocols = SCARD_PROTOCOL_T1;
}
while( /*TODO: Code for PAY application*/ );
BYTE InBuffer[4];
BYTE OutBuffer[4];
DWORD dwInBufferSize;
DWORD dwOutBufferSize;
DWORD dwBytesReturned;
DWORD dwControlCode = CM_IOCTL_SET_OPERATION_MODE;
BYTE InBuffer[4];
BYTE OutBuffer[4];
DWORD dwInBufferSize ;
DWORD dwOutBufferSize;
DWORD dwBytesReturned;
DWORD dwControlCode;
BYTE bUSBMode = 0x01; // USB Pipe Control
BYTE bReaderLEDs = 0x02; // red LED on
BYTE bLEDMode = 0x03; // application controlled
dwControlCode = CM_IOCTL_SIGNAL;
InBuffer[0] = PAYPASS_SIGNAL_MAINLED;
InBuffer[1] = bUSBMode;
InBuffer[2] = (bReaderLEDs) & 0x03;
InBuffer[3] = bLEDMode;
dwInBufferSize = 4;
dwOutBufferSize = 0;
dwBytesReturned = 0;
if (SCard_Status != SCARD_S_SUCCESS)
{
BYTE InBuffer[4];
BYTE OutBuffer[4];
DWORD dwInBufferSize ;
DWORD dwOutBufferSize;
DWORD dwBytesReturned;
DWORD dwControlCode;
dwControlCode = CM_IOCTL_SIGNAL;
InBuffer[0] = PAYPASS_SIGNAL_ADDLED;
InBuffer[1] = bUSBMode;
InBuffer[2] = (bReaderLEDs >> 2) & 0x07;
dwInBufferSize = 3;
dwOutBufferSize = 0;
dwBytesReturned = 0;
if (SCard_Status != SCARD_S_SUCCESS)
{
// TODO: Code for PAY application
BYTE InBuffer[4];
BYTE OutBuffer[4];
DWORD dwInBufferSize ;
DWORD dwOutBufferSize;
DWORD dwBytesReturned;
DWORD dwControlCode;
dwControlCode = CM_IOCTL_SIGNAL;
InBuffer[0] = ACOUSTIC_SIGNAL_BEEPER_ON;
dwInBufferSize = 1;
dwOutBufferSize = 0;
dwBytesReturned = 0;
dwControlCode = CM_IOCTL_SIGNAL;
InBuffer[0] = ACOUSTIC_SIGNAL_BEEPER_OFF;
dwInBufferSize = 1;
dwOutBufferSize = 0;
dwBytesReturned = 0;
Memory Layout
Shown is the memory layout of an iCLASS 2KS, iCLASS 16KS or page 0 of an iCLASS 8x2KS
card.
KS Session Key
Appendix: G References