UDIF: Universal Digital Identification Framework 1.0.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
79
84#define UDIF_ANCHOR_INTERVAL_SEC 3600U
85
90#define UDIF_ANCHOR_MAX_AGE_MAX 7200U
91
96#define UDIF_ANCHOR_MAX_SIZE (512U + UDIF_SIGNED_HASH_SIZE)
97
102#define UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER 4U
103
108#define UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER 4U
109
114#define UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER 4U
115
120#define UDIF_ANCHOR_SEQUENCE_SIZE 8U
121
126#define UDIF_ANCHOR_RECORD_SIZE (UDIF_SIGNED_HASH_SIZE + \
127 UDIF_CRYPTO_HASH_SIZE +\
128 UDIF_CRYPTO_HASH_SIZE + \
129 UDIF_CRYPTO_HASH_SIZE + \
130 UDIF_SERIAL_NUMBER_SIZE + \
131 UDIF_ANCHOR_SEQUENCE_SIZE + \
132 UDIF_VALID_TIME_SIZE + \
133 UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER + \
134 UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER + \
135 UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER)
136
141#define UDIF_ANCHOR_SIGNING_SIZE (UDIF_CRYPTO_HASH_SIZE + \
142 UDIF_CRYPTO_HASH_SIZE + \
143 UDIF_CRYPTO_HASH_SIZE + \
144 UDIF_SERIAL_NUMBER_SIZE + \
145 UDIF_VALID_TIME_SIZE + \
146 UDIF_ANCHOR_MEMBERSHIP_EVENT_COUNTER + \
147 UDIF_ANCHOR_REGISTRY_OBJECT_COUNTER + \
148 UDIF_ANCHOR_SEQUENCE_SIZE + \
149 UDIF_ANCHOR_REGISTRY_TRANSACTION_COUNTER)
150
171
192UDIF_EXPORT_API udif_errors udif_anchor_create(udif_anchor_record* anchor, const uint8_t* childser, uint64_t sequence, uint64_t timestamp,
193 const uint8_t* regroot, const uint8_t* txroot, const uint8_t* mroot, uint32_t regcount, uint32_t txcount,
194 uint32_t memcount, const uint8_t* childsigkey, bool (*rng_generate)(uint8_t*, size_t));
195
207UDIF_EXPORT_API udif_errors udif_anchor_deserialize(udif_anchor_record* anchor, const uint8_t* input, size_t inplen);
208
220
232UDIF_EXPORT_API udif_errors udif_anchor_compute_signature(udif_anchor_record* anchor, const uint8_t* sigkey, bool (*rng_generate)(uint8_t*, size_t));
233
242
254
265
277UDIF_EXPORT_API bool udif_anchor_is_fresh(const udif_anchor_record* anchor, uint64_t ctime, uint64_t maxage);
278
290UDIF_EXPORT_API udif_errors udif_anchor_serialize(uint8_t* output, size_t outlen, const udif_anchor_record* anchor);
291
302UDIF_EXPORT_API bool udif_anchor_validate_sequence(const udif_anchor_record* anchor, uint64_t prevseq);
303
315UDIF_EXPORT_API bool udif_anchor_verify(const udif_anchor_record* anchor, const uint8_t* childverkey, uint64_t expseq);
316
328UDIF_EXPORT_API bool udif_anchor_verify_chain(const udif_anchor_record* prevanchor, const udif_anchor_record* nextanchor, const uint8_t* childverkey);
329
330#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:297
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:337
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 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 bool udif_anchor_validate_sequence(const udif_anchor_record *anchor, uint64_t prevseq)
Validate anchor sequence.
Definition anchor.c:272
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:159
uint32_t memcount
Definition anchor.h:167
uint8_t mroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:161
uint64_t timestamp
Definition anchor.h:166
uint8_t signature[UDIF_SIGNED_HASH_SIZE]
Definition anchor.h:160
uint32_t regcount
Definition anchor.h:168
uint8_t txroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:163
uint8_t childser[UDIF_SERIAL_NUMBER_SIZE]
Definition anchor.h:164
uint64_t sequence
Definition anchor.h:165
uint8_t regroot[UDIF_CRYPTO_HASH_SIZE]
Definition anchor.h:162
uint32_t txcount
Definition anchor.h:169
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
#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:628
#define UDIF_EXPORT_API
The api export prefix.
Definition udifcommon.h:103