Auth Page

include/rid/auth_page.h Authentication message handling per ASTM F3411-22a.

Authentication messages support multi-page transmission with up to 16 pages (0-15). Page 0 has a different structure than pages 1-15.

Note:

For typical use cases, you should use the higher-level API in auth.h instead which manages multi-page authentication data automatically.

See also: auth.h Example usage:

    rid_auth_page_0_t page_0;
    rid_auth_page_x_t page_1;
    rid_auth_page_x_t page_2;

    /* sample authentication data */
    const uint8_t page_0_data[] = {
        0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09,
        0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
        0x01
    };

    const uint8_t page_1_data[] = {
        0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30,
        0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00,
        0xbb, 0x6a, 0x8c, 0x7e, 0x5f, 0x2a, 0x9b
    };

    const uint8_t page_2_data[] = {
        0xc5, 0x7b, 0x99, 0x3a, 0x1d, 0x03, 0x66, 0x81,
        0xf4, 0x9e, 0x2c, 0x87, 0xab, 0x4f, 0xe0, 0x12
    };

    /* page 0 example */
    rid_auth_page_0_init(&page_0);
    rid_auth_page_0_set_type(&page_0, RID_AUTH_TYPE_MESSAGE_SET_SIGNATURE);
    rid_auth_page_0_set_last_page_index(&page_0, 2);
    rid_auth_page_0_set_length(&page_0, 56);
    rid_auth_page_0_set_timestamp(&page_0, 189302400);
    rid_auth_page_0_set_data(&page_0, page_0_data, sizeof(page_0_data));

    printf("Page 0:\n");
    hexdump(&page_0, sizeof(page_0));

    uint8_t data_buffer[RID_AUTH_PAGE_0_DATA_SIZE];
    rid_auth_page_0_get_data(&page_0, data_buffer, sizeof(data_buffer));

    printf("Auth type:       %d\n", rid_auth_page_0_get_type(&page_0));
    printf("Last page index: %d\n", rid_auth_page_0_get_last_page_index(&page_0));
    printf("Length:          %d\n", rid_auth_page_0_get_length(&page_0));
    printf("Timestamp:       %u\n", rid_auth_page_0_get_timestamp(&page_0));
    printf("\n");

    /* page 1 example */
    rid_auth_page_x_init(&page_1, 1);
    rid_auth_page_x_set_type(&page_1, RID_AUTH_TYPE_MESSAGE_SET_SIGNATURE);
    rid_auth_page_x_set_data(&page_1, page_1_data, sizeof(page_1_data));

    printf("Page 1:\n");
    hexdump(&page_1, sizeof(page_1));

    printf("Auth type:   %d\n", rid_auth_page_x_get_type(&page_1));
    printf("Page number: %d\n", rid_auth_page_x_get_number(&page_1));
    printf("\n");

    /* page 2 example */
    rid_auth_page_x_init(&page_2, 2);
    rid_auth_page_x_set_type(&page_2, RID_AUTH_TYPE_MESSAGE_SET_SIGNATURE);
    rid_auth_page_x_set_data(&page_2, page_2_data, sizeof(page_2_data));

    printf("Page 2:\n");
    hexdump(&page_2, sizeof(page_2));

    printf("Auth type:   %d\n", rid_auth_page_x_get_type(&page_2));
    printf("Page number: %d\n", rid_auth_page_x_get_number(&page_2));

Structures and Types

Type Name
struct rid_auth_page_0_t
Authentication message page 0 structure per ASTM F3411-22a.
struct rid_auth_page_x_t
Authentication message pages 1-15 structure per ASTM F3411-22a.
enum rid_auth_type_t
Authentication type classification per ASTM F3411-22a.

Functions

