openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
nfc_step_up.h
1/* Aliro 1.0 / ISO 18013-5 NFC step-up message and APDU codecs. */
2#pragma once
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <stdint.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12enum woz_aliro_step_up_result {
13 WOZ_ALIRO_STEP_UP_OK = 0,
14 WOZ_ALIRO_STEP_UP_MORE_RESPONSE = 1,
15 WOZ_ALIRO_STEP_UP_INVALID_ARGUMENT = -1,
16 WOZ_ALIRO_STEP_UP_BUFFER_TOO_SMALL = -2,
17 WOZ_ALIRO_STEP_UP_INVALID_DATA = -3,
18 WOZ_ALIRO_STEP_UP_STATUS_ERROR = -4,
19};
20
21/* Build the compact-key Aliro DeviceRequest. */
22int woz_aliro_build_device_request(const uint8_t *element_identifier,
23 size_t element_identifier_length, bool intent_to_store,
24 uint8_t *output, size_t output_capacity, size_t *output_length);
25
26/* Encode/decode ISO 18013-5 SessionData: { "data": bstr }. */
27int woz_aliro_wrap_session_data(const uint8_t *ciphertext, size_t ciphertext_length,
28 uint8_t *output, size_t output_capacity, size_t *output_length);
29int woz_aliro_unwrap_session_data(const uint8_t *session_data, size_t session_data_length,
30 const uint8_t **ciphertext, size_t *ciphertext_length);
31
32/* Encode/decode the NFC Device Engagement DO53 wrapper. */
33int woz_aliro_wrap_do53(const uint8_t *message, size_t message_length, uint8_t *output,
34 size_t output_capacity, size_t *output_length);
35int woz_aliro_unwrap_do53(const uint8_t *encoded, size_t encoded_length, const uint8_t **message,
36 size_t *message_length);
37
38/* Build one ENVELOPE command. offset is advanced by the emitted fragment. */
39int woz_aliro_build_envelope_command(const uint8_t *encoded_do53, size_t encoded_length,
40 size_t *offset, size_t max_command_data,
41 size_t max_response_data, bool extended_supported,
42 uint8_t *output, size_t output_capacity, size_t *output_length,
43 bool *last_fragment);
44
45int woz_aliro_build_get_response_command(size_t expected_length, uint8_t *output,
46 size_t output_capacity, size_t *output_length);
47
48/* Append response data and interpret 9000 / 61xx. sw2==0 means 256 bytes. */
49int woz_aliro_collect_response(const uint8_t *response, size_t response_length, uint8_t *collected,
50 size_t collected_capacity, size_t *collected_length,
51 size_t *next_length);
52
53#ifdef __cplusplus
54}
55#endif
int woz_aliro_build_get_response_command(size_t expected_length, uint8_t *output, size_t output_capacity, size_t *output_length)
Build an ISO 7816 GET RESPONSE command APDU for retrieving data from a previous response chain.
Definition nfc_step_up.c:324
int woz_aliro_unwrap_do53(const uint8_t *encoded, size_t encoded_length, const uint8_t **message, size_t *message_length)
Unwrap an Aliro DO'53 TLV-encoded message: extract the value of a tag-0x53 object from an encoded buf...
Definition nfc_step_up.c:248
int woz_aliro_unwrap_session_data(const uint8_t *session_data, size_t session_data_length, const uint8_t **ciphertext, size_t *ciphertext_length)
Unwrap an ISO 18013-5 SessionData envelope (CBOR map with "data" key) to extract the encrypted cipher...
Definition nfc_step_up.c:206