An 12705
An 12705
Document information
Information Content
Keywords MIFARE SAM AV3, TDEA, AES, RSA, MIFARE Plus, MIFARE DESFire EV1,
X interface.
Abstract This application note describes usages of MIFARE SAM AV3 in X interface.
NXP Semiconductors
AN12705
MIFARE SAM AV3 - X interface
Revision history
Rev Date Description
1.1 20200110 AN number changed, security status changed into “Company Public”.
1.0 20190115 Initial version
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
1 Introduction
MIFARE SAMs (Secure Application Module) have been designed to provide the secure
storage of cryptographic keys and cryptographic functions for the terminals to access the
MIFARE products securely and to enable secure communication between terminals and
host (backend).
1.1 Scope
This application note presents examples of using MIFARE SAM AV3 (referred to SAM in
1
this document, if not otherwise mentioned) in X-interface . In this document, the SAM is
in AV3 mode. There is a set of application note for MIFARE SAM AV3; each of them is
addressing specific features. The list of application note is given in [4].
This application note is a supplement document for application development using
MIFARE SAM AV3. Should there be any confusion please check MIFARE SAM
AV3 datasheet [1]. Best use of this application note will be achieved by reading this
specification [1] in advance.
Note: This application note does not replace any of the relevant data sheets,
datasheets, application notes or design guides.
1.2 Abbreviation
Refer to Application note “MIFARE SAM AV3 – Quick Start up Guide” [4].
Table 1. C-APDU:
CLA INS P1 P2 Lc Data (nc) Le
Table 2. R-APDU:
Response data SW1 SW2
Please note, that the numerical data are used solely as examples. They appear in
the text in order to clarify the commands and command data.
Any data, values, cryptograms are expressed as hex string format if not otherwise
mentioned e.g. 0x563412 in hex string format represented as “123456”. Byte [0] = 0x12,
Byte [1] = 0x34, Byte [2] = 0x56.
1.4 X interface
The host is managing the communication to SAM only, and SAM is managing all the
required communication to PICCs.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
2 X interface
MIFARE SAM AV3 has the FW for ISO/IEC 14443, MIFARE Classic, MIFARE DESFire
(EV1, EV2 and light) and MIFARE Plus X, S, SE and EV1. The μC sends the command
to SAM for specific task related to RF (PICC) and SAM performs that task fully
independent of μC.
2
Figure 3. Detail I C interface
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3 X interface functions
The functions supported in X interface are also known as X functionalities. All the X-
functionalities commands are listed in the following table. Some of them are shown
with examples in this application note. For detail descriptions, refer to [2].
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
C
Command L INS P1 P2 Lc Data Le Purpose
A
xx. Copies value block(s) to other
MF_Restore 8X C2 00 00 xx -
.xx value block(s)
xx. Authenticates and reads MIFARE
MF_AuthenticateRead 8X 3A 00 00 xx 00
.xx block(s).
xx. Authenticates and writes to
MF_AuthenticateWrite 8X AA 00 00 xx -
.xx MIFARE block(s).
xx. Changes (updates) MIFARE keys
MF_ChangeKey 8X A1 xx 00 xx -
.xx in the sector trailer.
MIFARE Ultralight commands
Performs the Password
UL_PwdAuthPICC 8X 2D 00 00 xx xx xx - Authentication on the MIFARE
Ultralight EV1 PICC
ISO14443-4 Type commands
ISO14443-4_RATS_ xx. Performs the RATS and PPS
8X E0 00 00 03 00
PPS .xx command
Initializes PICC and reader
xx. for protocol data exchange,
ISO14443-4_Init 8X 11 00 00 05 -
.xx alternative command of
ISO14443-4_RATS_PPS.
xx. -/ Transceives APDU to and from
ISO14443-4_Exchange 8X EC xx 00 xx
.xx 00 the PICC.
ISO14443-4_
8X 4C 00 00 - - - Tracks the PICC.
PresenceCheck
Deselects the PICC and PICC
ISO14443-4_Deselcect 8X D4 xx 00 - - -
goes to halt state.
xx.
ISO14443-4_FreeCID 8X FC 00 00 xx - Frees the CID used by the PCD.
.xx
MIFARE DESFire related commands
DESFire_ xx. Performs complete 3-pass mutual
8X DA xx xx xx 00
AuthenticatePICC .xx authentication for DESFire.
DESFire_ xx.
8X DE xx xx xx 00 Changes the keys in DESFire
ChangeKeyPICC .xx
xx. Can be used for DESFire memory
DESFire_WriteX 8X D3 xx xx xx 00
.xx updated commands.
xx. Can be used for DESFire memory
DESFire_ReadX 8X D2 00 xx xx 00
.xx reading commands.
DESFire_ Creates a Transaction MAC File in
8X D1 xx xx xx xx xx 00
CreateTMFilePICC the PICC
MIFARE Plus related command
The data is transferred in plain, so
xx.
MFP_WritePerso 8X A8 00 00 xx 00 perform the write_perso command
.xx
in a secure site.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
C
Command L INS P1 P2 Lc Data Le Purpose
A
The same command is used in
xx. all security level (SL) of MIFARE
MFP_Authenticate 8X 70 0x 00 xx 00
.xx Plus, P1 is used to distinguish the
SL.
Performs the Post-Delivery
PCD_Authenticate 8X 73 0x 00 xx xx xx 00
configuration on the MIFARE Plus
The data field contains MIFARE
xx.
MFP_CombinedRead 8X 31 00 00 04 00 Plus cmd+2-byte block nr + nr. of
.xx
blocs to read
xx. The data filed contains the plain
MFP_CombinedWrite 8X 32 00 00 xx 00
.xx command.
xx. Only one key can be changed at a
MFP_ChangeKey 8X A5 0x 00 xx 00
.xx time.
MFP_ Switches the security level of
8X 72 xx 00 xx xx xx 00
AuthSectorSwitch MIFARE Plus sectors
MIFARE Ultralight C Authentication command
ULC_ xx. Only CMAC based key
8X 2C 0x 00 xx 00
AuthenticatePICC .xx diversification is allowed.
MIFARE common
TMRI_ Commits the ReaderID to the
8X 37 00 00 xx xx xx 00
CommitReaderID PICC
Programmable Logic
Triggers the execution of the
SAM_PLExec 8X BE xx 00 xx xx xx 00
programmable logic
Updates the code in the
SAM_PLUpload 8X BF xx xx xx xx xx 00
programmable logic
Virtual Card Architecture
xx.
VCA_ProximityCheck 8X FB 0x 00 xx 00 Performs the proximity check.
.xx
xx.
VCA_Select 8X 45 0x 00 xx 00 Used for VC selection
.xx
3.1.1 RC_LoadRegisterValueSet
RC_LoadRegisterValueSet loads one full set of values (deleting complete set and
loading the new value set) in a single command. In the SAM, 8 sets of register values
can be stored. The default register values stored at register set 0 is given in the Table 4.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
It is required to modify some of the register values to initialize the reader IC (RC52x) for
ISO/IEC 14443 type A. The modified values are given also in Table 4.
The above register setting is stored in the register set 0x00 in the following example.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
The RC_Init command with the value P1 = 0x00 will initialize the RC52X/PN51X with the
register settings stored in register set 0x00 in this example.
3.1.2 RC_Init
The RF controller IC (RC52X/PN51X) is initialized with the addressed set of values
stored in the SAM memory. By default, the register value sets 0 contains ISO/IEC 14443
A type register settings of the RC52X and PN51X (RF is turned off).
3.1.3 RC_RFControl
This command can be interpreted as the resetting of RF. The time (in ms) given in the
data field is the time the RF remains turned off before turning on again. The time “0000”
given in the data field turned off the RF.
In the following figure the RF field is shown while executing the above command.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
The time provided in the data field and the real RF turned off time can be in tolerance up to 10%
3.2.1 ISO14443-3_ActivateIdle
This is a compound command, performs all ISO/IEC 14443 type A card activation
sequences (ReqA – Anticollision - select). In the following example a DESFire card is
activated.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
* All the activated card will go to halt state. To continue with a card, those cards need to
wake up using ActivateWakeUp command. If P1= 01, then the card is in activated state.
3.2.2 ISO14443-3_TransparentExchange
Using this command every bits and bytes can be sent to the card. One example of using
this command is to activate ISO/IEC 14443 B type card. In the following example the
REQB command is shown.
Of course, before executing this command the RC523 registers have to be set to the
correct values using RC_Init command. The register setting can be requested from
Customer Application Support.
3.3.1 MF_Authenticate
Table 11. MF_Authenticate Example
Step Indication Data/Message Comments
In case of 7-byte UID, take
1 MIFARE UID = 443898DE
last four byte.
The MIFARE Key entry is
2 SAM Key Entry No = 02
personalized in advance
Key version of the SAM
3 = 01
Key Entry
4 MIFARE Key Type A = 0A
5 MIFARE Block Nr = 28
6 Div constant = 0A Here the sector number.
800C000009443898DE020
7 C-APDU >
10A280A
8 R-APDU < 9000
3.3.2 MF_Read
MF_Read command can read multiple numbers of blocks. In RF level the SAM is
performing the read command for every block and providing the total data to the user in
one step.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
In the above example, block number 04, 05 and 06 (sector 1) have been read. If any
block has different access condition, the SAM will not return data from the read block(s)
but only the NACK (90FX).
3.3.3 MF_Write
MF_Write command can read multiple numbers of blocks. In RF level the SAM is
performing the read command for every block and providing the total data to the user in
one step.
In the above example, block number 04, 05 and 06 (sector 1) have been written. If the
blocks access condition is different, the SAM will return NACK (90FX) but may be some
blocks already updated. As example, in this example if block 6 has different write access
condition than the current authentication state, SAM will return 90FX but already block
number 4 and 5 are updated.
3.3.4 MF_ValueWrite
MF_ValueWrite can personalize one or several blocks to value block. In the following
example block number 5 and block number 6 are personalized for 100 units.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Please note, the address provided here is fully written in the value block (last 4 bytes of
the 16-byte value block). If the blocks access condition is different, the SAM will return
NACK (90FX) but some blocks may have already been updated.
3.3.5 MF_Increment
MF_Increment can increment the value block(s). In the following example the value of
block 5 is incremented by 10 units and transferred to block number 6.
3.3.6 MF_Decrement
MF_Decrement can decrement the value block(s). In the following example the value of
block 5 is decremented by 10 units and transferred to block number 6.
3.3.7 MF_AuthenticateRead
This is a compound command consolidating Authentication and read, which can be very
useful for optimizing performance transaction time of MIFARE Classic applications. In the
following example, the sector number 10 is authenticated and blocks 40, 41 and 43 (3
user blocks of sector 10) will be read.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Please note, if the block read accesses are different or required keys are different, then
the information has to be provided in the data field. Please refer to [2]. If any block has
different access condition, the SAM will not return data from the read block(s) but only
the NACK (90FX).
3.3.8 MF_AuthenticateWrite
This is a compound command consolidating Authentication and write, which can be very
useful for optimizing performance transaction time of MIFARE Classic applications. In the
following example, the sector number 1 is authenticated and blocks 4, 5 and 6 (3 user
blocks of sector 1) will be written.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Please note, if the block write accesses are different or required keys are different, then
the information has to be provided in the data field. Please refer to [2]. If the blocks
access condition is different, the SAM will return NACK (90FX) but may be some blocks
already updated.
3.3.9 MF_ChangeKey
This command can be used to personalize or roll the MIFARE keys in MIFARE Classic
cards. MF_ChangeKey command at first generates the MIFARE diversified key and then
writes it to the corresponding sector trailer.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3.4 Preparing the proximity chips for T=CL half duplex transmission
MIFARE SAM AV3 supports the “Exchange Transparent Data” state with up to 4 cards
(according to ISO/IEC 14443-4, the number of cards in this state can be up to 15, CID 0
to CID 14). One logical channel can be assigned to one specific CID. In the following a
flow diagram is shown:
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3.4.1 ISO14443-4_RATS_PPS
Table 20. RATS_PPS Example
Step Indication Data/Message Comments
1 CID = 01
2 DRI = 02 424 kbps (PCD to PICC)
3 DSI = 02 424 kbps (PICC to PCD)
4 C-APDU > 80E000000301020200
5 R-APDU < 0102020675778102809000
Activating another card
6 CID = 02
7 DRI = 01 212 kbps (PCD to PICC)
8 DSI = 01 212 kbps (PICC to PCD)
9 C-APDU > 81E000000302010100
10 R-APDU < 0202020675778102809000
Accessing the card with CID 01, ‘GetApplicationID’ command
Logical channel 0 is
11 C-APDU > 80EC0000016A00 communicating with card
with CID = 0.
12 R-APDU < 004444449000
Accessing the card with CID 02, ‘GetApplicationID’ command
Logical channel 1 is
13 C-APDU > 81EC0000016A00 communicating with card
with CID = 1.
14 R-APDU < 002F8CF11111119000
MIFARE SAM AV3 supports using different RF communication speeds with different
cards at the same time.
3.4.2 ISO14443-4_PresenceCheck
For tracking a card, (if still the activated card is present) this command can be issued,
facilitates the windows resource manager according to PC/SC. This command will not
change any state of the card.
In this example the presence of the card attached to logical channel 0 is checked.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Important clarification: The complete APDU is made up of two APDUs. DESFire’s APDU
is transported/wrapped within the standard ISO14443 part IV APDU, as shown in the
following figure.
Please note, for ISO/IEC 7816-4 INS will have same structure like the above one.
These structures can be used for any DESFire commands. More over, some of the
DESFire commands are supported by MIFARE SAM AV3 directly and these commands
are named “DESFire related commands” in [1]. In the following some of them are
discussed.
3.5.3 DESFire_AuthenticatePICC
This command is very straightforward. The SAM key entry has to be personalized prior
to issue DESFire_AuthenticatePICC command. Please make sure, the key entry is in
accordance.
3.5.4 DESFire_ChangeKeyPICC
This command changes the keys of the MIFARE DESFire EV1 and can be used in
personalization or rolling of the keys. It supports the diversification mechanism as
described in [1]. Please note the same diversification inputs have to be used for both new
and current key, if they both are diversified.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3.5.5 DESFire_WriteX
“DESFire_WriteX” command is optimized for several memory update-type functions e.g.
ChangeKeySettings, WriteData, Credit, Debit, LimitedCredit, WriteRecord for DESFire.
Please note, the complete DESFire APDU (DESFire native, ISO 7816 wrapping or
ISO7816-4 INS) is provided in the data field. Please check the following example.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
**Please note, “DESFire_WriteX” command cannot be used for plain communication. For
plain communication, use the “ISO14443-4_Exchange” command.
DESFire_WriteX command does not support DESFire application chaining. To write
longer length of data (does not fit in one write frame, please check [5]), user has to
implement the chaining.
3.5.6 DESFire_ReadX
DESFire_ReadX command is optimized for accessing memory (ReadData, GetValue
and ReadRecord) in fully encrypted or MACed (CAMCed) communication. The complete
DESFire application protocol data unit (Native, ISO7816 wrapping or ISO7816-4 INS) is
given in the data field. In the following one example with reading the data file is shown.
**Please note, “DESFire_ReadX” command cannot be used for plain communication. For
plain communication, use the “ISO14443-4_Exchange” command.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Table 29. Example of DESFire_ReadX Command for reading a data file with chaining
Step Command Data/Message
“Read Data” command
1 = BD
for DESFire
2 File no, to read = 01
Offset at which the read
3 = 000000
starts
Length of data to be
4 = 960000 (150 bytes)
read
DESFire Native APDU, BD01000000960000 (will be the data field of DESFire_
5 =
the application data. ReadX C-APDU)
6 Now mapped to DESFire_ReadX APDU
7 P1 = 00
8 P2 = 30, (encrypted communication)
9 Lc = 08; (8 bytes from step 6)
80D200300B960000BD0100000096000000 (The length
10 C-APDU > of data “960000” to be read has to be added in front of the
DESFire APDU as well )
000102030405060708090A0B0C0D0E0F101112131415
161718191A1B1C1D1E1F202122232425262728292A2B
11 R-APDU <
2C2D2E2F90AF (90AF means more data from the
DESFire)
C-APDU (for more data,
12 > 80D2003001AF00
chaining)
303132333435363738393A3B3C3D3E3F4041424344454
13 R-APDU < 64748494A4B4C4D4E4F505152535455565758595A5B5C
5D5E5F606162636465666790AF
C-APDU (for more data,
14 > 80D2003001AF00
chaining)
68696A6B6C6D6E6F707172737475767778797A7B7C7D
15 R-APDU < 7E7F808182838485868788898A8B8C8D8E8F909192939
4959000
000102030405060708090A0B0C0D0E0F1011121314151
61718191A1B1C1D1E1F202122232425262728292A2B2C
2D2E2F303132333435363738393A3B3C3D3E3F4041424
The complete 150 bytes
16 = 34445464748494A4B4C4D4E4F50515253545556575859
data
5A5B5C5D5E5F606162636465666768696A6B6C6D6E6F
707172737475767778797A7B7C7D7E7F8081828384858
68788898A8B8C8D8E8F909192939495
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3.6.1 MFP_WritePerso
MFP_WritePerso command requires the exact data/key to be written to MIFARE Plus
card. The MIFARE Plus AES keys can be dumped from the SAM with “must diversified”
option, if it is required.
3.6.2 MFP_Authenticate
The same command is used for all type of AES authentication in all security level. Set bit
number 2 and 3 accordingly for selection of different authentication. In the following, one
example is given for authentication in security level 3.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
3.6.3 MFP_CombinedRead
This ‘combined read’ command can read MIFARE Plus block(s). If the access condition
allows, the full card can be read in one command.
Figure 9. Secure messaging adds security in the communication between SAM and Host
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Table 33. Example full protection Host communication for MIFARE DESFire EV1
Step Indication Data/Message Comment
1 Initialize the reader IC and turn on the RF.
Authenticate Host, using SAM_AuthenticateHost command take host mode = full
protection. See §2 of [8] for detail calculation. In this example session key were as
2 follows:
Encryption session key = 3056A1804B24B44386F5E1032AA206A9 and
CMAC session key = D03206A036FB41257A8093DB52A2DBC5
The command APDU
in plain. It requires now
3 ISO14443-3_ActivateIdle = 8026010000
calculation of secure
messaging.
Data field contains CMAC.
ISO14443-3_ActivateIdle 802601000804FD77D0FAF
4 > See §2 of [8] for detail
C-APDU in full protection F11E500
calculation
4FE359F6A562BC2E51BA9
ISO14443-3_ActivateIdle The response is encrypted
5 < 5ED48C9E9F4432959D77D
R-APDU in full protection with a CAMC.
63B69A9000
Plain response after
See §2 of [8] for detail
6 CMAC verification and = 44032007049137C9922680
calculation
decryption
The command APDU
ISO14443-4_RATS_ in plain. It requires now
7 = 80E000000301000000
PPS calculation of secure
messaging.
Data field contains
ISO14443-4_RATS_ 80E00000181917CFB3C9E encrypted data and CMAC.
8 PPS C-APDU in full > 585DFA822E3FEC4964062
See §2 of [8] for detail
protection 47C842647935E3EF00
calculation.
ISO14443-4_RATS_ 983A7DF82021274B40FC3 Response data field
9 PPS R-APDU in full < 919E00F7269C330BD2316 contains encrypted data and
protection DAD8299000 CAMC
Plain response of
the card after CMAC See §2 of [8] for detail
10 = 010000067577810280
verification and calculation.
decryption
The command APDU
ISO14443-4_Exchange
in plain. It requires now
11 command for application = 80EC0000045A12345600
calculation of secure
selection
messaging.
ISO14443-4_Exchange Data field contains
80EC00000002000018B73 encrypted data and CMAC.
C-APDU for application
11 > D246612CF9FB04C61089D
selection in full See §2 of [8] for detail
BD45DF3A00
protection mode calculation.
80EC000018B73D246612C Response data field
ISO14443-4_Exchange
12 < F9FB04C61089DBD45DF3 contains encrypted data and
R-APDU in full protection
A06FD8224F07FFF3800 CAMC
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
4 References
1. Data sheet – MIFARE SAM AV3, document number DS3235xx.
2. System guidance manual – MF4SAM30 (MIFARE SAM AV3), document number xx.
3. Data sheet – MIFARE Plus, document number 1637xx.
4. Application note – AN12695 - MIFARE SAM AV3 –Quick Start up Guide,
document number 5210xx, https://www.nxp.com/docs/en/application-note/
AN12695.pdf
5. Application note – AN5212 - MIFARE SAM AV3- Key Management and
Personalization, document number 5212xx.
6. Application note – Symmetric Key Diversifications, document number 1653xx.
7. Application note – AN5217 – MIFARE SAM AV3 for MIFARE Classic, document
number AN5217xx.
8. Application note – AN12704 – MIFARE SAM AV3 Host communication, document
number 5213xx, https://www.nxp.com/docs/en/application-note/AN12704.pdf
9. Data sheet – MFRC523, Contactless Reader IC.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
5 Legal information
responsible for doing all necessary testing for the customer’s applications
and products using NXP Semiconductors products in order to avoid a
5.1 Definitions default of the applications and the products or of the application or use by
customer’s third party customer(s). NXP does not accept any liability in this
Draft — The document is a draft version only. The content is still under respect.
internal review and subject to formal approval, which may result in
modifications or additions. NXP Semiconductors does not give any Export control — This document as well as the item(s) described herein
representations or warranties as to the accuracy or completeness of may be subject to export control regulations. Export might require a prior
information included herein and shall have no liability for the consequences authorization from competent authorities.
of use of such information.
Evaluation products — This product is provided on an “as is” and “with all
faults” basis for evaluation purposes only. NXP Semiconductors, its affiliates
and their suppliers expressly disclaim all warranties, whether express,
5.2 Disclaimers implied or statutory, including but not limited to the implied warranties of
non-infringement, merchantability and fitness for a particular purpose. The
entire risk as to the quality, or arising out of the use or performance, of this
Limited warranty and liability — Information in this document is believed
product remains with customer. In no event shall NXP Semiconductors, its
to be accurate and reliable. However, NXP Semiconductors does not
affiliates or their suppliers be liable to customer for any special, indirect,
give any representations or warranties, expressed or implied, as to the
consequential, punitive or incidental damages (including without limitation
accuracy or completeness of such information and shall have no liability
damages for loss of business, business interruption, loss of use, loss of
for the consequences of use of such information. NXP Semiconductors
data or information, and the like) arising out the use of or inability to use
takes no responsibility for the content in this document if provided by an
the product, whether or not based on tort (including negligence), strict
information source outside of NXP Semiconductors. In no event shall NXP
liability, breach of contract, breach of warranty or any other theory, even if
Semiconductors be liable for any indirect, incidental, punitive, special or
advised of the possibility of such damages. Notwithstanding any damages
consequential damages (including - without limitation - lost profits, lost
that customer might incur for any reason whatsoever (including without
savings, business interruption, costs related to the removal or replacement
limitation, all damages referenced above and all direct or general damages),
of any products or rework charges) whether or not such damages are based
the entire liability of NXP Semiconductors, its affiliates and their suppliers
on tort (including negligence), warranty, breach of contract or any other
and customer’s exclusive remedy for all of the foregoing shall be limited to
legal theory. Notwithstanding any damages that customer might incur for
actual damages incurred by customer based on reasonable reliance up to
any reason whatsoever, NXP Semiconductors’ aggregate and cumulative
the greater of the amount actually paid by customer for the product or five
liability towards customer for the products described herein shall be limited
dollars (US$5.00). The foregoing limitations, exclusions and disclaimers
in accordance with the Terms and conditions of commercial sale of NXP
shall apply to the maximum extent permitted by applicable law, even if any
Semiconductors.
remedy fails of its essential purpose.
Right to make changes — NXP Semiconductors reserves the right to
Translations — A non-English (translated) version of a document is for
make changes to information published in this document, including without
reference only. The English version shall prevail in case of any discrepancy
limitation specifications and product descriptions, at any time and without
between the translated and English versions.
notice. This document supersedes and replaces all information supplied prior
to the publication hereof.
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Tables
Tab. 1. C-APDU: ............................................................3 Tab. 21. ISO14443-4_PresenceCheck Example ........... 20
Tab. 2. R-APDU: ............................................................3 Tab. 22. Example of Select Application command ........ 21
Tab. 3. All X functionalities commands ......................... 7 Tab. 23. Example of MIFARE DESFire Read native
Tab. 4. Default “Register Set 0” storage ......................10 APDU ...............................................................21
Tab. 5. Register Set for ISO/IEC 14443 Type A .......... 10 Tab. 24. Example of Wrapping of DESFire Native
Tab. 6. Example of RC_LoadRegisterValueSet .......... 11 APDU ...............................................................22
Tab. 7. Example of RC_Init ......................................... 11 Tab. 25. Example of MIFARE DESFire EV1
Tab. 8. Example of RC_RFControl ..............................11 Authentication ..................................................23
Tab. 9. Example of ISO14443-3_ActivateIdle ..............12 Tab. 26. Example of DESFire_ChangeKeyPICC ...........23
Tab. 10. Example of ISO14443-3_ Tab. 27. Example of DESFire_WriteX Command for
TransparentExchange ..................................... 13 writing to a data file .........................................24
Tab. 11. MF_Authenticate Example .............................. 13 Tab. 28. Example of DESFire_ReadX Command for
Tab. 12. MF_Read Example ..........................................14 reading a data file ........................................... 25
Tab. 13. MF_Write Example ..........................................14 Tab. 29. Example of DESFire_ReadX Command for
Tab. 14. MF_ValueWrite Example .................................14 reading a data file with chaining ......................26
Tab. 15. MF_Increment Example .................................. 15 Tab. 30. Example of MFP_WritePerso .......................... 27
Tab. 16. MF_Decrement Example .................................15 Tab. 31. Example of MFP_Authenticate ........................27
Tab. 17. MF_AuthenticateRead Example ......................16 Tab. 32. Example of MFP_CombinedRead ................... 28
Tab. 18. MF_AuthenticateWrite Example ...................... 16 Tab. 33. Example full protection Host communication
Tab. 19. MF_ChangeKey Example ............................... 17 for MIFARE DESFire EV1 ............................... 29
Tab. 20. RATS_PPS Example .......................................20
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Figures
Fig. 1. Architecture in X interface .................................4 Fig. 7. ISO14443-4_Exchange Command APDU
Fig. 2. Reader with MIFARE SAM AV3 ........................5 for DESFire ..................................................... 21
Fig. 3. Detail I2C interface ........................................... 5 Fig. 8. Wrapping of DESFire Native APDU in
Fig. 4. X interface command-sequence for MIFARE ISO14443-4_Exchange APDU ........................ 23
product family ....................................................6 Fig. 9. Secure messaging adds security in the
Fig. 5. RF behavior with RC_RFControl command .... 12 communication between SAM and Host ..........28
Fig. 6. Specific logical channel is assigned in ISO/
IEC14443-4 ..................................................... 19
AN12705 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Contents
1 Introduction ......................................................... 3
1.1 Scope .................................................................3
1.2 Abbreviation ....................................................... 3
1.3 Examples presented in this document ...............3
1.4 X interface ......................................................... 4
2 X interface ............................................................5
2.1 MIFARE SAM AV3, X interface ......................... 5
2.2 Initializing the X interface .................................. 6
3 X interface functions .......................................... 7
3.1 RF Controller IC Control commands ..................9
3.1.1 RC_LoadRegisterValueSet ................................ 9
3.1.2 RC_Init ............................................................. 11
3.1.3 RC_RFControl ................................................. 11
3.2 ISO14443-3 type A card activation
commands ....................................................... 12
3.2.1 ISO14443-3_ActivateIdle ................................. 12
3.2.2 ISO14443-3_TransparentExchange ................ 13
3.3 MIFARE Commands ........................................13
3.3.1 MF_Authenticate ..............................................13
3.3.2 MF_Read ......................................................... 13
3.3.3 MF_Write ......................................................... 14
3.3.4 MF_ValueWrite ................................................ 14
3.3.5 MF_Increment ..................................................15
3.3.6 MF_Decrement ................................................ 15
3.3.7 MF_AuthenticateRead ..................................... 15
3.3.8 MF_AuthenticateWrite ..................................... 16
3.3.9 MF_ChangeKey ............................................... 17
3.4 Preparing the proximity chips for T=CL half
duplex transmission ......................................... 18
3.4.1 ISO14443-4_RATS_PPS ................................. 20
3.4.2 ISO14443-4_PresenceCheck .......................... 20
3.5 Accessing MIFARE DESFire ........................... 21
3.5.1 Selecting MIFARE DESFire Application .......... 21
3.5.2 MIFARE DESFire Read command .................. 21
3.5.3 DESFire_AuthenticatePICC ............................. 23
3.5.4 DESFire_ChangeKeyPICC .............................. 23
3.5.5 DESFire_WriteX ...............................................24
3.5.6 DESFire_ReadX .............................................. 25
3.6 Accessing MIFARE Plus ..................................27
3.6.1 MFP_WritePerso ..............................................27
3.6.2 MFP_Authenticate ........................................... 27
3.6.3 MFP_CombinedRead ...................................... 28
3.7 Use of Secure Messaging ............................... 28
3.7.1 Secure Messaging example for MIFARE
DESFire EV1 ................................................... 29
4 References ......................................................... 31
5 Legal information .............................................. 32
Please be aware that important notices concerning this document and the product(s)
described herein, have been included in section 'Legal information'.