openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
nfc_select.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <stddef.h>
10#include <stdint.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16enum {
17 WOZ_ALIRO_AID_SIZE = 9,
18 WOZ_ALIRO_SELECT_COMMAND_SIZE = 15,
19};
20
21enum woz_aliro_select_phase {
22 WOZ_ALIRO_SELECT_EXPEDITED = 1,
23 WOZ_ALIRO_SELECT_STEP_UP = 2,
24};
25
26enum woz_aliro_select_result {
27 WOZ_ALIRO_SELECT_OK = 0,
28 WOZ_ALIRO_SELECT_INVALID_ARGUMENT = -1,
29 WOZ_ALIRO_SELECT_INVALID_APDU = -2,
30 WOZ_ALIRO_SELECT_STATUS_ERROR = -3,
31 WOZ_ALIRO_SELECT_WRONG_APPLICATION = -4,
32 WOZ_ALIRO_SELECT_WRONG_TYPE = -5,
33 WOZ_ALIRO_SELECT_VERSION_NOT_SUPPORTED = -6,
34};
35
42 uint16_t selected_protocol_version;
43 /* Defaults required for a short-only peer when 7F66 is absent. */
44 size_t max_command_data_length;
45 size_t max_response_data_length;
46 int extended_length_supported;
47 /* Complete encoded A5 TLV. The view remains valid as long as the input
48 * response buffer remains valid. */
49 const uint8_t *proprietary_information_tlv;
50 size_t proprietary_information_tlv_length;
51};
52
53extern const uint8_t woz_aliro_expedited_aid[WOZ_ALIRO_AID_SIZE];
54extern const uint8_t woz_aliro_step_up_aid[WOZ_ALIRO_AID_SIZE];
55
56/* Build 00 A4 04 00 09 <AID> 00 (short case-4 SELECT by DF name). */
57int woz_aliro_build_select_command(enum woz_aliro_select_phase phase,
58 uint8_t out[WOZ_ALIRO_SELECT_COMMAND_SIZE]);
59
60/* Parse the complete response APDU, including the trailing SW1/SW2. */
61int woz_aliro_parse_select_response(const uint8_t *response, size_t response_length,
62 enum woz_aliro_select_phase phase,
63 uint16_t *selected_protocol_version);
64
65int woz_aliro_parse_select_response_ex(const uint8_t *response, size_t response_length,
66 enum woz_aliro_select_phase phase,
67 struct woz_aliro_select_response *result);
68
69/* Parse a complete encoded A5 Proprietary Information TLV. This is also the
70 * value carried by BLE Initiate Access Protocol, without an NFC FCI wrapper. */
71int woz_aliro_parse_proprietary_information(const uint8_t *encoded, size_t encoded_length,
72 enum woz_aliro_select_phase phase,
73 struct woz_aliro_select_response *result);
74
75#ifdef __cplusplus
76}
77#endif
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 reque...
Definition nfc_select.c:168
Parsed NFC SELECT response: negotiated protocol version, max command/response data lengths (from 7F66...
Definition nfc_select.h:41