-rw-r--r-- 4989 libmceliece-20230612/doc/man/mceliece.3 raw
.\" Automatically generated by Pandoc 2.9.2.1
.\"
.TH "mceliece" "3" "" "" ""
.hy
.SS NAME
.PP
mceliece - C API for the libmceliece implementation of the Classic
McEliece cryptosystem
.SS SYNOPSIS
.PP
Using libmceliece:
.IP
.nf
\f[C]
#include <mceliece.h>
\f[R]
.fi
.PP
Link with \f[C]-lmceliece\f[R].
.PP
Key generation (for, e.g., \f[C]mceliece6960119\f[R]):
.IP
.nf
\f[C]
unsigned char pk[mceliece6960119_PUBLICKEYBYTES];
unsigned char sk[mceliece6960119_SECRETKEYBYTES];
mceliece6960119_keypair(pk,sk);
\f[R]
.fi
.PP
Encapsulation (for, e.g., \f[C]mceliece6960119\f[R]):
.IP
.nf
\f[C]
unsigned char ct[mceliece6960119_CIPHERTEXTBYTES];
unsigned char k[mceliece6960119_BYTES];
const unsigned char pk[mceliece6960119_PUBLICKEYBYTES];
int ret;
ret = mceliece6960119_enc(ct,k,pk);
\f[R]
.fi
.PP
Decapsulation (for, e.g., \f[C]mceliece6960119\f[R]):
.IP
.nf
\f[C]
unsigned char k[mceliece6960119_BYTES];
const unsigned char ct[mceliece6960119_CIPHERTEXTBYTES];
const unsigned char sk[mceliece6960119_SECRETKEYBYTES];
int ret;
ret = mceliece6960119_dec(k,ct,sk);
\f[R]
.fi
.SS DESCRIPTION
.PP
libmceliece is an implementation of the Classic
McEliece (https://classic.mceliece.org) cryptosystem.
The C API for libmceliece provides the following functions:
.IP
.nf
\f[C]
mceliece{6960119,6688128,8192128,460896,348864}_keypair
mceliece{6960119,6688128,8192128,460896,348864}_enc
mceliece{6960119,6688128,8192128,460896,348864}_dec
mceliece{6960119,6688128,8192128,460896,348864}f_keypair
mceliece{6960119,6688128,8192128,460896,348864}f_enc
mceliece{6960119,6688128,8192128,460896,348864}f_dec
\f[R]
.fi
.PP
All of these functions follow the SUPERCOP API for
KEMs (https://bench.cr.yp.to/call-kem.html) except that
.IP \[bu] 2
the function names are libmceliece-specific instead of
\f[C]crypto_kem_*\f[R],
.IP \[bu] 2
message lengths are \f[C]long long\f[R] instead of
\f[C]unsigned long long\f[R], and
.IP \[bu] 2
the \f[C]keypair\f[R] functions return \f[C]void\f[R] instead of
\f[C]int\f[R].
.PP
The details below use \f[C]mceliece6960119\f[R] as an example.
.SS KEY GENERATION
.PP
The \f[C]mceliece6960119_keypair\f[R] function randomly generates
Alice\[cq]s secret key \f[C]sk[0]\f[R], \f[C]sk[1]\f[R], \&...,
\f[C]sk[mceliece6960119_SECRETKEYBYTES-1]\f[R] and Alice\[cq]s
corresponding public key \f[C]pk[0]\f[R], \f[C]pk[1]\f[R], \&...,
\f[C]pk[mceliece6960119_PUBLICKEYBYTES-1]\f[R].
.SS ENCAPSULATION
.PP
The \f[C]mceliece6960119_enc\f[R] function randomly generates a
ciphertext \f[C]ct[0]\f[R], \f[C]ct[1]\f[R], \&...,
\f[C]ct[mceliece6960119_CIPHERTEXTBYTES-1]\f[R] and the corresponding
session key \f[C]k[0]\f[R], \f[C]k[1]\f[R], \&...,
\f[C]k[mceliece6960119_BYTES-1]\f[R] given Alice\[cq]s public key
\f[C]pk[0]\f[R], \f[C]pk[1]\f[R], \&...,
\f[C]pk[mceliece6960119_PUBLICKEYBYTES-1]\f[R].
This function then returns \f[C]0\f[R].
.PP
Exception: If the input public key is not \[lq]narrowly decodable\[rq]
(i.e., if bits at particular positions in \f[C]pk\f[R] are set), this
function returns \f[C]-1\f[R].
Currently the function also handles such public keys by clearing
\f[C]ct\f[R] and \f[C]k\f[R], but callers should not rely on this.
.PP
For \f[C]{6688128,8192128,460896,348864}{,f}\f[R], all byte strings of
the correct length are narrowly decodable, and the return value is
always \f[C]0\f[R].
For \f[C]6960119{,f}\f[R], the return value can be \f[C]-1\f[R].
.SS DECAPSULATION
.PP
The \f[C]mceliece6960119_dec\f[R] function, given Alice\[cq]s secret key
\f[C]sk[0]\f[R], \f[C]sk[1]\f[R], \&...,
\f[C]sk[mceliece6960119_SECRETKEYBYTES-1]\f[R], computes the session key
\f[C]k[0]\f[R], \f[C]k[1]\f[R], \&...,
\f[C]k[mceliece6960119_BYTES-1]\f[R] corresponding to a ciphertext
\f[C]ct[0]\f[R], \f[C]ct[1]\f[R], \&...,
\f[C]ct[mceliece6960119_CIPHERTEXTBYTES-1]\f[R] that was encapsulated to
Alice.
This function then returns \f[C]0\f[R].
.PP
Exception: If the input ciphertext is not \[lq]narrowly decodable\[rq]
(i.e., if bits at particular positions in \f[C]ct\f[R] are set), this
function returns \f[C]-1\f[R].
Currently this function also handles such ciphertexts by setting all
bytes of \f[C]k\f[R] to \f[C]255\f[R], but callers should not rely on
this.
.PP
For \f[C]{6688128,8192128,460896,348864}{,f}\f[R], all byte strings of
the correct length are narrowly decodable, and the return value is
always \f[C]0\f[R].
For \f[C]6960119{,f}\f[R], the return value can be \f[C]-1\f[R].
.SS THE f VARIANTS
.PP
The \f[C]f\f[R] variants are internally more complicated than the
non-\f[C]f\f[R] variants but provide faster key generation.
The \f[C]f\f[R] variants are interoperable with the non-\f[C]f\f[R]
variants: for example, a key generated with
\f[C]mceliece6960119f_keypair\f[R] can decapsulate ciphertexts that were
encapsulated with \f[C]mceliece6960119_enc\f[R].
The secret-key sizes (and formats) are the same, the \f[C]enc\f[R]
functions are the same, and the \f[C]dec\f[R] functions are the same.
.SS SEE ALSO
.PP
\f[B]mceliece\f[R](1), \f[B]randombytes\f[R](3)