Type Name
int rid_auth_page_0_get_data (const rid_auth_page_0_t *message, uint8_t *buffer, size_t buffer_size)
Get the authentication data from page 0.
uint8_t rid_auth_page_0_get_last_page_index (const rid_auth_page_0_t *message)
Get the last page index from page 0.
uint8_t rid_auth_page_0_get_length (const rid_auth_page_0_t *message)
Get the total authentication data length from page 0.
uint32_t rid_auth_page_0_get_timestamp (const rid_auth_page_0_t *message)
Get the timestamp from page 0.
rid_auth_type_t rid_auth_page_0_get_type (const rid_auth_page_0_t *message)
Get the authentication type from page 0.
int rid_auth_page_0_init (rid_auth_page_0_t *message)
Initialize an Authentication message page 0 structure.
int rid_auth_page_0_set_data (rid_auth_page_0_t *message, const uint8_t *data, size_t size)
Set the authentication data for page 0.
int rid_auth_page_0_set_last_page_index (rid_auth_page_0_t *message, uint8_t index)
Set the last page index for page 0.
int rid_auth_page_0_set_length (rid_auth_page_0_t *message, uint8_t length)
Set the total authentication data length for page 0.
int rid_auth_page_0_set_timestamp (rid_auth_page_0_t *message, uint32_t timestamp)
Set the timestamp for page 0.
int rid_auth_page_0_set_type (rid_auth_page_0_t *message, rid_auth_type_t type)
Set the authentication type for page 0.
int rid_auth_page_to_json (const void *message, char *buffer, size_t buffer_size, size_t *needed_size)
Format a single AUTH page message as a JSON string.
int rid_auth_page_x_get_data (const rid_auth_page_x_t *message, uint8_t *buffer, size_t buffer_size)
Get the authentication data from pages 1-15.
uint8_t rid_auth_page_x_get_number (const rid_auth_page_x_t *message)
Get the page number from pages 1-15.
rid_auth_type_t rid_auth_page_x_get_type (const rid_auth_page_x_t *message)
Get the authentication type from pages 1-15.
int rid_auth_page_x_init (rid_auth_page_x_t *message, uint8_t page_number)
Initialize an Authentication message page 1-15 structure.
int rid_auth_page_x_set_data (rid_auth_page_x_t *message, const uint8_t *data, size_t size)
Set the authentication data for pages 1-15.
int rid_auth_page_x_set_number (rid_auth_page_x_t *message, uint8_t page_number)
Set the page number for pages 1-15.
int rid_auth_page_x_set_type (rid_auth_page_x_t *message, rid_auth_type_t type)
Set the authentication type for pages 1-15.
const char * rid_auth_type_to_string (rid_auth_type_t type)
Convert authentication type to string representation.

Macros

Type Name
define RID_AUTH_EPOCH_OFFSET 1546300800
Timestamp epoch offset (2019-01-01 00:00:00 UTC).
define RID_AUTH_MAX_PAGES 16
Maximum number of authentication pages.
define RID_AUTH_MAX_PAGE_INDEX 15
Maximum page index (0-15).
define RID_AUTH_PAGE_0_DATA_SIZE 17
Auth data size for page 0.
define RID_AUTH_PAGE_DATA_SIZE 23
Auth data size for pages 1-15.

Structures and Types Documentation

struct rid_auth_page_0_t

Authentication message page 0 structure per ASTM F3411-22a.

Page 0 contains header information including timestamp and total length.

Variables:

  • uint8_t auth_data

  • uint8_t auth_type

  • uint8_t last_page_index

  • uint8_t length

  • uint8_t message_type

  • uint8_t page_number

  • uint8_t protocol_version

  • uint32_t timestamp

struct rid_auth_page_x_t

Authentication message pages 1-15 structure per ASTM F3411-22a.

Pages 1-15 contain only auth type, page number, and authentication data.

Variables:

  • uint8_t auth_data

  • uint8_t auth_type

  • uint8_t message_type

  • uint8_t page_number

  • uint8_t protocol_version

enum rid_auth_type_t

Authentication type classification per ASTM F3411-22a.

enum rid_auth_type_t {
    RID_AUTH_TYPE_NONE = 0,
    RID_AUTH_TYPE_UAS_ID_SIGNATURE = 1,
    RID_AUTH_TYPE_OPERATOR_ID_SIGNATURE = 2,
    RID_AUTH_TYPE_MESSAGE_SET_SIGNATURE = 3,
    RID_AUTH_TYPE_NETWORK_REMOTE_ID = 4,
    RID_AUTH_TYPE_SPECIFIC_METHOD = 5,
    RID_AUTH_TYPE_MAX = 0x0F
};

Functions Documentation

function rid_auth_page_0_get_data

