hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
APDU Library

This library offers utilities to encode and decode APDU objects as well as their responses.

In smart card applications a host typically sends binary APDU data to a secure element and reads back a response. This binary data may be somewhat difficult to create and understand depending on the length of the data, etc. This library can be used to work with APDUs in a more generic and structured way.

Example

// Encode APDU so that it can be send to secure element
ifx_apdu_t apdu = {
.cla = 0x01u,
.ins = 0x02u,
.p1 = 0x03u,
.p2 = 0x04u,
.lc = 0u,
.data = NULL,
.le = 0u
};
uint8_t *encoded;
size_t encoded_len;
ifx_apdu_encode(&apdu, &encoded, &encoded_len);
// Perform some interaction with a secure element (not of importance here)
uint8_t *response;
size_t response_len;
ifx_protocol_t protocol;
// Initialize the `ifx_protocol_t` object with the concrete implementation of driver.(Eg. I2C, SPI, etc ..)
// Code placeholder
ifx_protocol_activate(&protocol, NULL, NULL);
ifx_protocol_transceive(&protocol, encoded, encoded_len, &response, &response_len);
// Decode APDU response and check status
ifx_apdu_response_decode(&decoded, response, response_len);
if (decoded.sw != 0x9000u)
{
// Error indicator set
}
APDU (response) en-/decoding utility.
Generic protocol API (ISO/OSI stack).
Data storage struct for APDU response information.
Definition ifx-apdu.h:130
uint16_t sw
APDU response status word.
Definition ifx-apdu.h:144
Data storage for APDU fields.
Definition ifx-apdu.h:89
uint8_t cla
APDU instruction class.
Definition ifx-apdu.h:93