UDIF: Universal Digital Identification Framework 1.1.0.0a (A1)
A quantum-secure cryptographic identification
anchor.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 UDIFANCHOR_H
53#define UDIFANCHOR_H
54
55#include "udif.h"
56
78
83#define UDIF_ANCHOR_INTERVAL_SEC 3600U
84
89#define UDIF_ANCHOR_MAX_AGE_MAX 7200U
90
95#define UDIF_ANCHOR_MAX_SIZE (512U + UDIF_SIGNED_HASH_SIZE)
96
101#define UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER 4U
102
107#define UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER 4U
108
113#define UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER 4U
114
119#define UDIF_ANCHOR_SEQUENCE_SIZE 8U
120
125#define UDIF_ANCHOR_RECORD_SIZE (UDIF_SIGNED_HASH_SIZE + \
126 UDIF_CRYPTO_HASH_SIZE +\
127 UDIF_CRYPTO_HASH_SIZE + \
128 UDIF_CRYPTO_HASH_SIZE + \
129 UDIF_SERIAL_NUMBER_SIZE + \
130 UDIF_ANCHOR_SEQUENCE_SIZE + \
131 UDIF_VALID_TIME_SIZE + \
132 UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER + \
133 UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER + \
134 UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER)
135
140#define UDIF_ANCHOR_SIGNING_SIZE (UDIF_CRYPTO_HASH_SIZE + \
141 UDIF_CRYPTO_HASH_SIZE + \
142 UDIF_CRYPTO_HASH_SIZE + \
143 UDIF_SERIAL_NUMBER_SIZE + \
144 UDIF_ANCHOR_SEQUENCE_SIZE + \
145 UDIF_VALID_TIME_SIZE + \
146 UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER + \
147 UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER + \
148 UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER)
149
170
191UDIF_EXPORT_API udif_errors udif_anchor_create(udif_anchor_record* anchor, const uint8_t* childser, uint64_t sequence, uint64_t timestamp,
192 const uint8_t* regroot, const uint8_t* txroot, const uint8_t* mroot, uint32_t regcount, uint32_t txcount,
193 uint32_t memcount, const uint8_t* childsigkey, bool (*rng_generate)(uint8_t*, size_t));
194
206UDIF_EXPORT_API udif_errors udif_anchor_deserialize(udif_anchor_record* anchor, const uint8_t* input, size_t inplen);
207
219
231UDIF_EXPORT_API udif_errors udif_anchor_compute_signature(udif_anchor_record* anchor, const uint8_t* sigkey, bool (*rng_generate)(uint8_t*, size_t));
232
241
253
264
276UDIF_EXPORT_API bool udif_anchor_is_fresh(const udif_anchor_record* anchor, uint64_t ctime, uint64_t maxage);
277
289UDIF_EXPORT_API udif_errors udif_anchor_serialize(uint8_t* output, size_t outlen, const udif_anchor_record* anchor);
290
303UDIF_EXPORT_API bool udif_anchor_validate_sequence(const udif_anchor_record* anchor, uint64_t expseq);
304
316UDIF_EXPORT_API bool udif_anchor_verify(const udif_anchor_record* anchor, const uint8_t* childverkey, uint64_t expseq);
317
329UDIF_EXPORT_API bool udif_anchor_verify_chain(const udif_anchor_record* prevanchor, const udif_anchor_record* nextanchor, const uint8_t* childverkey);
330
331#endif
UDIF_EXPORT_API bool udif_anchor_verify(const udif_anchor_record *anchor, const uint8_t *childverkey, uint64_t expseq)
Verify an anchor record.
Definition anchor.c:289
UDIF_EXPORT_API udif_errors udif_anchor_create(udif_anchor_record *anchor, const uint8_t *childser, uint64_t sequence, uint64_t timestamp, const uint8_t *regroot, const uint8_t *txroot, const uint8_t *mroot, uint32_t regcount, uint32_t txcount, uint32_t memcount, const uint8_t *childsigkey, bool(*rng_generate)(uint8_t *, size_t))
Create an anchor record.
Definition anchor.c:7
UDIF_EXPORT_API udif_errors udif_anchor_deserialize(udif_anchor_record *anchor, const uint8_t *input, size_t inplen)
Deserialize an anchor record.
Definition anchor.c:54
UDIF_EXPORT_API bool udif_anchor_is_fresh(const udif_anchor_record *anchor, uint64_t ctime, uint64_t maxage)
Check anchor freshness.
Definition anchor.c:210
UDIF_EXPORT_API bool udif_anchor_verify_chain(const udif_anchor_record *prevanchor, const udif_anchor_record *nextanchor, const uint8_t *childverkey)
Verify anchor chain continuity.
Definition anchor.c:334
UDIF_EXPORT_API size_t udif_anchor_encoded_size(const udif_anchor_record *anchor)
Get anchor encoded size.
Definition anchor.c:192
UDIF_EXPORT_API bool udif_anchor_validate_sequence(const udif_anchor_record *anchor, uint64_t expseq)
Validate an anchor sequence against the expected value.
Definition anchor.c:272
UDIF_EXPORT_API udif_errors udif_anchor_serialize(uint8_t *output, size_t outlen, const udif_anchor_record *anchor)
Serialize an anchor record.
Definition anchor.c:231
UDIF_EXPORT_API udif_errors udif_anchor_compute_signature(udif_anchor_record *anchor, const uint8_t *sigkey, bool(*rng_generate)(uint8_t *, size_t))
Compute object digest and signature.
Definition anchor.c:132
UDIF_EXPORT_API void udif_anchor_clear(udif_anchor_record *anchor)
Clear an anchor record.
Definition anchor.c:167
UDIF_EXPORT_API bool udif_anchor_compare(const udif_anchor_record *a, const udif_anchor_record *b)
Compare two anchor records.
Definition anchor.c:175
UDIF_EXPORT_API udif_errors udif_anchor_compute_digest(uint8_t *digest, const udif_anchor_record *anchor)
Compute anchor digest.
Definition anchor.c:95
Anchor record.
Definition anchor.h:158
uint32_t memcount
Definition anchor.h:166
uint8_t mroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:160
uint64_t timestamp
Definition anchor.h:165
uint8_t signature[UDIF_SIGNED_HASH_SIZE]
Definition anchor.h:159
uint32_t regcount
Definition anchor.h:167
uint8_t txroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:162
uint8_t childser[UDIF_SERIAL_NUMBER_SIZE]
Definition anchor.h:163
uint64_t sequence
Definition anchor.h:164
uint8_t regroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:161
uint32_t txcount
Definition anchor.h:168
UDIF Common Definitions and Protocol Configuration.
#define UDIF_SERIAL_NUMBER_SIZE
The certificate serial number field length.
Definition udif.h:546
#define UDIF_SIGNED_HASH_SIZE
The combined size of a signature and hash.
Definition udif.h:568
#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_EXPORT_API
The api export prefix.
Definition udifcommon.h:101