QSC Post Quantum Cryptographic Library 1.3.0.0 (C1)
A post quantum secure library written in Ansi C
Loading...
Searching...
No Matches
tlslimits.h
Go to the documentation of this file.
1/* 2020-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 QSC_TLS_LIMITS_H
53#define QSC_TLS_LIMITS_H
54
55#include "qsccommon.h"
56#include "tlsdefs.h"
57#include "kyber.h"
58#include "dilithium.h"
59
60QSC_CPLUSPLUS_ENABLED_START
61
66
67/* Record and stream limits */
72#define QSC_TLS_MAX_RECORD_SIZE 18432U
73
78#define QSC_TLS_STREAM_BUFFER_MAX_SIZE (QSC_TLS_MAX_RECORD_SIZE * 4U)
79
84#define QSC_TLS_MAX_PLAINTEXT_SIZE 16384U
85
90#define QSC_TLS_RECORD_MAX_PLAINTEXT_SIZE QSC_TLS_MAX_PLAINTEXT_SIZE
91
96#define QSC_TLS_RECORD_MAX_INNER_SIZE (QSC_TLS_MAX_PLAINTEXT_SIZE + QSC_TLS_INNER_CONTENT_TYPE_SIZE)
97
98/* Registry and identifier limits */
103#define QSC_TLS_MAX_GROUPS 16U
104
109#define QSC_TLS_MAX_SIGNATURE_SCHEMES 24U
110
115#define QSC_TLS_MAX_CIPHER_SUITES 16U
116
121#define QSC_TLS_MAX_HOSTNAME_SIZE 255U
122
127#define QSC_TLS_MAX_ALPN_SIZE 255U
128
133#define QSC_TLS_MAX_ALPN_PROTOCOLS 8U
134
139#define QSC_TLS_MAX_SERVER_IDENTITIES 4U
140
141/* Certificate and handshake message limits */
146#define QSC_TLS_CERTIFICATE_REQUEST_CONTEXT_MAX_SIZE 255U
147
152#define QSC_TLS_CERTIFICATE_LIST_MAX_ENTRIES 8U
153
158#define QSC_TLS_CERTIFICATE_MAX_SIZE 65535U
159
164#define QSC_TLS_HANDSHAKE_FINISHED_MAX_SIZE 64U
165
170#define QSC_TLS_MAX_PSK_IDENTITIES 4U
171
176#define QSC_TLS_TICKET_MAX_SIZE 1024U
177
182#define QSC_TLS_TICKET_NONCE_MAX_SIZE 255U
183
188#define QSC_TLS_PSK_BINDER_MAX_SIZE QSC_TLS_HASH_MAX_SIZE
189
190/* Key material and algorithm-size limits */
195#define QSC_TLS_MAX_CLASSICAL_PUBLIC_KEY_SIZE 97U
196
201#define QSC_TLS_MAX_CLASSICAL_PRIVATE_KEY_SIZE 96U
202
207#define QSC_TLS_MAX_KEM_PUBLIC_KEY_SIZE QSC_KYBER_PUBLICKEY_SIZE
208
213#define QSC_TLS_MAX_KEM_PRIVATE_KEY_SIZE QSC_KYBER_PRIVATEKEY_SIZE
214
219#define QSC_TLS_MAX_KEM_CIPHERTEXT_SIZE QSC_KYBER_CIPHERTEXT_SIZE
220
225#define QSC_TLS_MAX_KEM_SHARED_SECRET_SIZE QSC_KYBER_SHAREDSECRET_SIZE
226
231#define QSC_TLS_MAX_HYBRID_CLIENT_KEYSHARE_SIZE (QSC_TLS_MAX_CLASSICAL_PUBLIC_KEY_SIZE + QSC_TLS_MAX_KEM_PUBLIC_KEY_SIZE)
232
237#define QSC_TLS_MAX_HYBRID_SERVER_KEYSHARE_SIZE (QSC_TLS_MAX_CLASSICAL_PUBLIC_KEY_SIZE + QSC_TLS_MAX_KEM_CIPHERTEXT_SIZE)
238
243#define QSC_TLS_MAX_PRIVATE_KEY_SIZE (QSC_TLS_MAX_CLASSICAL_PRIVATE_KEY_SIZE + QSC_TLS_MAX_KEM_PRIVATE_KEY_SIZE)
244
249#define QSC_TLS_MAX_SHARED_SECRET_SIZE (48U + QSC_TLS_MAX_KEM_SHARED_SECRET_SIZE)
250
255#define QSC_TLS_CERTIFICATE_VERIFY_MAX_SIGNATURE_SIZE QSC_DILITHIUM_SIGNATURE_SIZE
256
264#define QSC_TLS_MAX_SIGNING_PRIVATE_KEY_SIZE 4896U
265
270#define QSC_TLS_MAX_KEYSHARE_SIZE QSC_TLS_MAX_HYBRID_CLIENT_KEYSHARE_SIZE
271
276#define QSC_TLS_KEY_SHARE_MAX_SIZE QSC_TLS_MAX_KEYSHARE_SIZE
277
278/* Extension and hello size limits */
283#define QSC_TLS_MAX_EXTENSION_SIZE (64U + QSC_TLS_MAX_HYBRID_CLIENT_KEYSHARE_SIZE + (QSC_TLS_MAX_GROUPS * sizeof(uint16_t)) + (QSC_TLS_MAX_SIGNATURE_SCHEMES * sizeof(uint16_t)))
284
289#define QSC_TLS_SUPPORTED_VERSIONS_CLIENT_EXTENSION_SIZE 7U
290
295#define QSC_TLS_SUPPORTED_VERSIONS_SERVER_EXTENSION_SIZE 6U
296
301#define QSC_TLS_SUPPORTED_GROUPS_EXTENSION_MAX_SIZE (6U + (QSC_TLS_MAX_GROUPS * sizeof(uint16_t)))
302
307#define QSC_TLS_SIGNATURE_ALGORITHMS_EXTENSION_MAX_SIZE (6U + (QSC_TLS_MAX_SIGNATURE_SCHEMES * sizeof(uint16_t)))
308
313#define QSC_TLS_KEY_SHARE_CLIENT_EXTENSION_MAX_SIZE (8U + QSC_TLS_MAX_KEYSHARE_SIZE)
314
319#define QSC_TLS_KEY_SHARE_SERVER_EXTENSION_MAX_SIZE (8U + QSC_TLS_MAX_HYBRID_SERVER_KEYSHARE_SIZE)
320
325#define QSC_TLS_CLIENT_HELLO_EXTENSIONS_MAX_SIZE (QSC_TLS_SUPPORTED_VERSIONS_CLIENT_EXTENSION_SIZE + QSC_TLS_SUPPORTED_GROUPS_EXTENSION_MAX_SIZE + QSC_TLS_SIGNATURE_ALGORITHMS_EXTENSION_MAX_SIZE + QSC_TLS_KEY_SHARE_CLIENT_EXTENSION_MAX_SIZE)
326
331#define QSC_TLS_CLIENT_HELLO_BODY_MAX_SIZE (43U + QSC_TLS_CLIENT_HELLO_EXTENSIONS_MAX_SIZE)
332
337#define QSC_TLS_SERVER_HELLO_EXTENSIONS_MAX_SIZE (QSC_TLS_SUPPORTED_VERSIONS_SERVER_EXTENSION_SIZE + QSC_TLS_KEY_SHARE_SERVER_EXTENSION_MAX_SIZE)
338
343#define QSC_TLS_SERVER_HELLO_BODY_MAX_SIZE (72U + QSC_TLS_SERVER_HELLO_EXTENSIONS_MAX_SIZE)
344
345/* HKDF label limits */
350#define QSC_TLS_HKDF_LABEL_MAX_WIRE_SIZE (2U + 1U + (QSC_TLS_HKDF_LABEL_PREFIX_SIZE + QSC_TLS_LABEL_MAX_SIZE) + 1U + QSC_TLS_CONTEXT_MAX_SIZE)
351
352typedef char qsc_tls_limit_assert_keyshare[(QSC_TLS_MAX_KEYSHARE_SIZE >= QSC_TLS_MAX_HYBRID_CLIENT_KEYSHARE_SIZE) ? 1 : -1];
353typedef char qsc_tls_limit_assert_extension[(QSC_TLS_MAX_EXTENSION_SIZE >= QSC_TLS_CLIENT_HELLO_EXTENSIONS_MAX_SIZE) ? 1 : -1];
354typedef char qsc_tls_limit_assert_client_hello[(QSC_TLS_CLIENT_HELLO_BODY_MAX_SIZE >= (43U + QSC_TLS_KEY_SHARE_CLIENT_EXTENSION_MAX_SIZE)) ? 1 : -1];
355typedef char qsc_tls_limit_assert_server_hello[(QSC_TLS_SERVER_HELLO_BODY_MAX_SIZE >= (72U + QSC_TLS_KEY_SHARE_SERVER_EXTENSION_MAX_SIZE)) ? 1 : -1];
356typedef char qsc_tls_limit_assert_private[(QSC_TLS_MAX_PRIVATE_KEY_SIZE >= (QSC_TLS_MAX_CLASSICAL_PRIVATE_KEY_SIZE + QSC_TLS_MAX_KEM_PRIVATE_KEY_SIZE)) ? 1 : -1];
357typedef char qsc_tls_limit_assert_signature[(QSC_TLS_CERTIFICATE_VERIFY_MAX_SIGNATURE_SIZE >= QSC_DILITHIUM_SIGNATURE_SIZE) ? 1 : -1];
358typedef char qsc_tls_limit_assert_ciphersuites[(QSC_TLS_MAX_CIPHER_SUITES >= 3U) ? 1 : -1];
359
360QSC_CPLUSPLUS_ENABLED_END
361
362#endif
Contains the primary public API for the Dilithium asymmetric signature scheme implementation.
#define QSC_DILITHIUM_SIGNATURE_SIZE
The byte size of the signature array.
Definition dilithium.h:148
Contains the public API for the FIPS 203 implementation of the Kyber CCA-secure Key Encapsulation Mec...
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
Defines fixed TLS protocol constants and HKDF label constants.
#define QSC_TLS_MAX_CIPHER_SUITES
Maximum number of cipher suites tracked or advertised by the TLS layer.
Definition tlslimits.h:115
#define QSC_TLS_MAX_HYBRID_CLIENT_KEYSHARE_SIZE
Maximum hybrid client key-share size in bytes.
Definition tlslimits.h:231
#define QSC_TLS_CLIENT_HELLO_EXTENSIONS_MAX_SIZE
Maximum encoded ClientHello extension block size excluding the outer vector16 header.
Definition tlslimits.h:325
#define QSC_TLS_MAX_KEYSHARE_SIZE
Maximum encoded client key-share size in bytes.
Definition tlslimits.h:270
#define QSC_TLS_SERVER_HELLO_BODY_MAX_SIZE
Maximum encoded ServerHello body size for the current TLS scaffolding.
Definition tlslimits.h:343
#define QSC_TLS_CERTIFICATE_VERIFY_MAX_SIGNATURE_SIZE
Maximum CertificateVerify signature size in bytes across the registered signature schemes.
Definition tlslimits.h:255
#define QSC_TLS_MAX_PRIVATE_KEY_SIZE
Maximum stored private-key state across the current named groups.
Definition tlslimits.h:243
#define QSC_TLS_KEY_SHARE_CLIENT_EXTENSION_MAX_SIZE
Maximum encoded key_share extension size in bytes for ClientHello.
Definition tlslimits.h:313
#define QSC_TLS_MAX_KEM_PRIVATE_KEY_SIZE
Maximum KEM private-key size exposed by the TLS registry.
Definition tlslimits.h:213
#define QSC_TLS_CLIENT_HELLO_BODY_MAX_SIZE
Maximum encoded ClientHello body size for the current TLS scaffolding.
Definition tlslimits.h:331
#define QSC_TLS_KEY_SHARE_SERVER_EXTENSION_MAX_SIZE
Maximum encoded key_share extension size in bytes for ServerHello.
Definition tlslimits.h:319
#define QSC_TLS_MAX_EXTENSION_SIZE
Maximum size of an encoded extension block in bytes for the current ClientHello scaffolding.
Definition tlslimits.h:283
#define QSC_TLS_MAX_CLASSICAL_PRIVATE_KEY_SIZE
Maximum classical named-group private-key state size exposed by the TLS registry.
Definition tlslimits.h:201