Hid Omnikey Contactless Smart Card Reader Developer Guide
Hid Omnikey Contactless Smart Card Reader Developer Guide
Irvine, CA 92618-2215
DEVELOPER GUIDE
© 2005 - 2010 HID Global Corporation. All rights reserved.
Contents
Purpose ............................................................................................................................................ 3
1 Contactless Reader Coverage ...................................................................................................... 4
2 Getting Started ............................................................................................................................... 5
2.1 Driver Installation ................................................................................................................ 5
2.2 Diagnostic Tool ................................................................................................................... 8
3 PC/SC 2.0 ...................................................................................................................................... 12
3.1 How to Access Contactless Cards through PC/SC .......................................................... 12
3.2 ATR Generation ................................................................................................................ 14
4 Accessing Asynchronous Cards................................................................................................ 15
4.1 MIFARE DESFire Card ..................................................................................................... 15
5 Accessing Synchronous Cards (Storage) ................................................................................. 17
5.1 MIFARE Card.................................................................................................................... 17
5.2 iCLASS Card..................................................................................................................... 21
5.3 ST LRI64 Support (PC/SC 2.0 add-on)............................................................................. 22
5.4 ISO15693-3 Memory Card Support .................................................................................. 23
6 Communication with MIFARE Plus ............................................................................................ 24
6.1 ISO 14443 A – part 4 card communication ....................................................................... 24
6.2 ISO 14443 A – part 3 card communication ....................................................................... 24
6.3 Open Generic Session...................................................................................................... 24
6.4 Generic Card Commands ................................................................................................. 25
6.5 Close Generic Session ..................................................................................................... 26
7 CardMan 5x21-CL Keys ............................................................................................................... 27
7.1 Key Numbering Scheme ................................................................................................... 27
7.2 Key Container and Slots ................................................................................................... 30
7.3 Key Update Rules ............................................................................................................. 31
8 Standard Communication with iCLASS Card............................................................................ 32
8.1 APDU Structure for Standard Communication ................................................................. 32
8.2 Commands Available in Standard Communication Mode ................................................ 32
8.3 Communication in Standard Mode.................................................................................... 40
9 Secured Communication with the iCLASS Card ...................................................................... 41
9.1 Multi-Step Approach to a Secure Card Reader System ................................................... 41
9.2 APDU Structure for Secured Communication................................................................... 42
9.3 Instructions (INS) for Secured Communication ................................................................ 45
9.4 Communication at Secured Mode..................................................................................... 49
9.5 Session at Secured Mode APDUs Example..................................................................... 50
10 Reading ISO15693........................................................................................................................ 53
10.1 Products ............................................................................................................................ 53
10.2 Tags .................................................................................................................................. 53
10.3 Commands........................................................................................................................ 54
11 OMNIKEY 5321 PAY Application Interface ............................................................................... 62
11.1 PayPassTM card transactions ............................................................................................ 62
11.2 LED and Buzzer control .................................................................................................... 62
11.3 Switch-over the operating mode ....................................................................................... 64
12 CardMan 5125 Registry Settings ................................................................................................ 66
Trademarks
HID, HID Global and OMNIKEY are the trademarks or registered trademarks of HID Global Corporation in
the U.S. and other countries.
MIFARE® is a registered trademark of NXP Semiconductors
my-d TM is a registered trademark of Infineon Technologies
Contacts
OMNIKEY brand product support
HID Global GmbH
email: [email protected]
Fax: +49 (0) 6123 7913-28
web: http://www.hidglobal.com/omnikeyCustomerSupportForm.php
http://www.hidglobal.com/omnikey
Purpose
Guide for developers for integrating contactless storage or CPU cards using OMNIKEY CardMan 5x21 and
6x21 smart card readers.
All readers listed are based on the OMNIKEY 5x21 RFID chipset. Therefore this document will use the term
5x21 to reference OMNIKEY readers.
2 Getting Started
This chapter describes how to install the drivers necessary to operate the OMNIKEY 5x21 in a Windows based
environment.
Note: Other operating systems, such as Linux, are also supported by the OMNIKEY 5x21.
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
Yes.
10. The following message appears and the green LED illuminates on the OMNIKEY 5x21
reader.
If the installation was successful, the green LED on the reader illuminates and the reader is listed in
the diagnostic tool as OMNIKEY 5x21.
Your reader is ready for use. Do a quick smart card system check using the OMNIKEY Diagnostic
Tool described in Diagnostic Tool, page 8.
3 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.
Access contactless CPU cards directly through PC/SC. 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.
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 5x21 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. 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
Now, you can 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);
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 absolutely necessary to disconnect the card after the completion of all 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);
4.1.1 Example: Write Card Data through ISO 7816-4 Framed APDU
Command Syntax
Response Syntax
Status Codes
4.1.2 Example: Read Card Data through ISO 7816-4 Framed APDU
Command Syntax
Response Syntax
Status Codes
GetUID
LoadKey
Authenticate
Implemented according to [PCSC 2.01]
Verify
Update Binary
Read Binary
Increment OMNIKEY proprietary extension of PC/SC
Decrement OMNIKEY proprietary extension of PC/SC
OMNIKEY proprietary extension of PC/SC
MIFARE Emulation Mode
CM_IOCTL_SET_RFID_CONTROL_FLAGS
Refer to 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
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
The error codes defined in the above 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
Refer to 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 do not support the new MIFARE Plus cards e.g. SL1 cards. The
command set from PC/SC 2.01 part 3 must be used. The MIFARE functions from the sample application
„contactlessdemoVC“ and „contactlessdemoVB“ 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. The data field can be
empty. The status code in this sample is the success code.
Sample for Mifare+ commands with the GENERIC INTERFACE Command APDU.
Sample for switching to ISO14443 part 4 (RATS):
Send FFA00005080100F3000064E08100
Receive 00000C757784024D46505F454E479000
Sample for first authentication:
Send FFA000050C0100F30000640A017002900000
Receive 00000A0190XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9000
Sample for SL1 authentication:
Send FFA00005090100F300006476049000
Receive 000090XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9000
After the generic interface session the session must be closed. Do never forgot this step.
The application must send the following APDU with SCardTransmit:
Send FFA0000703010002
Receive 9000
OMNIKEY CardMan 5x21-CL has a set of built-in cryptographic keys, some of which are implemented in
volatile memory and others in non-volatile memory.
Refer to [MIFARE] and [ICLASS] for detailed documentation of these third-party keys and contact your card
manufacturer in case you need information about any key values.
Keys Numbers and Key Names
Memory
Key Number Key Name Key Length Key Type
Type
6-byte (MIFARE) keys
KMIF0 (MIFARE Key 0) to KMIF31 (MIFARE Key 6 bytes Card Key Non-
‘00’ to ‘1F’ 31) volatile
memory
8-byte (iClass) keys
KIAMC (Any Inside Application Master key) 8 bytes Card Key Non-
‘20’ volatile
memory
KMDC HID Master Key 8 bytes Card Key Non-
‘21’ (KMD0, Kd for application 1 of page 0 on Book volatile
0 of iCLASS card) memory
RFU 8 bytes Card Key Non-
‘22’ (previously used for HID Master Key KMDO) volatile
memory
KMC0 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘23’ page 0 of iCLASS card) volatile
memory
KMD1 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘24’ page 1 of iCLASS card) volatile
memory
KMC1 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘25’ page 1 of iCLASS card) volatile
memory
KMD2 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘26’ page 2 of iCLASS card) volatile
memory
KMC2 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘27’ page 2 of iCLASS card) volatile
memory
Memory
Key Number Key Name Key Length Key Type
Type
KMD3 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘28’ page 3 of iCLASS card) volatile
memory
KMC3 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘29’ page 3 of iCLASS card) volatile
memory
KMD4 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘2A’ page 4 of iCLASS card) volatile
memory
KMC4 (Default Master Key for application 2) of 8 bytes Card Key Non-
‘2B’ page 4 of iCLASS card volatile
memory
KMD5 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘2C’ page 5 of iCLASS card) volatile
memory
KMC5 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘2D’ page 5 of iCLASS card) volatile
memory
KMD6 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘2E’ page 6 of iCLASS card) volatile
memory
KMC6 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘2F’ page 6 of iCLASS card) volatile
memory
KMD7 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘30’ page 7 of iCLASS card) volatile
memory
KMC7 (Default Master Key for application 2 of 8 bytes Card Key Non-
‘31’ page 7 of iCLASS card) volatile
memory
KMTD (Master Transport Key for application 1 of 8 bytes Card Key Non
‘32’ iCLASS card, key stored at chip production) volatile
memory
KMTC (Master Transport Key for application 1 of 8 bytes Card Key Non-
‘33’ iCLASS card, key stored at chip production)) volatile
memory
KMD0B1 (Default Master Key for application 1 of 8 bytes Card Key Non-
‘34’ page 0 on Book 1 of iCLASS card) volatile
memory
‘35’..’7F’ RFU
16-byte keys
KCUR (Custom read key) 16 bytes Reader Key Non-
‘80’ volatile
memory
KCUW (Custom write Key) 16 bytes Reader Key Non-
‘81’ volatile
memory
KENC (Card data encryption key) 16 bytes Card Key Non-
‘82’ volatile
memory
24- byte keys
‘B0’..’CF’ RFU
Memory
Key Number Key Name Key Length Key Type
Type
32-byte keys
‘D0’..’DF’ RFU
0xF0 to 0xFF are volatile keys
0xF0 KVAK (volatile application key) 8 bytes Card Key Volatile
memory
‘F1’...‘FF’ RFU
Note: OMNIKEY 5x21 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.
Standard communication means there is no authentication of the host application (for example Microsoft
Windows) to the OMNIKEY 5x21-CL. Unless the card itself has built-in mechanisms for confidential
communication, the channel between host and reader is unprotected, exposing the connecting USB cable to
eavesdropping.
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
Note: If the application resides on page 0 of an 8x2KS iCLASS card or on the single page of an iCLASS 16KS
or iCLASS 2KS card, the Select Page command is not necessary. It is helpful to call Select Page anyway, in
case you need to retrieve the card serial number, configuration block, or application issuer data.
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
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’
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
Note: Updating without authenticating to the corresponding application returns ‘6400‘ Card Execution Error.
1 Establish Context
3 Connect Card
4 Select Page
No
6 Authenticate Application
7 Read/Update
Yes
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
Note: A session is automatically ended if the card is removed.
Except for the CLA byte ‘84’, and the additional formatting rules for P1 described below, the syntax for the
Read command in secured mode is identical to the command described in 8.2.5-Read (Card Command).
P1 Formatting for Secured Mode
b7 b6 b5 – b0 Description
0 0 Plain
0 1 DES Encryption
Block Nr. MSB
1 0 Triple DES Encryption
1 1 RFU
Data needs to be decrypted with the KENC to get the plaintext data.
Except for the CLA byte ‘84’, and additional formatting of P1 described below, the syntax for the Update
command in secured mode is identical with the command described in 8.2.6-Update (Card Command).
P1 Formatting for Secured Mode
b7 b6 b5 – b0 Description
0 0 Plain
0 1 DES Encryption
Block Nr. MSB
1 0 Triple DES Encryption
1 1 RFU
Except for the CLA byte ‘84’, the syntax for 7.3.7 GetKeySlotInfo in secured mode is identical to the command
described in 8.2.3-GetKeySlotInfo (Reader Command).
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
Reference section 5.2.1-Card Access through SCardCLICCTransmit for additional status words common to all
iCLASS access functions.
The sequences for using UpdateCardKey command are as follows:
1. If the desired change of the key is not in page 0, the page has to be selected by a Select
Page command.
2. Load transport/old key by Load Key command.
3. Authenticate the card with the old key (key number as used for Load Key in step 2).
4. Load new key by Load Key command.
5. Now send the Update CardKey command with specific P2 (New Key number as loaded in
step 4).
Note: Only update KD (application 1) after authentication with KD, and only update KC (application 2) after
authentication with KC.
CAUTION: Do not write directly to address 3, 4 where KC and KD are stored, this will destroy the keys.
3 Connect Card
4
Start Session
5 Select Page
No
7 Authenticate Application
8 Read/Update
Yes
No
No
9 End Session
10
Disconnect Card
11 Release Context
A04B84A4DE515FD8A9D40DFFE703FBF1 9000
DH MAC
3-DESDec{(4A895F20C2D30B5E9E5052819C5A8D3C),(A04B84A4DE515FD8A9D40DFFE703FBF1) }
= EBDDE00C00800000E367401E2DA8FACB
Signature = DESEn{(4A895F20C2D30B5E),( EBDDE00C00800000) }
= E367401E2DA8FACB
Note: An open source library to accomplish all security protocols introduced in the secured communication
mode is available from OMNIKEY upon request.
DH MAC
B5FD83E756CA03DE54FBEA5546E8867D
Proprietary Data
Signature = DESEn{(4A895F20C2D30B5E),(B3F11FF300800000)}
= B50318C9E871191A
78A10C4FCC7EBC2C516354A56C4C7818 9000
DH MAC
3-DESDec{(4A895F20C2D30B5E9E5052819C5A8D3C),
(78A10C4FCC7EBC2C516354A56C4C7818) }
= 4C0E7D5500800000D2D0B0B4E34EBDBE
Note: An open 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
DH MAC
3-DESDec { (4A895F20C2D30B5E9E5052819C5A8D3C),
(AA401E3D849B881044FF4D847977D9070C589338C097F163)}
= 989D2A9408000000000000E4148000003101DDB971C922FF
Note: An open source library to accomplish all security protocols introduced in the secured communication
mode is available from OMNIKEY upon request.
10 Reading ISO15693
10.1 Products
This document describes the commands for ISO 15693 support of OMNIKEY 5x21.
Applicable readers are:
OMNIKEY 5321 USB
OMNIKEY 6321 USB
OMNIKEY 5321 CL
OMNIKEY 5321 CR
Applicable drivers and operating system:
MS Windows Drivers Version 1.2.0.6
10.2 Tags
The following tags and functions are covered by this document
• iCODE (see table below)
• LRI 64
• SLC Montalbano Technology
•
1
Texas Instruments Tag-it
• Infineon (MY-D, MY-D light) 2
• 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
10.3 Commands
10.3.1 Get Data
This Get Data command will retrieve information about the inserted command depending on the inserted card.
It can be used for kind of contactless cards.
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 !!!
Data Out
Data + SW1 SW2
Le = 0x00, this means: Return full length of the data
SW1SW2 Examples:
Flag1 Flag2
0x00 0x00 RFU
0x01 0x00 RFU
0x02 0x00 AFI of a ISO 15693 card is written if supported
0x03 0x00 DSFID of a ISO 15693 card is written if supported
0x04 0x00 RFU
0x05 0x00 RFU
0x06 0x00 EAS bit is written (for I-Code SLI) cards. Data field consists of one byte (bit 0 is the new
value of the EAS bit) 3
0x00 0x01 Stay quiet (the PICC does not answer any more any response), currently not supported
The following table introduces examples of SW1SW2 and their meaning.
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.
10.3.3 Lock
Use this command to lock the memory area of a contactless card. 5
Lock APDU
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 you can 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 bytes.
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 8 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
MIFARE 4k which have 16 blocks.
Each block has 8 bytes.
(Get Security Status currently not supported)
Data1, Data 2 contains the page number (0 – 15). Each page has 4 bytes.
MIFARE Ultra light
(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 8 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.
7
The chip does not support the optional ISO15693-3 command type.
Data Out
Data + SW1 SW2
8
Currently are extended APDU’s only supported for Texas Instruments Tag-it and Infineon MY-D.
Data Out
SW1 SW2
9
Currently are extended APDU’s only supported for Texas Instruments Tag-it and Infineon MY-D.
Data Out
SW1 SW2
The OMNIKEY 5321 PAY has an EMVCo Contactless Level 1 Type Approval. The application interface (API) is
compliant to PC/SC 2.01.
Table 10: Parameter for SIGNAL Command – PayPass Signal MAIN LED
Parameter Description
Command Param1 Param2 Param3 RFU
lpInBuffer 00 – CCID ESC command 00 – by default
21 LED status --
01 – USB Pipe Control 03 – application controlled
nInBufferSize >= 4
lpOutBuffer Empty
nOutBufferSize >= 0
lpBytesReturned 0
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 )
Summary of Param2
LED status Value Description
1 bicolour green LED on
Bit 0
0 bicolour green LED off
1 bicolour red LED on
Bit 1
0 bicolour red LED off
For details see the code snippet in Appendix A2.12 PayPassTM Signal MAIN LED
Table 11: Parameter for SIGNAL Command – PayPass Signal Additional LEDs
Parameter Description
Command Param1 Param2 Param3 RFU
lpInBuffer 00 – CCID ESC command
22 LED status -- --
01 – USB Pipe Control
nInBufferSize >= 3
lpOutBuffer Empty
nOutBufferSize >= 0
lpBytesReturned 0
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 snippet in Appendix A2.13 PayPassTM Signal Additional LEDs
For details see the code snippet in Appendix A2.14 PayPassTM Signal Tone
If the reader is switched to ISO mode, the complete functionality of an standard OMNIKEY 5x21 can be used.
Note: Currently the EMVCo type approval is confined to the firmware version 1.75. This firmware version do not
support the read and write operations of iClass cards.
For an static usage in ISO mode the reader behavior can also switched with the following registry entry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CardMan\CardInterface]
"ContactlessDefault"=dword:00000000
The following table shows allowed registry key entries. If there is a void value, the driver works like
“ProxFormat”=dword:00000000 is entered. (= no decoding)
Example:
The data-fields are converted into BCD format next and mapped into the ATR in the sequence A B C …. etc.
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat]
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\A]
“StartBit”=dword00000011
“BitLength”=dword:00000008
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\B]
“StartBit”=dword00000001
“BitLength”=dword:00000010
PAAAAAAAABBBBBBBBBBBBBBBBP
10000000100110000001110011
P Parity Bit
A Facility Code (FAC)
B Card Number (CN)
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat]
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\A]
“StartBit”=dword:00000001
“BitLength”=dword:000000023
PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP
0000000000000000000000000000000000010
P Parity Bit
A Card Number (CN)
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat]
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\A]
“StartBit”=dword00000014
“BitLength”=dword:00000010
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\B]
“StartBit”=dword00000001
“BitLength”=dword:00000013
PAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBP
0111111111111111111111111111111111111
P Parity Bit
A Facility Code (FAC)
B Card Number (CN)
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat]
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\A]
“StartBit”=dword00000015
“BitLength”=dword:0000000C
[HKLM\SYSTEM\CurrentControlSet\Control\CardMan\CustomProxFormat\B]
“StartBit”=dword00000001
“BitLength”=dword:00000014
PPAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBP
01111111111111000000000000000000101
P Parity Bit
A Facility Code (FAC)
B Card Number (CN)
First the ProxFormat value in the [ProximityOptions] section has to be changed to 255 (custom mode):
[ProximityOptions]
; ProxFormat = 254 (= automatic mode)
ProxFormat = 255
Then, add the entries for the format options. For Windows based operating systems, create registry keys as
mentioned in the sections above. For Linux you need to create additional format sections for the used card
(H10301 in this example):
[CustomProxFormat-A]
StartBit = 11
BitLength = 8
[CustomProxFormat-B]
StartBit = 1
BitLength = 10
For any other card reference the different examples above. The settings are the same for Windows; the only
difference is that the settings have to be done in the cmrfid.ini file.
A1 Sample Project
The following C++ sample project is part of the synchronous API which can be downloaded from our website at
www.hidglobal.com/omnikey.
If you choose the default installation settings, sample code is found in:
c:\omnikey\samples\contactlessdemovc.
Sample code for Visual Basic is also available and found in: c:\omnikey\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.
Note: Integrate MIFARE cards through non-proprietary, PC/SC 2.0 compliant function calls.
A1.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.
A2 Code Examples
This section lists coding examples for a PC/SC 2.01 compliant implementation.
A2.1 Getting the Card UID (PC/SC 2.01)
The following function retrieves the Unique card ID (UID) currently connected to the card through the air
interface. Use the UID as the card serial number. The UID is available for every ISO 14443 A/B or ISO 15693
compliant cards. It does not matter whether the card is a CPU or storage card. This makes GetUID the ideal
candidate for Hello Card type applications. If you do not have access to application keys, the UID serves as a
valuable identifier allowing card lookup on a backend database.
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);
// 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;
7. Read/write any block (block number 0x13 to 0x1F for 2KS and 0xFF for 16KS).
8. For secured mode: End Session.
9. Disconnect card.
10. Remove card.
Appendix E - References