openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
nfc_auth.h
1/* Aliro 1.0 expedited authentication APDU codecs. */
2#pragma once
3
4#include <stddef.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define WOZ_ALIRO_PUBLIC_KEY_SIZE 65
12#define WOZ_ALIRO_SIGNATURE_SIZE 64
13#define WOZ_ALIRO_TRANSACTION_ID_SIZE 16
14#define WOZ_ALIRO_READER_ID_SIZE 32
15#define WOZ_ALIRO_AUTH0_STANDARD_COMMAND_SIZE 135
16#define WOZ_ALIRO_AUTH1_COMMAND_SIZE 75
17#define WOZ_ALIRO_AUTH_DATA_SIZE 126
18
19enum woz_aliro_auth_result {
20 WOZ_ALIRO_AUTH_OK = 0,
21 WOZ_ALIRO_AUTH_INVALID_ARGUMENT = -1,
22 WOZ_ALIRO_AUTH_BUFFER_TOO_SMALL = -2,
23 WOZ_ALIRO_AUTH_INVALID_APDU = -3,
24 WOZ_ALIRO_AUTH_STATUS_ERROR = -4,
25 WOZ_ALIRO_AUTH_WRONG_CONTENT = -5,
26};
27
33 uint8_t command_parameters;
34 uint8_t authentication_policy;
35 uint16_t protocol_version;
36 const uint8_t *reader_ephemeral_public_key;
37 const uint8_t *transaction_identifier;
38 const uint8_t *reader_identifier;
39 const uint8_t *vendor_extension;
40 size_t vendor_extension_length;
41};
42
48 uint8_t credential_ephemeral_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE];
49 const uint8_t *cryptogram;
50 size_t cryptogram_length;
51 const uint8_t *vendor_extension;
52 size_t vendor_extension_length;
53};
54
61 uint8_t credential_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE];
62 uint8_t signature[WOZ_ALIRO_SIGNATURE_SIZE];
63 uint16_t signaling_bitmap;
64 const uint8_t *credential_signed_timestamp;
65 const uint8_t *revocation_signed_timestamp;
66};
67
68int woz_aliro_build_auth0_command(const struct woz_aliro_auth0_command *params, uint8_t *output,
69 size_t output_capacity, size_t *output_length);
70
71int woz_aliro_parse_auth0_response(const uint8_t *response, size_t response_length,
72 int fast_requested, struct woz_aliro_auth0_response *result);
73
75 const uint8_t reader_identifier[WOZ_ALIRO_READER_ID_SIZE],
76 const uint8_t credential_ephemeral_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE],
77 const uint8_t reader_ephemeral_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE],
78 const uint8_t transaction_identifier[WOZ_ALIRO_TRANSACTION_ID_SIZE], uint32_t usage,
79 uint8_t output[WOZ_ALIRO_AUTH_DATA_SIZE]);
80
81int woz_aliro_build_auth1_command(uint8_t command_parameters,
82 const uint8_t signature[WOZ_ALIRO_SIGNATURE_SIZE],
83 uint8_t *output, size_t output_capacity, size_t *output_length);
84
85int woz_aliro_build_auth1_command_ex(uint8_t command_parameters,
86 const uint8_t signature[WOZ_ALIRO_SIGNATURE_SIZE],
87 const uint8_t *reader_certificate,
88 size_t reader_certificate_length, uint8_t *output,
89 size_t output_capacity, size_t *output_length);
90
91int woz_aliro_parse_auth1_plaintext(const uint8_t *plaintext, size_t plaintext_length,
92 int public_key_requested,
93 struct woz_aliro_auth1_response *result);
94
95#ifdef __cplusplus
96}
97#endif
int woz_aliro_parse_auth1_plaintext(const uint8_t *plaintext, size_t plaintext_length, int public_key_requested, struct woz_aliro_auth1_response *result)
Parse plaintext AUTH1 response (TLV-encoded): credential public key (tag 0x5a if public_key_requested...
Definition nfc_auth.c:234
int woz_aliro_parse_auth0_response(const uint8_t *response, size_t response_length, int fast_requested, struct woz_aliro_auth0_response *result)
Parse an AUTH0 response APDU (status 0x9000, TLV-encoded) and extract credential ephemeral public key...
Definition nfc_auth.c:83
int woz_aliro_build_auth1_command_ex(uint8_t command_parameters, const uint8_t signature[WOZ_ALIRO_SIGNATURE_SIZE], const uint8_t *reader_certificate, size_t reader_certificate_length, uint8_t *output, size_t output_capacity, size_t *output_length)
Build an NFC AUTH1 command APDU with ECDSA signature and optional reader certificate; return WOZ_ALIR...
Definition nfc_auth.c:191
int woz_aliro_build_auth1_command(uint8_t command_parameters, const uint8_t signature[WOZ_ALIRO_SIGNATURE_SIZE], uint8_t *output, size_t output_capacity, size_t *output_length)
Build an NFC AUTH1 command APDU with ECDSA signature and no reader certificate; return WOZ_ALIRO_AUTH...
Definition nfc_auth.c:178
int woz_aliro_build_auth0_command(const struct woz_aliro_auth0_command *params, uint8_t *output, size_t output_capacity, size_t *output_length)
Build an NFC AUTH0 command APDU with reader ephemeral public key, transaction and reader identifiers,...
Definition nfc_auth.c:30
int woz_aliro_build_authentication_data(const uint8_t reader_identifier[WOZ_ALIRO_READER_ID_SIZE], const uint8_t credential_ephemeral_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE], const uint8_t reader_ephemeral_public_key[WOZ_ALIRO_PUBLIC_KEY_SIZE], const uint8_t transaction_identifier[WOZ_ALIRO_TRANSACTION_ID_SIZE], uint32_t usage, uint8_t output[WOZ_ALIRO_AUTH_DATA_SIZE])
Build the fixed-size 256-byte Aliro authentication data structure containing TLV-encoded reader ident...
Definition nfc_auth.c:141
Parsed NFC AUTH0 command: authentication policy and protocol version from the reader,...
Definition nfc_auth.h:32
Parsed NFC AUTH0 response: credential ephemeral public key (65 bytes), cryptogram (variable length),...
Definition nfc_auth.h:47
Parsed NFC AUTH1 response: credential public key (65 bytes), signature (variable length),...
Definition nfc_auth.h:60