UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
udifcommon.h
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: This software and all accompanying materials are the exclusive
5 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
6 * The intellectual and technical concepts contained within this implementation
7 * are proprietary to QRCS and its authorized licensors and are protected under
8 * applicable U.S. and international copyright, patent, and trade secret laws.
9 *
10 * CRYPTOGRAPHIC STANDARDS:
11 * - This software includes implementations of cryptographic algorithms such as
12 * SHA3, AES, and others. These algorithms are public domain or standardized
13 * by organizations such as NIST and are NOT the property of QRCS.
14 * - However, all source code, optimizations, and implementations in this library
15 * are original works of QRCS and are protected under this license.
16 *
17 * RESTRICTIONS:
18 * - Redistribution, modification, or unauthorized distribution of this software,
19 * in whole or in part, is strictly prohibited.
20 * - This software is provided for non-commercial, educational, and research
21 * purposes only. Commercial use in any form is expressly forbidden.
22 * - Licensing and authorized distribution are solely at the discretion of QRCS.
23 * - Any use of this software implies acceptance of these restrictions.
24 *
25 * DISCLAIMER:
26 * This software is provided "as is," without warranty of any kind, express or
27 * implied, including but not limited to warranties of merchantability or fitness
28 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
29 * incidental, or consequential damages resulting from the use or misuse of this software.
30 *
31 * FULL LICENSE:
32 * This software is subject to the **Quantum Resistant Cryptographic Solutions
33 * Proprietary License (QRCS-PL)**. The complete license terms are included
34 * in the LICENSE.txt file distributed with this software.
35 *
36 * Written by: John G. Underhill
37 * Contact: contact@qrcscorp.ca
38 */
39
40#ifndef UDIF_COMMON_H
41#define UDIF_COMMON_H
42
43#include <errno.h>
44#include <stdbool.h>
45#include <stdint.h>
46#include <limits.h>
47#include <string.h>
48#include "qsccommon.h"
49#include "intrinsics.h"
50
57
58static const char UDIF_DEFAULT_APP_PATH[] = "C:\\";
59static const char UDIF_LOG_FILENAME[] = "\\userlog.mlog";
60
62/* application constants */
63#define UDIF_CRYPTO_PASSWORD_HASH 32U
64#define UDIF_DEFAULT_AUTH_RETRIES 3U
65#define UDIF_DEFAULT_PORT 8022U
66#define UDIF_DEFAULT_SESSION_TIMEOUT 5U
67#define UDIF_STORAGE_ADDRESS_MIN 7U
68#define UDIF_STORAGE_ADDRESS_MAX 65U
69#define UDIF_STORAGE_ASSOCIATION_HOSTS_MAX 16U
70#define UDIF_STORAGE_CERTIFICATE_NAME 128U
71#define UDIF_STORAGE_DEVICENAME_MAX 16U
72#define UDIF_STORAGE_DEVICENAME_MIN 2U
73#define UDIF_STORAGE_DOMAINNAME_MAX 260U
74#define UDIF_STORAGE_DOMAINNAME_MIN 2U
75#define UDIF_STORAGE_FILEPATH_MAX 256U
76#define UDIF_STORAGE_FILEPATH_MIN 8U
77#define UDIF_STORAGE_HOSTNAME_MIN 2U
78#define UDIF_STORAGE_HOSTNAME_MAX 128U
79#define UDIF_STORAGE_INPUT_MAX 256U
80#define UDIF_STORAGE_MAC_SIZE 32U
81#define UDIF_STORAGE_MAX_PATH 260U
82#define UDIF_STORAGE_MESSAGE_MAX 8192U
83#define UDIF_STORAGE_PASSWORD_MAX 256U
84#define UDIF_STORAGE_PASSWORD_MIN 8U
85#define UDIF_STORAGE_PASSWORD_RETRY 3U
86#define UDIF_STORAGE_PATH_MAX 260U
87#define UDIF_STORAGE_PROMPT_MAX 64U
88#define UDIF_STORAGE_RETRIES_MIN 1U
89#define UDIF_STORAGE_RETRIES_MAX 5U
90#define UDIF_STORAGE_SERVER_PAUSE_INTERVAL 250U
91#define UDIF_STORAGE_TIMEOUT_MIN 1U
92#define UDIF_STORAGE_TIMEOUT_MAX 60U
93#define UDIF_STORAGE_USERNAME_MAX 128U
94#define UDIF_STORAGE_USERNAME_MIN 6U
95#define UDIF_STORAGE_USERNAME_RETRY 3U
96
101#define UDIF_CONFIG_DILITHIUM_KYBER
102
107#if defined(_DLL)
108# define UDIF_DLL_API
109#endif
114#if defined(UDIF_DLL_API)
115# if defined(QSC_SYSTEM_COMPILER_MSC)
116# if defined(QSC_DLL_IMPORT)
117# define UDIF_EXPORT_API __declspec(dllimport)
118# else
119# define UDIF_EXPORT_API __declspec(dllexport)
120# endif
121# elif defined(QSC_SYSTEM_COMPILER_GCC)
122# if defined(QSC_DLL_IMPORT)
123# define UDIF_EXPORT_API __attribute__((dllimport))
124# else
125# define UDIF_EXPORT_API __attribute__((dllexport))
126# endif
127# else
128# if defined(__SUNPRO_C)
129# if !defined(__GNU_C__)
130# define UDIF_EXPORT_API __attribute__ (visibility(__global))
131# else
132# define UDIF_EXPORT_API __attribute__ __global
133# endif
134# elif defined(_MSG_VER)
135# define UDIF_EXPORT_API extern __declspec(dllexport)
136# else
137# define UDIF_EXPORT_API __attribute__ ((visibility ("default")))
138# endif
139# endif
140#else
141# define UDIF_EXPORT_API
142#endif
143
144#if defined(DEBUG) || defined(_DEBUG) || defined(__DEBUG__) || (defined(__GNUC__) && !defined(__OPTIMIZE__))
149# define UDIF_DEBUG_MODE
150#endif
151
152#ifdef UDIF_DEBUG_MODE
157# define UDIF_ASSERT(expr) assert(expr)
158#else
159# define UDIF_ASSERT(expr) ((void)0)
160#endif
161
163
164#endif