openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
nfc_select.c File Reference

NFC SELECT command builder and response parser for Aliro. More...

#include "nfc_select.h"
#include "tlv.h"
#include <stdbool.h>
#include <string.h>
Include dependency graph for nfc_select.c:

Functions

static const uint8_t * aid_for_phase (enum woz_aliro_select_phase phase)
 Map a SELECT phase (EXPEDITED or STEP_UP) to its corresponding Aliro AID byte sequence; return NULL if phase is unknown.
 
static int parse_proprietary_information (const uint8_t *data, size_t length, enum woz_aliro_select_phase phase, struct woz_aliro_select_response *result)
 Parse proprietary information TLV data from a SELECT response: validate type tag 0x80, extract protocol version from expedited phase 0x5c, and decode extended-length sizes from 0x7f66 if present; return WOZ_ALIRO_SELECT_OK on valid parse or error code if format or content is malformed.
 
int woz_aliro_parse_select_response_ex (const uint8_t *response, size_t response_length, enum woz_aliro_select_phase phase, struct woz_aliro_select_response *result)
 Parse a complete ISO 7816 SELECT response APDU (ending with 9000), validate the AID matches the requested phase (EXPEDITED or STEP_UP), extract proprietary information TLV, and decode protocol version and extended-length sizes.
 

Detailed Description

NFC SELECT command builder and response parser for Aliro.

build_select_command emits 00 A4 04 00 09 AID 00. parse_proprietary_information decodes type-0x80 data from a SELECT response, extracting protocol version (expedited phase only) and extended-length sizes (0x7f66 TLV). parse_select_response and parse_select_response_ex validate the trailing 9000, check AID, and call parse_proprietary_information.

Function Documentation

◆ woz_aliro_parse_select_response_ex()

int woz_aliro_parse_select_response_ex ( const uint8_t *  response,
size_t  response_length,
enum woz_aliro_select_phase  phase,
struct woz_aliro_select_response result 
)

Parse a complete ISO 7816 SELECT response APDU (ending with 9000), validate the AID matches the requested phase (EXPEDITED or STEP_UP), extract proprietary information TLV, and decode protocol version and extended-length sizes.

Return WOZ_ALIRO_SELECT_OK on success or an error code (WRONG_APPLICATION, STATUS_ERROR, INVALID_APDU, INVALID_ARGUMENT).