ENCAPSULATE instruction

Use this command to directly send a raw, non-ISO/IEC 7816 compliant frame to a card.

This is typically required to communicate with wired-logic cards or non-standard smart cards.

Command format

Field Value Remark
CLA FF
INS FE
P1 Sub command selection See table below
P2 Timeout and options See table below
Lc Length of the raw frame
DataIn Raw frame to send to the card
Le 00

Sub command selection (P1)

Standard communications modes

P1 Function
00 For ISO 14443-4 (A or B) PICCs : send the frame in the T=CL stream. DataIn shall not include PCB, CID, NAD nor CRC fields.
For ISO 18092 targets : send the frame DEP_REQ/DEP_RES stream. DataIn shall not include PFB, DID, NAD nor CRC fields
01 Send the frame “as is” using the ISO 14443-3 type A protocol at 106 kbit/s.
Parity bits and CRC are handled by the coupler.
02 Send the frame “as is” using the ISO 14443-3 type B protocol at 106 kbit/s.
SOF, EOF and CRC are handled by the coupler.
03 Send the frame “as is” using the ISO 14443-3 type A protocol at 212 kbit/s.
Parity bits and CRC are handled by the coupler.
04 Send the frame “as is” using the ISO 15693 protocol.
The UID of the VICC and a valid header shall be provided in DataIn.
The CRC is handled by the coupler.
05 Send the frame “as is” using the ISO 15693 protocol.
The UID of the VICC is added to the frame and the option byte in the header is adjusted for unselected communication mode.
The CRC is handled by the coupler.
07 Send the frame “as is” using the JIS:X6319-4 protocol at 212 kbit/s.
The CRC is handled by the coupler.

Special communications modes

P1 Function
09 Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits are handled by the coupler, but the CRC shall be added to DataIn, and checked in DataOut, by the application.
0A Send the frame “as is” using the ISO 14443-3 type B modulation at 106 kbit/s.
SOF and EOF are handled by the coupler, but the CRC shall be added to DataIn, and checked in DataOut, by the application.
0C Send the frame “as is” using the ISO 15693-2 modulation.
The CRC shall be added to DataIn, and checked in DataOut, by the application.

Mifare Classic low level communication

P1 Function
0F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte is complete (8 valid bits).
1F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 1 valid bit.
2F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 2 valid bits.
3F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 3 valid bits.
4F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 4 valid bits.
5F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 5 valid bits.
6F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 6 valid bits.
7F Send the frame “as is” using the ISO 14443-3 type A modulation at 106 kbit/s.
Parity bits and CRC shall be added to DataIn, and checked in DataOut, by the application. The last byte has only 7 valid bits.

When one of this value is used for P1, after SW1=90, SW2 denotes the number of valid bits in the last byte of DataOut.

Timeout and options (P2)

P2 is an array of bits with the following definition:

Bits Value
7 0 : if the communication with the card fails, return SW1=6F and SW2=internal error code
1 : if the communication with the card fails, return SW1=63 and SW2=00 whatever the reason
6-4 RFU, must be 000
3-0 Timeout:
0000 : use ISO/IEC 14443-4 FWT (valid for P1=00 only)
0001 : timeout = 106 ETU (approx 1ms @106kbit/s)
0010 : timeout = 212 ETU (approx 2ms @106kbit/s)
0011 : timeout = 424 ETU (approx 4ms @106kbit/s)
0100 : timeout = 848 ETU (approx 8ms @106kbit/s)
0101 : timeout = 1696 ETU (approx 16ms @106kbit/s)
0110 : timeout = 3392 ETU (approx 32ms @106kbit/s)
0111 : timeout = 6784 ETU (approx 65ms @106kbit/s)
1000 : timeout = 13568 ETU (approx 0.125s @106kbit/s)
1001 : timeout = 27136 ETU (approx 0.250s @106kbit/s)
1010 : timeout = 54272 ETU (approx 0.5ms @106kbit/s)
1011 : timeout = 108544 ETU (approx 1s @106kbit/s)
1100 : timeout = 217088 ETU (approx 2s @106kbit/s)
1101 : timeout = 434176 ETU (approx 4s @106kbit/s)
1110 : RFU
1111 : RFU

Response

Communication is not Mifare Classic

If P1 is not 0F, 1F, … 7F, possible SW are:

Field Value Remark
SW 9000 on success
6300 on error if bit 7 of P2 is 1
6Fxx on error if bit 7 of P2 is 0
Other values are documented in Status Words

Communication is Mifare Classic

If P1 is 0F, 1F, … 7F

Field Value Remark
SW 9000 on success and the last byte is complete (8 bits)
9001 on success and the last byte has 1 bit only
9002 on success and the last byte has 2 bits only
9003 on success and the last byte has 3 bits only
9004 on success and the last byte has 4 bits only
9005 on success and the last byte has 5 bits only
9006 on success and the last byte has 6 bits only
9007 on success and the last byte has 7 bits only
6300 on error if bit 7 of P2 is 1
6Fxx on error if bit 7 of P2 is 0
Other values are documented in Status Words