Get the authentication data from page 0.

int rid_auth_page_0_get_data (
    const rid_auth_page_0_t *message,
    uint8_t *buffer,
    size_t buffer_size
) 

Parameters:

  • message Pointer to the Authentication message structure.
  • buffer Buffer to store the authentication data.
  • buffer_size Size of the buffer (must be at least 17).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or buffer is NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer_size < 17.

function rid_auth_page_0_get_last_page_index

Get the last page index from page 0.

uint8_t rid_auth_page_0_get_last_page_index (
    const rid_auth_page_0_t *message
) 

Parameters:

  • message Pointer to the Authentication message structure.

Returns:

The last page index, or 0 if message is NULL.

function rid_auth_page_0_get_length

Get the total authentication data length from page 0.

uint8_t rid_auth_page_0_get_length (
    const rid_auth_page_0_t *message
) 

Parameters:

  • message Pointer to the Authentication message structure.

Returns:

The total length, or 0 if message is NULL.

function rid_auth_page_0_get_timestamp

Get the timestamp from page 0.

uint32_t rid_auth_page_0_get_timestamp (
    const rid_auth_page_0_t *message
) 

Parameters:

  • message Pointer to the Authentication message structure.

Returns:

Seconds since 2019-01-01 00:00:00 UTC, or 0 if message is NULL.

function rid_auth_page_0_get_type

Get the authentication type from page 0.

rid_auth_type_t rid_auth_page_0_get_type (
    const rid_auth_page_0_t *message
) 

Parameters:

  • message Pointer to the Authentication message structure.

Returns:

The authentication type, or RID_AUTH_TYPE_NONE if message is NULL.

function rid_auth_page_0_init

Initialize an Authentication message page 0 structure.

int rid_auth_page_0_init (
    rid_auth_page_0_t *message
) 

Sets protocol version to RID_PROTOCOL_VERSION_2, message type to RID_MESSAGE_TYPE_AUTH, and page number to 0. All other fields are zeroed.

Parameters:

  • message Pointer to the Authentication message structure to initialize.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.

function rid_auth_page_0_set_data

Set the authentication data for page 0.

int rid_auth_page_0_set_data (
    rid_auth_page_0_t *message,
    const uint8_t *data,
    size_t size
) 

Parameters:

  • message Pointer to the Authentication message structure.
  • data Pointer to the authentication data.
  • size Size of the data (max 17 bytes).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or data is NULL.
  • RID_ERROR_BUFFER_TOO_LARGE if size > 17.

function rid_auth_page_0_set_last_page_index

Set the last page index for page 0.

int rid_auth_page_0_set_last_page_index (
    rid_auth_page_0_t *message,
    uint8_t index
) 

Parameters:

  • message Pointer to the Authentication message structure.
  • index The last page index (0-15).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if index > 15.

function rid_auth_page_0_set_length

Set the total authentication data length for page 0.

int rid_auth_page_0_set_length (
    rid_auth_page_0_t *message,
    uint8_t length
) 

Parameters:

  • message Pointer to the Authentication message structure.
  • length The total length of authentication data across all pages.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.

function rid_auth_page_0_set_timestamp

Set the timestamp for page 0.

int rid_auth_page_0_set_timestamp (
    rid_auth_page_0_t *message,
    uint32_t timestamp
) 

Timestamp is seconds since 2019-01-01 00:00:00 UTC.

Parameters:

  • message Pointer to the Authentication message structure.
  • timestamp Seconds since 2019-01-01 00:00:00 UTC.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.

function rid_auth_page_0_set_type

Set the authentication type for page 0.

int rid_auth_page_0_set_type (
    rid_auth_page_0_t *message,
    rid_auth_type_t type
) 

Parameters:

  • message Pointer to the Authentication message structure.
  • type The authentication type to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if type exceeds RID_AUTH_TYPE_MAX.

function rid_auth_page_to_json

Format a single AUTH page message as a JSON string.

int rid_auth_page_to_json (
    const void *message,
    char *buffer,
    size_t buffer_size,
    size_t *needed_size
) 

Handles both page 0 (rid_auth_page_0_t) and pages 1-15 (rid_auth_page_x_t) automatically based on the page_number field.

