UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
storage.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_STORAGE_H
53#define UDIF_STORAGE_H
54
55#include "udifcommon.h"
56#include "udif.h"
57#include "fileutils.h"
58
90
95#define UDIF_STORAGE_MAX_PATH 512U
96
101#define UDIF_STORAGE_MAX_HANDLES 16U
102
113
125
141
154
165
176
185
200UDIF_EXPORT_API bool udif_storage_write(void* context, const uint8_t* loc, size_t loclen, const uint8_t* data, size_t datalen);
201
216UDIF_EXPORT_API bool udif_storage_read(void* context, const uint8_t* loc, size_t loclen, uint8_t* data, size_t datalen, size_t* outread);
217
233UDIF_EXPORT_API bool udif_storage_append(void* context, const uint8_t* loc, size_t loclen, const uint8_t* data, size_t datalen, uint64_t* outpos);
234
247UDIF_EXPORT_API bool udif_storage_size(void* context, const uint8_t* loc, size_t loclen, uint64_t* outlen);
248
260UDIF_EXPORT_API bool udif_storage_flush(void* context, const uint8_t* loc, size_t loclen);
261
262/* === Internal Helper Functions === */
263
278bool udif_storage_resolve_path(const udif_storage_context* ctx, const uint8_t* loc, size_t loclen, char* outpath, size_t outpathlen);
279
289bool udif_storage_mkdir_recursive(const char* path);
290
304bool udif_storage_get_handle(udif_storage_context* ctx, const char* path, qsc_fileutils_mode mode, FILE** outfp);
305
314void udif_storage_evict_handle(udif_storage_context* ctx, const char* path);
315
324
325#endif /* UDIF_STORAGE_H */
UDIF_EXPORT_API void udif_storage_set_ledger(udif_storage_context *ctx, udif_ledger_type ledgertype)
Set active ledger namespace.
Definition storage.c:294
#define UDIF_STORAGE_MAX_PATH
Maximum file path length.
Definition storage.h:95
UDIF_EXPORT_API bool udif_storage_flush(void *context, const uint8_t *loc, size_t loclen)
Flush buffered data.
Definition storage.c:493
UDIF_EXPORT_API void udif_storage_dispose(udif_storage_context *ctx)
Dispose storage context.
Definition storage.c:326
void udif_storage_evict_handle(udif_storage_context *ctx, const char *path)
Close and evict a cached handle.
Definition storage.c:147
UDIF_EXPORT_API void udif_storage_get_callbacks(udif_storage_context *ctx, void *callbacks)
Get MCEL store callbacks for this context.
Definition storage.c:306
bool udif_storage_resolve_path(const udif_storage_context *ctx, const uint8_t *loc, size_t loclen, char *outpath, size_t outpathlen)
Resolve logical location to file path.
Definition storage.c:25
udif_ledger_type
Ledger namespace identifiers.
Definition storage.h:108
@ UDIF_LEDGER_MEMBERSHIP
Definition storage.h:109
@ UDIF_LEDGER_TRANSACTION
Definition storage.h:110
@ UDIF_LEDGER_REGISTRY
Definition storage.h:111
UDIF_EXPORT_API bool udif_storage_write(void *context, const uint8_t *loc, size_t loclen, const uint8_t *data, size_t datalen)
Write complete object to storage.
Definition storage.c:337
bool udif_storage_mkdir_recursive(const char *path)
Create directory recursively.
UDIF_EXPORT_API bool udif_storage_append(void *context, const uint8_t *loc, size_t loclen, const uint8_t *data, size_t datalen, uint64_t *outpos)
Append data to append-only object.
Definition storage.c:417
UDIF_EXPORT_API udif_errors udif_storage_initialize(udif_storage_context *ctx, const char *basepath)
Initialize storage context.
Definition storage.c:216
UDIF_EXPORT_API bool udif_storage_size(void *context, const uint8_t *loc, size_t loclen, uint64_t *outlen)
Get object size.
Definition storage.c:463
void udif_storage_close_all_handles(udif_storage_context *ctx)
Close all cached handles.
Definition storage.c:170
UDIF_EXPORT_API bool udif_storage_read(void *context, const uint8_t *loc, size_t loclen, uint8_t *data, size_t datalen, size_t *outread)
Read complete object from storage.
Definition storage.c:382
bool udif_storage_get_handle(udif_storage_context *ctx, const char *path, qsc_fileutils_mode mode, FILE **outfp)
Get or open cached file handle.
Definition storage.c:56
#define UDIF_STORAGE_MAX_HANDLES
Maximum number of cached file handles.
Definition storage.h:101
Cached file handle with metadata.
Definition storage.h:119
uint64_t lastaccess
Definition storage.h:122
bool isopen
Definition storage.h:123
char path[UDIF_STORAGE_MAX_PATH]
Definition storage.h:121
FILE * fp
Definition storage.h:120
File-based storage context for MCEL integration.
Definition storage.h:134
udif_ledger_type currentledger
Definition storage.h:138
char basepath[UDIF_STORAGE_MAX_PATH]
Definition storage.h:135
udif_file_handle handles[UDIF_STORAGE_MAX_HANDLES]
Definition storage.h:136
bool initialized
Definition storage.h:139
size_t handlecount
Definition storage.h:137
UDIF Common Definitions and Protocol Configuration.
udif_errors
UDIF error codes.
Definition udif.h:628
UDIF common definitions and constants.
#define UDIF_EXPORT_API
The api export prefix.
Definition udifcommon.h:103