UDIF: Universal Digital Identification Framework 1.1.0.0a (A1)
A quantum-secure cryptographic identification
treatystore.h
Go to the documentation of this file.
1/* 2025-2026 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE:
5 * This software and all accompanying materials are the exclusive property of
6 * Quantum Resistant Cryptographic Solutions Corporation (QRCS). The intellectual
7 * and technical concepts contained herein are proprietary to QRCS and are
8 * protected under applicable Canadian, U.S., and international copyright,
9 * patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC ALGORITHMS AND IMPLEMENTATIONS:
12 * - This software includes implementations of cryptographic primitives and
13 * algorithms that are standardized or in the public domain, such as AES
14 * and SHA-3, which are not proprietary to QRCS.
15 * - This software also includes cryptographic primitives, constructions, and
16 * algorithms designed by QRCS, including but not limited to RCS, SCB, CSX, QMAC, and
17 * related components, which are proprietary to QRCS.
18 * - All source code, implementations, protocol compositions, optimizations,
19 * parameter selections, and engineering work contained in this software are
20 * original works of QRCS and are protected under this license.
21 *
22 * LICENSE AND USE RESTRICTIONS:
23 * - This software is licensed under the Quantum Resistant Cryptographic Solutions
24 * Public Research and Evaluation License (QRCS-PREL), 2025-2026.
25 * - Permission is granted solely for non-commercial evaluation, academic research,
26 * cryptographic analysis, interoperability testing, and feasibility assessment.
27 * - Commercial use, production deployment, commercial redistribution, or
28 * integration into products or services is strictly prohibited without a
29 * separate written license agreement executed with QRCS.
30 * - Licensing and authorized distribution are solely at the discretion of QRCS.
31 *
32 * EXPERIMENTAL CRYPTOGRAPHY NOTICE:
33 * Portions of this software may include experimental, novel, or evolving
34 * cryptographic designs. Use of this software is entirely at the user's risk.
35 *
36 * DISCLAIMER:
37 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
39 * FOR A PARTICULAR PURPOSE, SECURITY, OR NON-INFRINGEMENT. QRCS DISCLAIMS ALL
40 * LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
41 * ARISING FROM THE USE OR MISUSE OF THIS SOFTWARE.
42 *
43 * FULL LICENSE:
44 * This software is subject to the Quantum Resistant Cryptographic Solutions
45 * Public Research and Evaluation License (QRCS-PREL), 2025-2026. The complete license terms
46 * are provided in the accompanying LICENSE file or at https://www.qrcscorp.ca.
47 *
48 * Written by: John G. Underhill
49 * Contact: contact@qrcscorp.ca
50 */
51
52#ifndef UDIF_TREATYSTORE_H
53#define UDIF_TREATYSTORE_H
54
55#include "treaty.h"
56#include "query.h"
57
66
70#define UDIF_TREATYSTORE_CAPACITY 64U
71
75#define UDIF_TREATYSTORE_PENDING_CAPACITY 64U
76
87
98
99
113
124
130
136
147
155UDIF_EXPORT_API const udif_treaty* udif_treatystore_find(const udif_treatystore* store, const uint8_t* treatyid);
156
165
175UDIF_EXPORT_API udif_errors udif_treatystore_set_status(udif_treatystore* store, const uint8_t* treatyid, udif_treatystore_status status, uint64_t nowsecs);
176
188 const uint8_t* peerser, uint8_t querytype, uint64_t nowsecs);
189
200UDIF_EXPORT_API udif_errors udif_treatystore_add_pending_query(udif_treatystore* store, const uint8_t* treatyid, const uint8_t* peerser,
201 const udif_query* query, uint64_t expires);
202
216UDIF_EXPORT_API udif_errors udif_treatystore_consume_pending_response(udif_treatystore* store, const uint8_t* localser, const uint8_t* peerser,
217 const udif_query_response* response, uint64_t nowsecs);
218
219#endif
UDIF query operations.
Query response.
Definition query.h:188
Query request.
Definition query.h:171
Cross-domain treaty.
Definition treaty.h:216
Stored treaty record.
Definition treatystore.h:92
udif_treatystore_status status
Definition treatystore.h:94
bool occupied
Definition treatystore.h:96
udif_treaty treaty
Definition treatystore.h:93
uint64_t statustime
Definition treatystore.h:95
Pending treaty query awaiting a signed response.
Definition treatystore.h:104
uint8_t treatyid[UDIF_SERIAL_NUMBER_SIZE]
Definition treatystore.h:105
uint8_t querytype
Definition treatystore.h:110
uint64_t expires
Definition treatystore.h:109
uint8_t queryid[UDIF_QUERY_ID_SIZE]
Definition treatystore.h:107
uint8_t querydigest[UDIF_CRYPTO_HASH_SIZE]
Definition treatystore.h:108
uint8_t peerser[UDIF_SERIAL_NUMBER_SIZE]
Definition treatystore.h:106
bool occupied
Definition treatystore.h:111
Fixed-capacity treaty table.
Definition treatystore.h:118
size_t pendingcount
Definition treatystore.h:122
size_t count
Definition treatystore.h:121
udif_treatystore_entry entries[UDIF_TREATYSTORE_CAPACITY]
Definition treatystore.h:119
udif_treatystore_pending_query pending[UDIF_TREATYSTORE_PENDING_CAPACITY]
Definition treatystore.h:120
UDIF treaty operations.
UDIF_EXPORT_API void udif_treatystore_clear(udif_treatystore *store)
Clear a treaty store.
Definition treatystore.c:84
#define UDIF_TREATYSTORE_CAPACITY
Maximum number of treaty records retained in one entity context.
Definition treatystore.h:70
UDIF_EXPORT_API const udif_treaty * udif_treatystore_find(const udif_treatystore *store, const uint8_t *treatyid)
Find a treaty by identifier.
Definition treatystore.c:140
#define UDIF_TREATYSTORE_PENDING_CAPACITY
Maximum number of pending treaty-query responses tracked.
Definition treatystore.h:75
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.
Definition treatystore.c:212
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.
Definition treatystore.c:92
UDIF_EXPORT_API void udif_treatystore_initialize(udif_treatystore *store)
Initialize a treaty store.
Definition treatystore.c:74
UDIF_EXPORT_API udif_treatystore_status udif_treatystore_get_status(const udif_treatystore *store, const uint8_t *treatyid)
Return a treaty status by identifier.
Definition treatystore.c:163
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.
Definition treatystore.c:183
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.
Definition treatystore.c:277
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.
Definition treatystore.c:315
udif_treatystore_status
Runtime treaty status.
Definition treatystore.h:81
@ udif_treatystore_status_revoked
Definition treatystore.h:84
@ udif_treatystore_status_active
Definition treatystore.h:83
@ udif_treatystore_status_expired
Definition treatystore.h:85
@ udif_treatystore_status_unknown
Definition treatystore.h:82
#define UDIF_SERIAL_NUMBER_SIZE
The certificate serial number field length.
Definition udif.h:546
#define UDIF_CRYPTO_HASH_SIZE
The size of the certificate hash in bytes.
Definition udif.h:439
udif_errors
UDIF error codes.
Definition udif.h:1210
#define UDIF_QUERY_ID_SIZE
The query identifier field length in bytes.
Definition udif.h:531
#define UDIF_EXPORT_API
The api export prefix.
Definition udifcommon.h:101