QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
mceliece.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_MCELIECE_H
42#define QSC_MCELIECE_H
43
44#include "common.h"
45
46QSC_CPLUSPLUS_ENABLED_START
47
48// TODO: malloc large arrays and translate GAS to MASM and implement
49
83
84/* Parameter definitions for different McEliece parameter sets */
85#if defined(QSC_MCELIECE_S1N3488T64)
86
91# define QSC_MCELIECE_CIPHERTEXT_SIZE 128
92
97# define QSC_MCELIECE_PRIVATEKEY_SIZE 6492
98
103# define QSC_MCELIECE_PUBLICKEY_SIZE 261120
104
105#elif defined(QSC_MCELIECE_S3N4608T96)
106
111# define QSC_MCELIECE_CIPHERTEXT_SIZE 188
112
117# define QSC_MCELIECE_PRIVATEKEY_SIZE 13608
118
123# define QSC_MCELIECE_PUBLICKEY_SIZE 524160
124
125#elif defined(QSC_MCELIECE_S5N6688T128)
126
131# define QSC_MCELIECE_CIPHERTEXT_SIZE 240
132
137# define QSC_MCELIECE_PRIVATEKEY_SIZE 13932
138
143# define QSC_MCELIECE_PUBLICKEY_SIZE 1044992
144
145#elif defined(QSC_MCELIECE_S6N6960T119)
146
151# define QSC_MCELIECE_CIPHERTEXT_SIZE 226
152
157# define QSC_MCELIECE_PRIVATEKEY_SIZE 13948
158
163# define QSC_MCELIECE_PUBLICKEY_SIZE 1047319
164
165#elif defined(QSC_MCELIECE_S7N8192T128)
166
171# define QSC_MCELIECE_CIPHERTEXT_SIZE 240
172
177# define QSC_MCELIECE_PRIVATEKEY_SIZE 14120
178
183# define QSC_MCELIECE_PUBLICKEY_SIZE 1357824
184
185#else
186# error "The McEliece parameter set is invalid!"
187#endif
188
193#define QSC_MCELIECE_SEED_SIZE 32ULL
194
199#define QSC_MCELIECE_SHAREDSECRET_SIZE 32ULL
200
205#define QSC_MCELIECE_ALGNAME "MCELIECE"
206
215QSC_EXPORT_API bool qsc_mceliece_decapsulate(uint8_t* secret, const uint8_t* ciphertext, const uint8_t* privatekey);
216
225QSC_EXPORT_API bool qsc_mceliece_decrypt(uint8_t* secret, const uint8_t* ciphertext, const uint8_t* privatekey);
226
235QSC_EXPORT_API void qsc_mceliece_encapsulate(uint8_t* secret, uint8_t* ciphertext, const uint8_t* publickey, bool (*rng_generate)(uint8_t*, size_t));
236
245QSC_EXPORT_API void qsc_mceliece_encrypt(uint8_t* secret, uint8_t* ciphertext, const uint8_t* publickey, const uint8_t seed[QSC_MCELIECE_SEED_SIZE]);
246
254QSC_EXPORT_API void qsc_mceliece_generate_keypair(uint8_t* publickey, uint8_t* privatekey, bool (*rng_generate)(uint8_t*, size_t));
255
256QSC_CPLUSPLUS_ENABLED_END
257
258#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_mceliece_decapsulate(uint8_t *secret, const uint8_t *ciphertext, const uint8_t *privatekey)
Decapsulates the shared secret for a given ciphertext using a private key.
Definition mceliece.c:5
QSC_EXPORT_API void qsc_mceliece_encapsulate(uint8_t *secret, uint8_t *ciphertext, const uint8_t *publickey, bool(*rng_generate)(uint8_t *, size_t))
Encapsulates a shared secret key using a public key.
Definition mceliece.c:41
QSC_EXPORT_API void qsc_mceliece_generate_keypair(uint8_t *publickey, uint8_t *privatekey, bool(*rng_generate)(uint8_t *, size_t))
Generates a McEliece public/private key pair.
Definition mceliece.c:69
#define QSC_MCELIECE_SEED_SIZE
The byte size of the seed array.
Definition mceliece.h:193
QSC_EXPORT_API void qsc_mceliece_encrypt(uint8_t *secret, uint8_t *ciphertext, const uint8_t *publickey, const uint8_t seed[QSC_MCELIECE_SEED_SIZE])
Encrypts to encapsulate a shared secret key using a public key.
Definition mceliece.c:54
QSC_EXPORT_API bool qsc_mceliece_decrypt(uint8_t *secret, const uint8_t *ciphertext, const uint8_t *privatekey)
Decrypts the shared secret for a given ciphertext using a private key.
Definition mceliece.c:23