QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
dilithium.h
Go to the documentation of this file.
1/*
2 * 2025 Quantum Resistant Cryptographic Solutions Corporation
3 * All Rights Reserved.
4 *
5 * NOTICE: This software and all accompanying materials are the exclusive
6 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
7 * The intellectual and technical concepts contained within this implementation
8 * are proprietary to QRCS and its authorized licensors and are protected under
9 * applicable U.S. and international copyright, patent, and trade secret laws.
10 *
11 * CRYPTOGRAPHIC STANDARDS:
12 * - This software includes implementations of cryptographic algorithms such as
13 * SHA3, AES, and others. These algorithms are public domain or standardized
14 * by organizations such as NIST and are NOT the property of QRCS.
15 * - However, all source code, optimizations, and implementations in this library
16 * are original works of QRCS and are protected under this license.
17 *
18 * RESTRICTIONS:
19 * - Redistribution, modification, or unauthorized distribution of this software,
20 * in whole or in part, is strictly prohibited.
21 * - This software is provided for non-commercial, educational, and research
22 * purposes only. Commercial use in any form is expressly forbidden.
23 * - Licensing and authorized distribution are solely at the discretion of QRCS.
24 * - Any use of this software implies acceptance of these restrictions.
25 *
26 * DISCLAIMER:
27 * This software is provided "as is," without warranty of any kind, express or
28 * implied, including but not limited to warranties of merchantability or fitness
29 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
30 * incidental, or consequential damages resulting from the use or misuse of this software.
31 *
32 * FULL LICENSE:
33 * This software is subject to the **Quantum Resistant Cryptographic Solutions
34 * Proprietary License (QRCS-PL)**. The complete license terms are included
35 * in the LICENSE.txt file distributed with this software.
36 *
37 * Written by: John G. Underhill
38 * Contact: john.underhill@protonmail.com
39 */
40
41#ifndef QSC_DILITHIUM_H
42#define QSC_DILITHIUM_H
43
44#include "common.h"
45
46QSC_CPLUSPLUS_ENABLED_START
47
86
87#if defined(QSC_DILITHIUM_S1P2544)
88
93# define QSC_DILITHIUM_PRIVATEKEY_SIZE 2560
94
99# define QSC_DILITHIUM_PUBLICKEY_SIZE 1312
100
105# define QSC_DILITHIUM_SIGNATURE_SIZE 2420
106
107#elif defined(QSC_DILITHIUM_S3P4016)
108
113# define QSC_DILITHIUM_PRIVATEKEY_SIZE 4032
114
119# define QSC_DILITHIUM_PUBLICKEY_SIZE 1952
120
125# define QSC_DILITHIUM_SIGNATURE_SIZE 3309
126
127#elif defined(QSC_DILITHIUM_S5P4880)
128
133# define QSC_DILITHIUM_PRIVATEKEY_SIZE 4896
134
139# define QSC_DILITHIUM_PUBLICKEY_SIZE 2592
140
145# define QSC_DILITHIUM_SIGNATURE_SIZE 4627
146
147#else
148# error "The Dilithium parameter set is invalid!"
149#endif
150
155#define QSC_DILITHIUM_ALGNAME "DILITHIUM"
156
158// * \def QSC_DILITHIUM_RANDOMIZED_SIGNING
159// * \brief Enables randomized signing.
160// */
161//#define QSC_DILITHIUM_RANDOMIZED_SIGNING
162
172QSC_EXPORT_API void qsc_dilithium_generate_keypair(uint8_t* publickey, uint8_t* privatekey, bool (*rng_generate)(uint8_t*, size_t));
173
186QSC_EXPORT_API void qsc_dilithium_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));
187
202QSC_EXPORT_API void qsc_dilithium_sign_ex(uint8_t* signedmsg, size_t* smsglen, const uint8_t* message, size_t msglen, const uint8_t* context, size_t contextlen, const uint8_t* privatekey, bool (*rng_generate)(uint8_t*, size_t));
203
215QSC_EXPORT_API bool qsc_dilithium_verify(uint8_t* message, size_t* msglen, const uint8_t* signedmsg, size_t smsglen, const uint8_t* publickey);
216
230QSC_EXPORT_API bool qsc_dilithium_verify_ex(uint8_t* message, size_t* msglen, const uint8_t* signedmsg, size_t smsglen, const uint8_t* context, size_t contextlen, const uint8_t* publickey);
231
232QSC_CPLUSPLUS_ENABLED_END
233
234#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 bool qsc_dilithium_verify_ex(uint8_t *message, size_t *msglen, const uint8_t *signedmsg, size_t smsglen, const uint8_t *context, size_t contextlen, const uint8_t *publickey)
Verifies a signature-message pair with the public key.
Definition dilithium.c:70
QSC_EXPORT_API bool qsc_dilithium_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 dilithium.c:52
QSC_EXPORT_API void qsc_dilithium_sign_ex(uint8_t *signedmsg, size_t *smsglen, const uint8_t *message, size_t msglen, const uint8_t *context, size_t contextlen, 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 dilithium.c:37
QSC_EXPORT_API void qsc_dilithium_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 dilithium.c:22
QSC_EXPORT_API void qsc_dilithium_generate_keypair(uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Generates a Dilithium public/private key-pair.
Definition dilithium.c:9