PQS: Post Quantum Shell Protocol 1.1.0.0a (A2)
A quantum secure secure shell protocol
pqsuser.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 PQS_USER_H
53#define PQS_USER_H
54
55#include "pqs.h"
56
61
65#define PQS_USER_DATABASE_MAGIC "PQSUSERDB1"
66
70#define PQS_USER_DEFAULT_SHELL_PROFILE "default"
71
75PQS_EXPORT_API typedef struct pqs_user_record
76{
77 char username[PQS_USERNAME_MAX];
78 char shellprofile[PQS_SHELL_PROFILE_NAME_MAX];
79 uint8_t salt[PQS_USER_SALT_SIZE];
80 uint8_t verifier[PQS_USER_VERIFIER_SIZE];
81 uint64_t created;
82 uint64_t modified;
83 uint32_t failures;
84 pqs_user_privileges privilege;
85 bool enabled;
87
91PQS_EXPORT_API typedef struct pqs_user_store
92{
93 pqs_user_record records[PQS_USER_DATABASE_MAX];
94 char path[QSC_SYSTEM_MAX_PATH];
95 size_t count;
98
109PQS_EXPORT_API bool pqs_user_store_add(pqs_user_store* store, const char* username, const char* passphrase, pqs_user_privileges privilege);
110
120PQS_EXPORT_API bool pqs_user_store_enable(pqs_user_store* store, const char* username, bool enabled);
121
130PQS_EXPORT_API const pqs_user_record* pqs_user_store_find(const pqs_user_store* store, const char* username);
131
140PQS_EXPORT_API pqs_user_record* pqs_user_store_find_mutable(pqs_user_store* store, const char* username);
141
150PQS_EXPORT_API bool pqs_user_store_initialize(pqs_user_store* store, const char* path);
151
160PQS_EXPORT_API bool pqs_user_store_remove(pqs_user_store* store, const char* username);
161
169PQS_EXPORT_API bool pqs_user_store_save(const pqs_user_store* store);
170
180PQS_EXPORT_API bool pqs_user_store_set_privilege(pqs_user_store* store, const char* username, pqs_user_privileges privilege);
181
191PQS_EXPORT_API bool pqs_user_store_set_shell_profile(pqs_user_store* store, const char* username, const char* shellprofile);
192
202PQS_EXPORT_API bool pqs_user_store_set_passphrase(pqs_user_store* store, const char* username, const char* passphrase);
203
211PQS_EXPORT_API bool pqs_user_name_is_valid(const char* username);
212
220PQS_EXPORT_API bool pqs_user_passphrase_is_valid(const char* passphrase);
221
229PQS_EXPORT_API const char* pqs_user_privilege_to_string(pqs_user_privileges privilege);
230
238PQS_EXPORT_API pqs_user_privileges pqs_user_privilege_from_string(const char* value);
239
248PQS_EXPORT_API bool pqs_user_verify_passphrase(const pqs_user_record* record, const char* passphrase);
249
259PQS_EXPORT_API bool pqs_user_verify_passphrase_timing_neutral(const pqs_user_record* record, const char* username, const char* passphrase);
260
261#endif
PQS_EXPORT_API pqs_user_privileges pqs_user_privilege_from_string(const char *value)
Convert a stable text name to a privilege level.
Definition pqsuser.c:669
PQS_EXPORT_API bool pqs_user_verify_passphrase_timing_neutral(const pqs_user_record *record, const char *username, const char *passphrase)
Verify a passphrase using a timing-neutral valid or dummy account path.
Definition pqsuser.c:722
PQS_EXPORT_API bool pqs_user_verify_passphrase(const pqs_user_record *record, const char *passphrase)
Verify a plaintext passphrase against a user record.
Definition pqsuser.c:694
PQS_EXPORT_API bool pqs_user_passphrase_is_valid(const char *passphrase)
Test whether a passphrase length is valid for a PQS account and login request.
Definition pqsuser.c:103
PQS_EXPORT_API bool pqs_user_store_set_passphrase(pqs_user_store *store, const char *username, const char *passphrase)
Set a user's passphrase verifier.
Definition pqsuser.c:617
PQS_EXPORT_API pqs_user_record * pqs_user_store_find_mutable(pqs_user_store *store, const char *username)
Find a mutable user record by name.
Definition pqsuser.c:409
PQS_EXPORT_API const pqs_user_record * pqs_user_store_find(const pqs_user_store *store, const char *username)
Find a user record by name.
Definition pqsuser.c:385
PQS_EXPORT_API bool pqs_user_store_set_privilege(pqs_user_store *store, const char *username, pqs_user_privileges privilege)
Set the user privilege level.
Definition pqsuser.c:570
PQS_EXPORT_API bool pqs_user_store_enable(pqs_user_store *store, const char *username, bool enabled)
Disable or enable a user account.
Definition pqsuser.c:359
PQS_EXPORT_API bool pqs_user_store_initialize(pqs_user_store *store, const char *path)
Initialize and load the user database.
Definition pqsuser.c:433
PQS_EXPORT_API bool pqs_user_store_save(const pqs_user_store *store)
Save the user database to disk.
Definition pqsuser.c:527
PQS_EXPORT_API bool pqs_user_name_is_valid(const char *username)
Test whether a user name is valid for a PQS account and login request.
Definition pqsuser.c:66
PQS_EXPORT_API bool pqs_user_store_set_shell_profile(pqs_user_store *store, const char *username, const char *shellprofile)
Set a user's assigned shell profile name.
Definition pqsuser.c:590
PQS_EXPORT_API bool pqs_user_store_add(pqs_user_store *store, const char *username, const char *passphrase, pqs_user_privileges privilege)
Add a user to the user database.
Definition pqsuser.c:315
PQS_EXPORT_API const char * pqs_user_privilege_to_string(pqs_user_privileges privilege)
Convert a privilege level to its stable text name.
Definition pqsuser.c:647
PQS_EXPORT_API bool pqs_user_store_remove(pqs_user_store *store, const char *username)
Remove a user from the user database.
Definition pqsuser.c:492
A PQS server user account record.
Definition pqsuser.h:76
uint32_t failures
Definition pqsuser.h:83
uint64_t created
Definition pqsuser.h:81
uint64_t modified
Definition pqsuser.h:82
uint8_t salt[PQS_USER_SALT_SIZE]
Definition pqsuser.h:79
char username[PQS_USERNAME_MAX]
Definition pqsuser.h:77
bool enabled
Definition pqsuser.h:85
pqs_user_privileges privilege
Definition pqsuser.h:84
char shellprofile[PQS_SHELL_PROFILE_NAME_MAX]
Definition pqsuser.h:78
uint8_t verifier[PQS_USER_VERIFIER_SIZE]
Definition pqsuser.h:80
The fixed-size PQS server user database.
Definition pqsuser.h:92
pqs_user_record records[PQS_USER_DATABASE_MAX]
Definition pqsuser.h:93
size_t count
Definition pqsuser.h:95
char path[QSC_SYSTEM_MAX_PATH]
Definition pqsuser.h:94
bool initialized
Definition pqsuser.h:96