UDIF: Universal Digital Identification Framework 1.1.0.0a (A1)
A quantum-secure cryptographic identification
treatystore.h File Reference

Runtime treaty store. More...

#include "treaty.h"
#include "query.h"

Go to the source code of this file.

Data Structures

struct  udif_treatystore_entry
 Stored treaty record. More...
struct  udif_treatystore_pending_query
 Pending treaty query awaiting a signed response. More...
struct  udif_treatystore
 Fixed-capacity treaty table. More...

Macros

#define UDIF_TREATYSTORE_CAPACITY   64U
 Maximum number of treaty records retained in one entity context.
#define UDIF_TREATYSTORE_PENDING_CAPACITY   64U
 Maximum number of pending treaty-query responses tracked.

Typedefs

typedef UDIF_EXPORT_API enum udif_treatystore_status udif_treatystore_status
typedef UDIF_EXPORT_API struct udif_treatystore_entry udif_treatystore_entry
typedef UDIF_EXPORT_API struct udif_treatystore_pending_query udif_treatystore_pending_query
typedef UDIF_EXPORT_API struct udif_treatystore udif_treatystore

Enumerations

enum  udif_treatystore_status { udif_treatystore_status_unknown = 0x00U , udif_treatystore_status_active = 0x01U , udif_treatystore_status_revoked = 0x02U , udif_treatystore_status_expired = 0x03U }
 Runtime treaty status. More...

Functions

UDIF_EXPORT_API void udif_treatystore_initialize (udif_treatystore *store)
 Initialize a treaty store.
UDIF_EXPORT_API void udif_treatystore_clear (udif_treatystore *store)
 Clear a treaty store.
UDIF_EXPORT_API udif_errors udif_treatystore_add (udif_treatystore *store, const udif_treaty *treaty, udif_treatystore_status status, uint64_t nowsecs)
 Add or update a treaty.
UDIF_EXPORT_API const udif_treatyudif_treatystore_find (const udif_treatystore *store, const uint8_t *treatyid)
 Find a treaty by identifier.
UDIF_EXPORT_API udif_treatystore_status udif_treatystore_get_status (const udif_treatystore *store, const uint8_t *treatyid)
 Return a treaty status by identifier.
UDIF_EXPORT_API udif_errors udif_treatystore_set_status (udif_treatystore *store, const uint8_t *treatyid, udif_treatystore_status status, uint64_t nowsecs)
 Set the status of an existing treaty.
UDIF_EXPORT_API const udif_treatyudif_treatystore_find_active_for_query (udif_treatystore *store, const uint8_t *localser, const uint8_t *peerser, uint8_t querytype, uint64_t nowsecs)
 Find an active treaty linking the local and peer serials.
UDIF_EXPORT_API udif_errors udif_treatystore_add_pending_query (udif_treatystore *store, const uint8_t *treatyid, const uint8_t *peerser, const udif_query *query, uint64_t expires)
 Add a pending treaty query response expectation.
UDIF_EXPORT_API udif_errors udif_treatystore_consume_pending_response (udif_treatystore *store, const uint8_t *localser, const uint8_t *peerser, const udif_query_response *response, uint64_t nowsecs)
 Consume a pending treaty response expectation.

Detailed Description

Runtime treaty store.

The treaty store is a fixed-capacity table keyed by treaty identifier. It records active and revoked bilateral treaties and provides peer/query lookup helpers for cross-domain forwarding enforcement.

Enumeration Type Documentation

◆ udif_treatystore_status

Runtime treaty status.

Enumerator
udif_treatystore_status_unknown 

No treaty status is known.

udif_treatystore_status_active 

Treaty is active and may authorize forwarding.

udif_treatystore_status_revoked 

Treaty has been revoked.

udif_treatystore_status_expired 

Treaty has expired.

Function Documentation

◆ udif_treatystore_add()

UDIF_EXPORT_API udif_errors udif_treatystore_add ( udif_treatystore * store,
const udif_treaty * treaty,
udif_treatystore_status status,
uint64_t nowsecs )

Add or update a treaty.

Parameters
storeThe treaty store.
treaty[const] The treaty to store.
statusThe treaty status.
nowsecsThe UTC status time.
Returns
Returns udif_error_none on success.

◆ udif_treatystore_add_pending_query()

UDIF_EXPORT_API udif_errors udif_treatystore_add_pending_query ( udif_treatystore * store,
const uint8_t * treatyid,
const uint8_t * peerser,
const udif_query * query,
uint64_t expires )

Add a pending treaty query response expectation.

Parameters
storeThe treaty store.
treatyid[const] The treaty identifier.
peerser[const] The expected responding peer serial.
query[const] The outbound treaty query.
expiresThe expiration time for the pending response.
Returns
Returns udif_error_none on success.

◆ udif_treatystore_clear()

UDIF_EXPORT_API void udif_treatystore_clear ( udif_treatystore * store)

Clear a treaty store.

Parameters
storeThe treaty store.

◆ udif_treatystore_consume_pending_response()

UDIF_EXPORT_API udif_errors udif_treatystore_consume_pending_response ( udif_treatystore * store,
const uint8_t * localser,
const uint8_t * peerser,
const udif_query_response * response,
uint64_t nowsecs )

Consume a pending treaty response expectation.

A matching pending query is removed only when the response query id, embedded query digest, expected peer, and expected query type match.

Parameters
storeThe treaty store.
localser[const] The local controller serial.
peerser[const] The responding peer serial.
response[const] The treaty query response.
nowsecsThe current UTC time.
Returns
Returns udif_error_none on success.

◆ udif_treatystore_find()

UDIF_EXPORT_API const udif_treaty * udif_treatystore_find ( const udif_treatystore * store,
const uint8_t * treatyid )

Find a treaty by identifier.

Parameters
store[const] The treaty store.
treatyid[const] The treaty identifier.
Returns
Returns the stored treaty, or NULL.

◆ udif_treatystore_find_active_for_query()

UDIF_EXPORT_API const udif_treaty * udif_treatystore_find_active_for_query ( udif_treatystore * store,
const uint8_t * localser,
const uint8_t * peerser,
uint8_t querytype,
uint64_t nowsecs )

Find an active treaty linking the local and peer serials.

Parameters
storeThe treaty store.
localser[const] The local domain-controller serial.
peerser[const] The peer domain-controller serial.
querytypeThe requested query predicate family.
nowsecsThe UTC validation time.
Returns
Returns the active treaty, or NULL.

◆ udif_treatystore_get_status()

UDIF_EXPORT_API udif_treatystore_status udif_treatystore_get_status ( const udif_treatystore * store,
const uint8_t * treatyid )

Return a treaty status by identifier.

Parameters
store[const] The treaty store.
treatyid[const] The treaty identifier.
Returns
Returns the stored status, or unknown.

◆ udif_treatystore_initialize()

UDIF_EXPORT_API void udif_treatystore_initialize ( udif_treatystore * store)

Initialize a treaty store.

Parameters
storeThe treaty store.

◆ udif_treatystore_set_status()

UDIF_EXPORT_API udif_errors udif_treatystore_set_status ( udif_treatystore * store,
const uint8_t * treatyid,
udif_treatystore_status status,
uint64_t nowsecs )

Set the status of an existing treaty.

Parameters
storeThe treaty store.
treatyid[const] The treaty identifier.
statusThe new status.
nowsecsThe UTC status time.
Returns
Returns udif_error_none on success.