QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
sphincsplus.h
Go to the documentation of this file.
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 QSC_SPHINCSPLUS_H
41#define QSC_SPHINCSPLUS_H
42
43#include "common.h"
44
45QSC_CPLUSPLUS_ENABLED_START
46
84
85#if defined(QSC_SPHINCSPLUS_S1S128SHAKERF)
86
91# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 17088
92
97# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 64
98
103# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 32
104
105#elif defined(QSC_SPHINCSPLUS_S1S128SHAKERS)
106
111# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 7856
112
117# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 64
118
123# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 32
124
125#elif defined(QSC_SPHINCSPLUS_S3S192SHAKERF)
126
131# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 35664
132
137# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 96
138
143# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 48
144#elif defined(QSC_SPHINCSPLUS_S3S192SHAKERS)
145
150# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 16224
151
156# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 96
157
162# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 48
163
164#elif defined(QSC_SPHINCSPLUS_S5S256SHAKERF)
165
170# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 49856
171
176# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 128
177
182# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 64
183
184#elif defined(QSC_SPHINCSPLUS_S5S256SHAKERS)
185
190# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 29792
191
196# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 128
197
202# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 64
203
204#elif defined(QSC_SPHINCSPLUS_S6S512SHAKERF)
205
206/* The hash is 512-bit extended */
207# define QSC_SPHINCSPLUS_EXTENDED
208
213# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 165056
214
219# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 256
220
225# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 128
226
227#elif defined(QSC_SPHINCSPLUS_S6S512SHAKERS)
228
229/* The hash is 512-bit extended */
230# define QSC_SPHINCSPLUS_EXTENDED
231
236# define QSC_SPHINCSPLUS_SIGNATURE_SIZE 113344
237
242# define QSC_SPHINCSPLUS_PRIVATEKEY_SIZE 256
243
248# define QSC_SPHINCSPLUS_PUBLICKEY_SIZE 128
249
250#else
251# error "The SPHINCS+ parameter set is invalid!"
252#endif
253
258#define QSC_SPHINCSPLUS_ALGNAME "SPHINCSPLUS"
259
269QSC_EXPORT_API void qsc_sphincsplus_generate_keypair(uint8_t* publickey, uint8_t* privatekey, bool (*rng_generate)(uint8_t*, size_t));
270
283QSC_EXPORT_API void qsc_sphincsplus_sign(uint8_t* signedmsg, size_t* smsglen, const uint8_t* message, size_t msglen, const uint8_t* privatekey, bool (*rng_generate)(uint8_t*, size_t));
284
295QSC_EXPORT_API bool qsc_sphincsplus_verify(uint8_t* message, size_t* msglen, const uint8_t* signedmsg, size_t smsglen, const uint8_t* publickey);
296
297QSC_CPLUSPLUS_ENABLED_END
298
299#endif
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
QSC_EXPORT_API void qsc_sphincsplus_sign(uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Takes the message as input and returns an array containing the signature followed by the message.
Definition sphincsplus.c:16
QSC_EXPORT_API void qsc_sphincsplus_generate_keypair(uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Generates a Sphincs+ public/private key-pair.
Definition sphincsplus.c:4
QSC_EXPORT_API bool qsc_sphincsplus_verify(uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *publickey)
Verifies a signature-message pair with the public key.
Definition sphincsplus.c:30