UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
treaty.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_TREATY_H
53#define UDIF_TREATY_H
54
55#include "udif.h"
56
85
90#define UDIF_TREATY_SCOPE_ANALYTICS 1U
91
96#define UDIF_TREATY_SCOPE_INTRA_DOMAIN 2U
97
102#define UDIF_TREATY_SCOPE_LOCAL 4U
103
108#define UDIF_TREATY_SCOPE_QUERY 8U
109
114#define UDIF_TREATY_SCOPE_TRANSFER 16U
115
120#define UDIF_TREATY_SCOPE_TREATY 32U
121
126#define UDIF_TREATY_SCOPE_RESERVED1 64U
127
132#define UDIF_TREATY_SCOPE_RESERVED2 128U
133
138#define UDIF_TREATY_SCOPE_RESERVED3 256U
139
144#define UDIF_TREATY_SCOPE_MAX 256U
145
150#define UDIF_TREATY_POLICY_VERSION_SIZE 4U
151
156#define UDIF_TREATY_SCOPE_QUERY_SIZE 4U
157
162#define UDIF_TREATY_DEFAULT_DURATION (365U * 24U * 3600U)
163
168#define UDIF_TREATY_MAX_DURATION (5U * 365U * 24U * 3600U)
169
174#define UDIF_TREATY_STRUCTURE_SIZE (UDIF_SIGNED_HASH_SIZE + \
175 UDIF_SIGNED_HASH_SIZE + \
176 UDIF_SERIAL_NUMBER_SIZE + \
177 UDIF_SERIAL_NUMBER_SIZE + \
178 UDIF_SERIAL_NUMBER_SIZE + \
179 UDIF_VALID_TIME_SIZE + \
180 UDIF_VALID_TIME_SIZE + \
181 UDIF_TREATY_POLICY_VERSION_SIZE + \
182 UDIF_TREATY_SCOPE_QUERY_SIZE)
183
203
215UDIF_EXPORT_API udif_errors udif_treaty_accept(udif_treaty* treaty, const uint8_t* domsigkeyb, bool (*rng_generate)(uint8_t*, size_t));
216
227UDIF_EXPORT_API bool udif_treaty_allows_scope(const udif_treaty* treaty, uint32_t scope);
228
237
249
261
280UDIF_EXPORT_API udif_errors udif_treaty_create_proposal(udif_treaty* treaty, const uint8_t* treatyid, const uint8_t* domsera, const uint8_t* domserb,
281 uint32_t scopebitmap, uint64_t validfrom, uint64_t validto, uint32_t policy, const uint8_t* domsigkeya, bool (*rng_generate)(uint8_t*, size_t));
282
294UDIF_EXPORT_API udif_errors udif_treaty_deserialize(udif_treaty* treaty, const uint8_t* input, size_t inplen);
295
306
317
328UDIF_EXPORT_API bool udif_treaty_is_active(const udif_treaty* treaty, uint64_t ctime);
329
340UDIF_EXPORT_API bool udif_treaty_is_expired(const udif_treaty* treaty, uint64_t ctime);
341
352UDIF_EXPORT_API bool udif_treaty_is_participant(const udif_treaty* treaty, const uint8_t* entityser);
353
364
376UDIF_EXPORT_API udif_errors udif_treaty_serialize(uint8_t* output, size_t outlen, const udif_treaty* treaty);
377
388
400UDIF_EXPORT_API bool udif_treaty_verify(const udif_treaty* treaty, const uint8_t* domverkeya, const uint8_t* domverkeyb);
401
402#endif
Cross-domain treaty.
Definition treaty.h:192
uint8_t domsigb[UDIF_SIGNED_HASH_SIZE]
Definition treaty.h:194
uint8_t treatyid[UDIF_SERIAL_NUMBER_SIZE]
Definition treaty.h:197
uint32_t scopebitmap
Definition treaty.h:201
uint8_t domsera[UDIF_SERIAL_NUMBER_SIZE]
Definition treaty.h:195
uint64_t validfrom
Definition treaty.h:198
uint8_t domserb[UDIF_SERIAL_NUMBER_SIZE]
Definition treaty.h:196
uint32_t policy
Definition treaty.h:200
uint64_t validto
Definition treaty.h:199
uint8_t domsiga[UDIF_SIGNED_HASH_SIZE]
Definition treaty.h:193
UDIF_EXPORT_API bool udif_treaty_is_participant(const udif_treaty *treaty, const uint8_t *entityser)
Check if entity is treaty participant.
Definition treaty.c:328
UDIF_EXPORT_API bool udif_treaty_allows_scope(const udif_treaty *treaty, uint32_t scope)
Check if treaty allows scope.
Definition treaty.c:57
UDIF_EXPORT_API bool udif_treaty_is_expired(const udif_treaty *treaty, uint64_t ctime)
Check if treaty is expired.
Definition treaty.c:312
UDIF_EXPORT_API size_t udif_treaty_encoded_size(const udif_treaty *treaty)
Get treaty encoded size.
Definition treaty.c:255
UDIF_EXPORT_API udif_errors udif_treaty_create_proposal(udif_treaty *treaty, const uint8_t *treatyid, const uint8_t *domsera, const uint8_t *domserb, uint32_t scopebitmap, uint64_t validfrom, uint64_t validto, uint32_t policy, const uint8_t *domsigkeya, bool(*rng_generate)(uint8_t *, size_t))
Create a treaty proposal.
Definition treaty.c:98
UDIF_EXPORT_API bool udif_treaty_is_active(const udif_treaty *treaty, uint64_t ctime)
Check if treaty is active.
Definition treaty.c:288
UDIF_EXPORT_API udif_errors udif_treaty_accept(udif_treaty *treaty, const uint8_t *domsigkeyb, bool(*rng_generate)(uint8_t *, size_t))
Accept a treaty proposal.
Definition treaty.c:6
UDIF_EXPORT_API bool udif_treaty_verify(const udif_treaty *treaty, const uint8_t *domverkeya, const uint8_t *domverkeyb)
Verify a treaty.
Definition treaty.c:443
UDIF_EXPORT_API udif_errors udif_treaty_deserialize(udif_treaty *treaty, const uint8_t *input, size_t inplen)
Deserialize a treaty.
Definition treaty.c:216
UDIF_EXPORT_API udif_errors udif_treaty_validate(const udif_treaty *treaty)
Validate treaty parameters.
Definition treaty.c:411
UDIF_EXPORT_API void udif_treaty_clear(udif_treaty *treaty)
Clear a treaty.
Definition treaty.c:73
UDIF_EXPORT_API uint64_t udif_treaty_get_duration(const udif_treaty *treaty)
Get treaty duration.
Definition treaty.c:272
UDIF_EXPORT_API bool udif_treaty_is_pending(const udif_treaty *treaty)
Check if treaty is pending.
Definition treaty.c:355
UDIF_EXPORT_API udif_errors udif_treaty_compute_digest(uint8_t *digest, const udif_treaty *treaty)
Compute treaty digest.
Definition treaty.c:180
UDIF_EXPORT_API udif_errors udif_treaty_serialize(uint8_t *output, size_t outlen, const udif_treaty *treaty)
Serialize a treaty.
Definition treaty.c:372
UDIF_EXPORT_API bool udif_treaty_compare(const udif_treaty *a, const udif_treaty *b)
Compare two treaties.
Definition treaty.c:81
UDIF Common Definitions and Protocol Configuration.
#define UDIF_SERIAL_NUMBER_SIZE
The serial number field length.
Definition udif.h:519
#define UDIF_SIGNED_HASH_SIZE
The combined size of a signature and hash.
Definition udif.h:525
udif_errors
UDIF error codes.
Definition udif.h:628
#define UDIF_EXPORT_API
The api export prefix.
Definition udifcommon.h:103