MPDC: Multi Party Domain Cryptosystem 1.0.0.0b (A0)
MPDC Interior protocol
common.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: john.underhill@protonmail.com
38 */
39
40#ifndef MPDC_COMMON_H
41#define MPDC_COMMON_H
42
43#include <assert.h>
44#include <errno.h>
45#include <stdbool.h>
46#include <stdint.h>
47#include <limits.h>
48#include <string.h>
49#include "../../QSC/QSC/common.h"
50
56
61#define MPDC_CONFIG_DILITHIUM_KYBER
62
68#if !defined(MPDC_CONFIG_DILITHIUM_KYBER)
69# define MPDC_CONFIG_SPHINCS_MCELIECE
70#endif
71
72#if defined(DEBUG) || defined(_DEBUG) || defined(__DEBUG__) || (defined(__GNUC__) && !defined(__OPTIMIZE__))
77# define MPDC_COMPILE_DEBUG_MODE
78#endif
79
84#if defined(MPDC_COMPILE_DEBUG_MODE)
85//# define MPDC_DEBUG_TESTS_RUN
86#endif
87
88/* application constants */
89#define MPDC_CRYPTO_PASSWORD_HASH 32
90#define MPDC_DEFAULT_AUTH_RETRIES 3
91#define MPDC_DEFAULT_PORT 8022
92#define MPDC_DEFAULT_SESSION_TIMEOUT 5
93#define MPDC_STORAGE_ADDRESS_MIN 7
94#define MPDC_STORAGE_ADDRESS_MAX 65
95#define MPDC_STORAGE_ASSOCIATION_HOSTS_MAX 16
96#define MPDC_STORAGE_CERTIFICATE_NAME 128
97#define MPDC_STORAGE_DEVICENAME_MAX 16
98#define MPDC_STORAGE_DEVICENAME_MIN 2
99#define MPDC_STORAGE_DOMAINNAME_MAX 260
100#define MPDC_STORAGE_DOMAINNAME_MIN 2
101#define MPDC_STORAGE_FILEPATH_MAX 256
102#define MPDC_STORAGE_FILEPATH_MIN 8
103#define MPDC_STORAGE_HOSTNAME_MIN 2
104#define MPDC_STORAGE_HOSTNAME_MAX 128
105#define MPDC_STORAGE_INPUT_MAX 256
106#define MPDC_STORAGE_MAC_SIZE 32
107#define MPDC_STORAGE_MAX_PATH 260
108#define MPDC_STORAGE_MESSAGE_MAX 8192
109#define MPDC_STORAGE_PASSWORD_MAX 256
110#define MPDC_STORAGE_PASSWORD_MIN 8
111#define MPDC_STORAGE_PASSWORD_RETRY 3
112#define MPDC_STORAGE_PATH_MAX 260
113#define MPDC_STORAGE_PROMPT_MAX 64
114#define MPDC_STORAGE_RETRIES_MIN 1
115#define MPDC_STORAGE_RETRIES_MAX 5
116#define MPDC_STORAGE_SERVER_PAUSE_INTERVAL 250
117#define MPDC_STORAGE_TIMEOUT_MIN 1
118#define MPDC_STORAGE_TIMEOUT_MAX 60
119#define MPDC_STORAGE_USERNAME_MAX 128
120#define MPDC_STORAGE_USERNAME_MIN 6
121#define MPDC_STORAGE_USERNAME_RETRY 3
122
127#if defined(_DLL)
128# define MPDC_DLL_API
129#endif
130
135#if defined(MPDC_DLL_API)
136# if defined(QSC_SYSTEM_COMPILER_MSC)
137# if defined(MPDC_DLL_IMPORT)
138# define MPDC_EXPORT_API __declspec(dllimport)
139# else
140# define MPDC_EXPORT_API __declspec(dllexport)
141# endif
142# elif defined(QSC_SYSTEM_COMPILER_GCC)
143# if defined(MPDC_DLL_IMPORT)
144# define MPDC_EXPORT_API __attribute__((dllimport))
145# else
146# define MPDC_EXPORT_API __attribute__((dllexport))
147# endif
148# else
149# if defined(__SUNPRO_C)
150# if !defined(__GNU_C__)
151# define MPDC_EXPORT_API __attribute__ (visibility(__global))
152# else
153# define MPDC_EXPORT_API __attribute__ __global
154# endif
155# elif defined(_MSG_VER)
156# define MPDC_EXPORT_API extern __declspec(dllexport)
157# else
158# define MPDC_EXPORT_API __attribute__ ((visibility ("default")))
159# endif
160# endif
161#else
162# define MPDC_EXPORT_API
163#endif
164
165static const char MPDC_DEFAULT_APP_PATH[] = "C:\\";
166static const char MPDC_LOG_FILENAME[] = "\\userlog.mlog";
167
168#endif