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 File Reference

Contains the primary public API for the Niederreiter dual form of the McEliece asymmetric cipher implementation. More...

#include "common.h"

Go to the source code of this file.

Macros

#define QSC_MCELIECE_CIPHERTEXT_SIZE   240
 The byte size of the ciphertext array.
 
#define QSC_MCELIECE_PRIVATEKEY_SIZE   13932
 The byte size of the secret private-key array.
 
#define QSC_MCELIECE_PUBLICKEY_SIZE   1044992
 The byte size of the public-key array.
 
#define QSC_MCELIECE_SEED_SIZE   32ULL
 The byte size of the seed array.
 
#define QSC_MCELIECE_SHAREDSECRET_SIZE   32ULL
 The byte size of the shared secret-key array.
 
#define QSC_MCELIECE_ALGNAME   "MCELIECE"
 The formal algorithm name.
 

Functions

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.
 
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.
 
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.
 
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.
 
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.
 

Detailed Description

Contains the primary public API for the Niederreiter dual form of the McEliece asymmetric cipher implementation.

This header defines the functions and constants for the McEliece Key Encapsulation Mechanism (KEM) implementation. Depending on the defined parameter set (e.g. QSC_MCELIECE_S1N3488T64, QSC_MCELIECE_S3N4608T96, etc.), the sizes of the ciphertext, private key, and public key vary. The API supports key encapsulation (encryption) and decapsulation (decryption) operations.

// Create the public and secret keys.
qsc_mceliece_generate_keypair(pk, sk, rng_generate);
// Output the ciphertext and the shared secret.
qsc_mceliece_encapsulate(ssb, ct, pk, rng_generate);
// Decapsulate to retrieve the shared secret.
if (qsc_mceliece_decapsulate(ssa, ct, sk) == false)
{
// Decapsulation failed; handle error.
}
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
#define QSC_MCELIECE_PUBLICKEY_SIZE
The byte size of the public-key array.
Definition mceliece.h:143
#define QSC_MCELIECE_PRIVATEKEY_SIZE
The byte size of the secret private-key array.
Definition mceliece.h:137
#define QSC_MCELIECE_CIPHERTEXT_SIZE
The byte size of the ciphertext array.
Definition mceliece.h:131
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_SHAREDSECRET_SIZE
The byte size of the shared secret-key array.
Definition mceliece.h:199

Reference Links:

Function Documentation

◆ qsc_mceliece_decapsulate()

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.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (array of QSC_MCELIECE_SHAREDSECRET_SIZE).
ciphertext[const uint8_t*] Pointer to the ciphertext array (size QSC_MCELIECE_CIPHERTEXT_SIZE).
privatekey[const uint8_t*] Pointer to the private key array (size QSC_MCELIECE_PRIVATEKEY_SIZE).
Returns
[bool] Returns true if decapsulation succeeds.

◆ qsc_mceliece_decrypt()

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.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (array of QSC_MCELIECE_SHAREDSECRET_SIZE).
ciphertext[const uint8_t*] Pointer to the ciphertext array (size QSC_MCELIECE_CIPHERTEXT_SIZE).
privatekey[const uint8_t*] Pointer to the private key array (size QSC_MCELIECE_PRIVATEKEY_SIZE).
Returns
[bool] Returns true if decryption succeeds.

◆ qsc_mceliece_encapsulate()

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.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (array of QSC_MCELIECE_SHAREDSECRET_SIZE).
ciphertext[uint8_t*] Pointer to the output ciphertext array (size QSC_MCELIECE_CIPHERTEXT_SIZE).
publickey[const uint8_t*] Pointer to the public key array (size QSC_MCELIECE_PUBLICKEY_SIZE).
rng_generate[bool (*)(uint8_t*, size_t)] Pointer to a random generator function.

◆ qsc_mceliece_encrypt()

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.

Parameters
secret[uint8_t*] Pointer to the output shared secret key (array of QSC_MCELIECE_SHAREDSECRET_SIZE).
ciphertext[uint8_t*] Pointer to the output ciphertext array (size QSC_MCELIECE_CIPHERTEXT_SIZE).
publickey[const uint8_t*] Pointer to the public key array (size QSC_MCELIECE_PUBLICKEY_SIZE).
seed[const uint8_t[QSC_MCELIECE_SEED_SIZE]] Pointer to the random seed array.

◆ qsc_mceliece_generate_keypair()

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.

Parameters
publickey[uint8_t*] Pointer to the output public key array (size QSC_MCELIECE_PUBLICKEY_SIZE).
privatekey[uint8_t*] Pointer to the output private key array (size QSC_MCELIECE_PRIVATEKEY_SIZE).
rng_generate[bool (*)(uint8_t*, size_t)] Pointer to a random generator function.