UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
logging.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_LOGGING_H
53#define UDIF_LOGGING_H
54
55#include "udif.h"
56
78
79
84#define UDIF_LOG_DEFAULT_CAPACITY 1024U
85
90#define UDIF_LOG_MAX_CAPACITY 10485760U
91
96#define UDIF_LOG_MAX_DATA_SIZE 65535U
97
107
125
139
152UDIF_EXPORT_API udif_errors udif_logging_initialize(udif_logging_state* log, udif_logging_type logtype, const uint8_t* ownerser, size_t capacity);
153
170UDIF_EXPORT_API udif_errors udif_logging_append(udif_logging_state* log, uint16_t eventcode, const uint8_t* subjser, uint64_t timestamp,
171 const uint8_t* data, size_t datalen, const uint8_t* sigkey, bool (*rng_generate)(uint8_t*, size_t));
172
185UDIF_EXPORT_API udif_errors udif_logging_compute_root(uint8_t* root, const udif_logging_state* log, size_t fromseq, size_t toseq);
186
199UDIF_EXPORT_API udif_errors udif_logging_generate_proof(uint8_t* proof, size_t* prooflen, const udif_logging_state* log, size_t entryseq);
200
213UDIF_EXPORT_API bool udif_logging_verify_proof(const uint8_t* proof, size_t prooflen, const uint8_t* root, const uint8_t* entrydigest);
214
227
238
249UDIF_EXPORT_API bool udif_logging_verify_entry(const udif_logging_entry* entry, const uint8_t* verkey);
250
260
272
281
290
299
311UDIF_EXPORT_API udif_errors udif_logging_entry_serialize(uint8_t* output, size_t* outlen, const udif_logging_entry* entry);
312
324UDIF_EXPORT_API udif_errors udif_logging_entry_deserialize(udif_logging_entry* entry, const uint8_t* input, size_t inlen);
325
336
347
360UDIF_EXPORT_API udif_errors udif_logging_get_statistics(const udif_logging_state* log, size_t* count, size_t* capacity, uint8_t* root);
361
362#endif
UDIF_EXPORT_API bool udif_logging_is_full(const udif_logging_state *log)
Check if log is full.
Definition logging.c:765
UDIF_EXPORT_API void udif_logging_dispose(udif_logging_state *log)
Dispose of a log.
Definition logging.c:589
UDIF_EXPORT_API udif_errors udif_logging_get_entry(udif_logging_entry *entry, const udif_logging_state *log, size_t seq)
Get log entry at sequence.
Definition logging.c:445
UDIF_EXPORT_API size_t udif_logging_get_count(const udif_logging_state *log)
Get log entry count.
Definition logging.c:464
UDIF_EXPORT_API bool udif_logging_verify_entry(const udif_logging_entry *entry, const uint8_t *verkey)
Verify log entry signature.
UDIF_EXPORT_API udif_errors udif_logging_entry_serialize(uint8_t *output, size_t *outlen, const udif_logging_entry *entry)
Serialize a log entry.
Definition logging.c:650
UDIF_EXPORT_API udif_errors udif_logging_entry_deserialize(udif_logging_entry *entry, const uint8_t *input, size_t inlen)
Deserialize a log entry.
Definition logging.c:692
UDIF_EXPORT_API bool udif_logging_verify_proof(const uint8_t *proof, size_t prooflen, const uint8_t *root, const uint8_t *entrydigest)
Verify log inclusion proof.
UDIF_EXPORT_API udif_errors udif_logging_initialize(udif_logging_state *log, udif_logging_type logtype, const uint8_t *ownerser, size_t capacity)
Initialize a log.
UDIF_EXPORT_API void udif_logging_compute_entry_digest(uint8_t *digest, const udif_logging_entry *entry)
Compute log entry digest.
UDIF_EXPORT_API void udif_logging_entry_clear(udif_logging_entry *entry)
Clear a log entry.
Definition logging.c:636
UDIF_EXPORT_API udif_errors udif_logging_append(udif_logging_state *log, uint16_t eventcode, const uint8_t *subjser, uint64_t timestamp, const uint8_t *data, size_t datalen, const uint8_t *sigkey, bool(*rng_generate)(uint8_t *, size_t))
Append an entry to the log.
UDIF_EXPORT_API udif_errors udif_logging_get_statistics(const udif_logging_state *log, size_t *count, size_t *capacity, uint8_t *root)
Get log statistics.
UDIF_EXPORT_API void udif_logging_clear(udif_logging_state *log)
Clear a log.
Definition logging.c:616
udif_logging_type
Log types.
Definition logging.h:103
@ udif_logging_membership
Definition logging.h:104
@ udif_logging_transaction
Definition logging.h:105
UDIF_EXPORT_API bool udif_logging_is_empty(const udif_logging_state *log)
Check if log is empty.
Definition logging.c:749
UDIF_EXPORT_API udif_errors udif_logging_compute_root(uint8_t *root, const udif_logging_state *log, size_t fromseq, size_t toseq)
Compute log Merkle root.
UDIF_EXPORT_API udif_errors udif_logging_resize(udif_logging_state *log, size_t capacity)
Resize log capacity.
Definition logging.c:551
UDIF_EXPORT_API udif_errors udif_logging_generate_proof(uint8_t *proof, size_t *prooflen, const udif_logging_state *log, size_t entryseq)
Generate log inclusion proof.
Definition logging.c:280
Audit log entry.
Definition logging.h:116
uint8_t digest[UDIF_CRYPTO_HASH_SIZE]
Definition logging.h:122
uint8_t subject_serial[UDIF_SERIAL_NUMBER_SIZE]
Definition logging.h:118
size_t datalen
Definition logging.h:121
uint64_t timestamp
Definition logging.h:119
uint8_t signature[UDIF_SIGNED_HASH_SIZE]
Definition logging.h:123
uint16_t event_code
Definition logging.h:117
uint8_t * data
Definition logging.h:120
Log state structure.
Definition logging.h:131
udif_logging_type type
Definition logging.h:132
size_t entry_count
Definition logging.h:135
uint8_t owner_serial[UDIF_SERIAL_NUMBER_SIZE]
Definition logging.h:133
udif_logging_entry * entries
Definition logging.h:134
size_t capacity
Definition logging.h:136
bool initialized
Definition logging.h:137
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