PQS: Post Quantum Shell Protocol 1.1.0.0a (A2)
A quantum secure secure shell protocol
pqscommon.h
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 PQS_MASTER_COMMON_H
53#define PQS_MASTER_COMMON_H
54
55#include "qsccommon.h"
56#include <assert.h>
57#include <errno.h>
58#include <stdbool.h>
59#include <stddef.h>
60#include <stdint.h>
61#include <string.h>
62
69
71
76#if defined(_DLL)
77# define PQS_DLL_API
78#endif
83#if defined(PQS_DLL_API)
84# if defined(QSC_SYSTEM_COMPILER_MSC)
85# if defined(PQS_DLL_IMPORT)
86# define PQS_EXPORT_API __declspec(dllimport)
87# else
88# define PQS_EXPORT_API __declspec(dllexport)
89# endif
90# elif defined(QSC_SYSTEM_COMPILER_GCC)
91# if defined(PQS_DLL_IMPORT)
92# define PQS_EXPORT_API __attribute__((dllimport))
93# else
94# define PQS_EXPORT_API __attribute__((dllexport))
95# endif
96# else
97# if defined(__SUNPRO_C)
98# if !defined(__GNU_C__)
99# define PQS_EXPORT_API __attribute__ (visibility(__global))
100# else
101# define PQS_EXPORT_API __attribute__ __global
102# endif
103# elif defined(_MSG_VER)
104# define PQS_EXPORT_API extern __declspec(dllexport)
105# else
106# define PQS_EXPORT_API __attribute__ ((visibility ("default")))
107# endif
108# endif
109#else
110# define PQS_EXPORT_API
111#endif
112
113#if defined(DEBUG) || defined(_DEBUG) || defined(__DEBUG__) || (defined(__GNUC__) && !defined(__OPTIMIZE__))
118# define PQS_DEBUG_MODE
119#endif
120
121#ifdef PQS_DEBUG_MODE
126# define PQS_ASSERT(expr) assert(expr)
127#else
128# define PQS_ASSERT(expr) ((void)0)
129#endif
130
132
137#define PQS_STRING_TERMINATOR_SIZE 1U
138
143#define PQS_MINIMUM_MESSAGE_SIZE 1U
144
149#define PQS_APPLICATION_MESSAGE_TYPE_SIZE 1U
150
155#define PQS_APPLICATION_MESSAGE_HEADER_SIZE PQS_APPLICATION_MESSAGE_TYPE_SIZE
156
157#ifndef PQS_SERVER_COMMAND_MAX
162# define PQS_SERVER_COMMAND_MAX 1280U
163#endif
164
165#ifndef PQS_SERVER_COMMAND_TEXT_MAX
170# define PQS_SERVER_COMMAND_TEXT_MAX (PQS_SERVER_COMMAND_MAX - PQS_STRING_TERMINATOR_SIZE)
171#endif
172
173#ifndef PQS_INTERPRETER_COMMAND_BUFFER_SIZE
178# define PQS_INTERPRETER_COMMAND_BUFFER_SIZE 128U
179#endif
180
185#define PQS_XFER_PATH_MAX 256U
186
191#define PQS_XFER_CHUNK_SIZE 512U
192
197#define PQS_XFER_LIST_BUFFER_SIZE 4096U
198
203#define PQS_XFER_HASH_SIZE 32U
204
209#define PQS_XFER_HASH_TEXT_SIZE ((PQS_XFER_HASH_SIZE * 2U) + PQS_STRING_TERMINATOR_SIZE)
210
215#define PQS_XFER_METADATA_MAX 512U
216
221#define PQS_XFER_USERS_ROOT_NAME "users"
222
227#define PQS_XFER_RECURSIVE_PREFIX "-r"
228
233#define PQS_XFER_RECURSION_MAX 64U
234
239#define PQS_USERNAME_MAX 64U
240
245#define PQS_USERNAME_TEXT_MAX (PQS_USERNAME_MAX - PQS_STRING_TERMINATOR_SIZE)
246
251#define PQS_SHELL_PROFILE_NAME_MAX 64U
252
257#define PQS_SHELL_PROFILE_TEXT_MAX (PQS_SHELL_PROFILE_NAME_MAX - PQS_STRING_TERMINATOR_SIZE)
258
263#define PQS_PASSPHRASE_MIN 8U
264
269#define PQS_PASSPHRASE_MAX 128U
270
275#define PQS_PASSPHRASE_TEXT_MAX (PQS_PASSPHRASE_MAX - PQS_STRING_TERMINATOR_SIZE)
276
281#define PQS_LOGIN_REQUEST_PAYLOAD_SIZE (PQS_USERNAME_MAX + PQS_PASSPHRASE_MAX)
282
287#define PQS_LOGIN_REQUEST_MESSAGE_SIZE (PQS_APPLICATION_MESSAGE_HEADER_SIZE + PQS_LOGIN_REQUEST_PAYLOAD_SIZE)
288
293#define PQS_USER_SALT_SIZE 32U
294
299#define PQS_USER_VERIFIER_SIZE 32U
300
305#define PQS_USER_DATABASE_MAX 128U
306
311#define PQS_USER_DATABASE_VERSION 2U
312
317#define PQS_SHELL_PROFILE_DATABASE_MAX 32U
318
323#define PQS_SHELL_PROFILE_PATH_MAX QSC_SYSTEM_MAX_PATH
324
329#define PQS_SHELL_PROFILE_TYPE_MAX 24U
330
335#define PQS_SHELL_PROFILE_TYPE_TEXT_MAX (PQS_SHELL_PROFILE_TYPE_MAX - PQS_STRING_TERMINATOR_SIZE)
336
341#define PQS_POLICY_DATABASE_MAX 64U
342
347#define PQS_POLICY_NAME_MAX 64U
348
353#define PQS_POLICY_NAME_TEXT_MAX (PQS_POLICY_NAME_MAX - PQS_STRING_TERMINATOR_SIZE)
354
359#define PQS_POLICY_COMMAND_MAX 64U
360
365#define PQS_POLICY_COMMAND_TEXT_MAX (PQS_POLICY_COMMAND_MAX - PQS_STRING_TERMINATOR_SIZE)
366
371#define PQS_POLICY_COMMAND_LIST_MAX 768U
372
373#endif