APDU reader and writer

Application protocol data units (APDUs) are special communication units that are defined in ISO/IEC 7816-4. The subset of these commands that is used to interact with a Type 4 Tag is implemented in this library.

Command APDUs (C-APDUs) are the commands sent from the polling device, while response APDUs (R-APDUs) are the responses to a specific command received by the polling device from the tag.

The APDU reader/writer module provides functions to encode a C-APDU according to its descriptor and to decode a raw R-APDU data into the appropriate descriptor.

This library can be used with the NFC Reader ST25R3911B library to exchange NFC Type 4 Tag data.

APDU types

There are three types of APDU that are relevant for a Type 4 Tag platform:

APDU type

Usage

Select

Selecting applications or files.

ReadBinary

Reading data from a file.

UpdateBinary

Writing data to a file.

C-APDU and R-APDU format

A C-APDU consists of the following fields:

Field

Length

Required

Description

CLA

1 byte

yes

Specifies the security level of the message.

INS

1 byte

yes

Specifies the command type to process.

P1

1 byte

yes

Specifies the first parameter for the chosen command type.

P2

1 byte

yes

Specifies the second parameter for the chosen command type.

Lc

1 or 3 byte

no

Specifies the data length.

Data

Lc bytes

no

Required if LC field is present. Contains payload of C-APDU.

Le

1 or 2 bytes

no

Specifies the expected response body length of R-APDU.

An R-APDU consists of the following fields:

Field

Length

Required

Description

Response body

variable

no

Carries the data of the R-APDU.

SW1

1 byte

yes

Specifies the first status word.

SW2

1 byte

yes

Specifies the second status word.

API documentation

Header file: include/nfc/t4t/apdu.h
Source file: subsys/nfc/t4t/apdu.c
APDU reader and writer

Parameters for selecting instruction code in C-APDU

Parameters for selecting

Status codes contained in R-APDU

Status codes contained in R-APDU