Parameters:

  • message Pointer to an AUTH page structure.
  • buffer Buffer to store the JSON string or NULL.
  • buffer_size Size of the buffer.
  • needed_size If non-NULL receives the required buffer size.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL or if bothbuffer andneeded_size are NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer is too small.

function rid_auth_page_x_get_data

Get the authentication data from pages 1-15.

int rid_auth_page_x_get_data (
    const rid_auth_page_x_t *message,
    uint8_t *buffer,
    size_t buffer_size
) 

Parameters:

  • message Pointer to the Authentication page structure.
  • buffer Buffer to store the authentication data.
  • buffer_size Size of the buffer (must be at least 23).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or buffer is NULL.
  • RID_ERROR_BUFFER_TOO_SMALL if buffer_size < 23.

function rid_auth_page_x_get_number

Get the page number from pages 1-15.

uint8_t rid_auth_page_x_get_number (
    const rid_auth_page_x_t *message
) 

Parameters:

  • message Pointer to the Authentication page structure.

Returns:

The page number, or 0 if message is NULL.

function rid_auth_page_x_get_type

Get the authentication type from pages 1-15.

rid_auth_type_t rid_auth_page_x_get_type (
    const rid_auth_page_x_t *message
) 

Parameters:

  • message Pointer to the Authentication page structure.

Returns:

The authentication type, or RID_AUTH_TYPE_NONE if message is NULL.

function rid_auth_page_x_init

Initialize an Authentication message page 1-15 structure.

int rid_auth_page_x_init (
    rid_auth_page_x_t *message,
    uint8_t page_number
) 

Sets protocol version to RID_PROTOCOL_VERSION_2, message type to RID_MESSAGE_TYPE_AUTH, and page number to specified value.

Parameters:

  • message Pointer to the Authentication page structure to initialize.
  • page_number Page number (1-15).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if page_number is 0 or > 15.

function rid_auth_page_x_set_data

Set the authentication data for pages 1-15.

int rid_auth_page_x_set_data (
    rid_auth_page_x_t *message,
    const uint8_t *data,
    size_t size
) 

Parameters:

  • message Pointer to the Authentication page structure.
  • data Pointer to the authentication data.
  • size Size of the data (max 23 bytes).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message or data is NULL.
  • RID_ERROR_BUFFER_TOO_LARGE if size > 23.

function rid_auth_page_x_set_number

Set the page number for pages 1-15.

int rid_auth_page_x_set_number (
    rid_auth_page_x_t *message,
    uint8_t page_number
) 

Parameters:

  • message Pointer to the Authentication page structure.
  • page_number The page number (1-15).

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if page_number is 0 or > 15.

function rid_auth_page_x_set_type

Set the authentication type for pages 1-15.

int rid_auth_page_x_set_type (
    rid_auth_page_x_t *message,
    rid_auth_type_t type
) 

Parameters:

  • message Pointer to the Authentication page structure.
  • type The authentication type to set.

Return value:

  • RID_SUCCESS on success.
  • RID_ERROR_NULL_POINTER if message is NULL.
  • RID_ERROR_OUT_OF_RANGE if type exceeds RID_AUTH_TYPE_MAX.

function rid_auth_type_to_string

Convert authentication type to string representation.

const char * rid_auth_type_to_string (
    rid_auth_type_t type
) 

Parameters:

  • type The authentication type to convert.

Returns:

String representation of the authentication type. Returns "UNKNOWN" for invalid values.

Macros Documentation

define RID_AUTH_EPOCH_OFFSET

Timestamp epoch offset (2019-01-01 00:00:00 UTC).

#define RID_AUTH_EPOCH_OFFSET 1546300800

define RID_AUTH_MAX_PAGES

Maximum number of authentication pages.

#define RID_AUTH_MAX_PAGES 16

define RID_AUTH_MAX_PAGE_INDEX

Maximum page index (0-15).

#define RID_AUTH_MAX_PAGE_INDEX 15

define RID_AUTH_PAGE_0_DATA_SIZE

Auth data size for page 0.

#define RID_AUTH_PAGE_0_DATA_SIZE 17

define RID_AUTH_PAGE_DATA_SIZE

Auth data size for pages 1-15.

#define RID_AUTH_PAGE_DATA_SIZE 23