Leancrypto 1.6.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
BIKE Key Encapsulation Mechanism

Functions

enum lc_bike_type lc_bike_sk_type (const struct lc_bike_sk *sk)
 Obtain BIKE type from secret key.
enum lc_bike_type lc_bike_pk_type (const struct lc_bike_pk *pk)
 Obtain BIKE type from public key.
enum lc_bike_type lc_bike_ct_type (const struct lc_bike_ct *ct)
 Obtain BIKE type from BIKE ciphertext.
enum lc_bike_type lc_bike_ss_type (const struct lc_bike_ss *ss)
 Obtain BIKE type from shared secret.
LC_PURE unsigned int lc_bike_sk_size (enum lc_bike_type bike_type)
 Return the size of the BIKE secret key.
LC_PURE unsigned int lc_bike_pk_size (enum lc_bike_type bike_type)
 Return the size of the BIKE public key.
LC_PURE unsigned int lc_bike_ct_size (enum lc_bike_type bike_type)
 Return the size of the BIKE ciphertext.
LC_PURE unsigned int lc_bike_ss_size (enum lc_bike_type bike_type)
 Return the size of the BIKE shared secret.
int lc_bike_sk_load (struct lc_bike_sk *sk, const uint8_t *src_key, size_t src_key_len)
 Load a BIKE secret key provided with a buffer into the leancrypto data structure.
int lc_bike_pk_load (struct lc_bike_pk *pk, const uint8_t *src_key, size_t src_key_len)
 Load a BIKE public key provided with a buffer into the leancrypto data structure.
int lc_bike_ct_load (struct lc_bike_ct *ct, const uint8_t *src_key, size_t src_key_len)
 Load a BIKE ciphertext key provided with a buffer into the leancrypto data structure.
int lc_bike_ss_load (struct lc_bike_ss *ss, const uint8_t *src_key, size_t src_key_len)
 Load a BIKE shared secret provided with a buffer into the leancrypto data structure.
int lc_bike_sk_ptr (uint8_t **bike_key, size_t *bike_key_len, struct lc_bike_sk *sk)
 Obtain the reference to the BIKE key and its length.
int lc_bike_pk_ptr (uint8_t **bike_key, size_t *bike_key_len, struct lc_bike_pk *pk)
 Obtain the reference to the BIKE key and its length.
int lc_bike_ct_ptr (uint8_t **bike_ct, size_t *bike_ct_len, struct lc_bike_ct *ct)
 Obtain the reference to the BIKE ciphertext and its length.
int lc_bike_ss_ptr (uint8_t **bike_ss, size_t *bike_ss_len, struct lc_bike_ss *ss)
 Obtain the reference to the BIKE shared secret and its length.
int lc_bike_keypair (struct lc_bike_pk *pk, struct lc_bike_sk *sk, struct lc_rng_ctx *rng_ctx, enum lc_bike_type bike_type)
 Generates public and private key for IND-CCA2-secure BIKE key encapsulation mechanism.
int lc_bike_keypair_from_seed (struct lc_bike_pk *pk, struct lc_bike_sk *sk, const uint8_t *seed, size_t seedlen, enum lc_bike_type bike_type)
 Generates BIKE public and private key from a given seed.
int lc_bike_enc (struct lc_bike_ct *ct, struct lc_bike_ss *ss, const struct lc_bike_pk *pk)
 Key encapsulation.
int lc_bike_enc_kdf (struct lc_bike_ct *ct, uint8_t *ss, size_t ss_len, const struct lc_bike_pk *pk)
 Key encapsulation with KDF applied to shared secret.
int lc_bike_dec (struct lc_bike_ss *ss, const struct lc_bike_ct *ct, const struct lc_bike_sk *sk)
 Key decapsulation.
int lc_bike_dec_kdf (uint8_t *ss, size_t ss_len, const struct lc_bike_ct *ct, const struct lc_bike_sk *sk)
 Key decapsulation with KDF applied to shared secret.

Detailed Description

BIKE API concept

The BIKE API is accessible via the following header files with the mentioned purpose.

Function Documentation

◆ lc_bike_ct_load()

int lc_bike_ct_load ( struct lc_bike_ct * ct,
const uint8_t * src_key,
size_t src_key_len )

Load a BIKE ciphertext key provided with a buffer into the leancrypto data structure.

Parameters
[out]ctBIKE ciphertext to be filled (the caller must have it allocated)
[in]src_keyBuffer that holds the ciphertext to be imported
[in]src_key_lenBuffer length that holds the ciphertext to be imported
Returns
0 on success or < 0 on error

◆ lc_bike_ct_ptr()

int lc_bike_ct_ptr ( uint8_t ** bike_ct,
size_t * bike_ct_len,
struct lc_bike_ct * ct )

Obtain the reference to the BIKE ciphertext and its length.

Note
Only pointer references into the leancrypto data structure are returned which implies that any modification will modify the leancrypto ciphertext, too.
Parameters
[out]bike_ctBIKE ciphertext pointer
[out]bike_ct_lenLength of the ciphertext buffer
[in]ctBIKE ciphertext from which the references are obtained
Returns
0 on success, != 0 on error

◆ lc_bike_ct_size()

LC_PURE unsigned int lc_bike_ct_size ( enum lc_bike_type bike_type)

Return the size of the BIKE ciphertext.

Parameters
[in]bike_typeBIKE type for which the size is requested
Returns
requested size

◆ lc_bike_ct_type()

enum lc_bike_type lc_bike_ct_type ( const struct lc_bike_ct * ct)

Obtain BIKE type from BIKE ciphertext.

Parameters
[in]ctCiphertext from which the type is to be obtained
Returns
key type

◆ lc_bike_dec()

int lc_bike_dec ( struct lc_bike_ss * ss,
const struct lc_bike_ct * ct,
const struct lc_bike_sk * sk )

Key decapsulation.

Generates shared secret for given cipher text and private key

Parameters
[out]sspointer to output shared secret that is the same as produced during encapsulation
[in]ctpointer to input cipher text generated during encapsulation
[in]skpointer to input private key
Returns
0

On failure, ss will contain a pseudo-random value.

◆ lc_bike_dec_kdf()

int lc_bike_dec_kdf ( uint8_t * ss,
size_t ss_len,
const struct lc_bike_ct * ct,
const struct lc_bike_sk * sk )

Key decapsulation with KDF applied to shared secret.

Generates cipher text and shared secret for given private key. The shared secret is derived from the BIKE SS using the KDF derived from the round 3 definition of BIKE:

SS <- KMAC256(K = BIKE-SS, X = BIKE-CT, L = requested SS length,
S = "BIKE KEM SS")
Parameters
[out]sspointer to output shared secret that is the same as produced during encapsulation
[in]ss_lenlength of shared secret to be generated
[in]ctpointer to input cipher text generated during encapsulation
[in]skpointer to input private key
Returns
0

On failure, ss will contain a pseudo-random value.

◆ lc_bike_enc()

int lc_bike_enc ( struct lc_bike_ct * ct,
struct lc_bike_ss * ss,
const struct lc_bike_pk * pk )

Key encapsulation.

Generates cipher text and shared secret for given public key.

Parameters
[out]ctpointer to output cipher text to used for decapsulation
[out]sspointer to output shared secret that will be also produced during decapsulation
[in]pkpointer to input public key

Returns 0 (success) or < 0 on error

◆ lc_bike_enc_kdf()

int lc_bike_enc_kdf ( struct lc_bike_ct * ct,
uint8_t * ss,
size_t ss_len,
const struct lc_bike_pk * pk )

Key encapsulation with KDF applied to shared secret.

Generates cipher text and shared secret for given public key. The shared secret is derived from the BIKE SS using the KDF derived from the round 3 definition of BIKE:

SS <- KMAC256(K = BIKE-SS, X = BIKE-CT, L = requested SS length,
S = "BIKE KEM SS")
Parameters
[out]ctpointer to output cipher text to used for decapsulation
[out]sspointer to output shared secret that will be also produced during decapsulation
[in]ss_lenlength of shared secret to be generated
[in]pkpointer to input public key

Returns 0 (success) or < 0 on error

◆ lc_bike_keypair()

int lc_bike_keypair ( struct lc_bike_pk * pk,
struct lc_bike_sk * sk,
struct lc_rng_ctx * rng_ctx,
enum lc_bike_type bike_type )

Generates public and private key for IND-CCA2-secure BIKE key encapsulation mechanism.

Parameters
[out]pkpointer to already allocated output public key
[out]skpointer to already allocated output private key
[in]rng_ctxpointer to seeded random number generator context
[in]bike_typetype of the BIKE key to generate
Returns
0 (success) or < 0 on error

◆ lc_bike_keypair_from_seed()

int lc_bike_keypair_from_seed ( struct lc_bike_pk * pk,
struct lc_bike_sk * sk,
const uint8_t * seed,
size_t seedlen,
enum lc_bike_type bike_type )

Generates BIKE public and private key from a given seed.

The idea of the function is the allowance of FIPS 203 to maintain the seed used to generate a key pair in lieu of maintaining a private key or the key pair (which used much more memory). The seed must be treated equally sensitive as a private key.

The seed is generated by simply obtaining 64 bytes from a properly seeded DRNG, i.e. the same way as a symmetric key would be generated.

Parameters
[out]pkpointer to allocated output public key
[out]skpointer to allocated output private key
[in]seedbuffer with the seed data which must be exactly 64 bytes in size
[in]seedlenlength of the seed buffer
[in]bike_typetype of the BIKE key to generate
Returns
0 (success) or < 0 on error

◆ lc_bike_pk_load()

int lc_bike_pk_load ( struct lc_bike_pk * pk,
const uint8_t * src_key,
size_t src_key_len )

Load a BIKE public key provided with a buffer into the leancrypto data structure.

Parameters
[out]pkPublic key to be filled (the caller must have it allocated)
[in]src_keyBuffer that holds the key to be imported
[in]src_key_lenBuffer length that holds the key to be imported
Returns
0 on success or < 0 on error

◆ lc_bike_pk_ptr()

int lc_bike_pk_ptr ( uint8_t ** bike_key,
size_t * bike_key_len,
struct lc_bike_pk * pk )

Obtain the reference to the BIKE key and its length.

Note
Only pointer references into the leancrypto data structure are returned which implies that any modification will modify the leancrypto key, too.
Parameters
[out]bike_keyBIKE key pointer
[out]bike_key_lenLength of the key buffer
[in]pkBIKE public key from which the references are obtained
Returns
0 on success, != 0 on error

◆ lc_bike_pk_size()

LC_PURE unsigned int lc_bike_pk_size ( enum lc_bike_type bike_type)

Return the size of the BIKE public key.

Parameters
[in]bike_typeBIKE type for which the size is requested
Returns
requested size

◆ lc_bike_pk_type()

enum lc_bike_type lc_bike_pk_type ( const struct lc_bike_pk * pk)

Obtain BIKE type from public key.

Parameters
[in]pkPublic key from which the type is to be obtained
Returns
key type

◆ lc_bike_sk_load()

int lc_bike_sk_load ( struct lc_bike_sk * sk,
const uint8_t * src_key,
size_t src_key_len )

Load a BIKE secret key provided with a buffer into the leancrypto data structure.

Parameters
[out]skSecret key to be filled (the caller must have it allocated)
[in]src_keyBuffer that holds the key to be imported
[in]src_key_lenBuffer length that holds the key to be imported
Returns
0 on success or < 0 on error

◆ lc_bike_sk_ptr()

int lc_bike_sk_ptr ( uint8_t ** bike_key,
size_t * bike_key_len,
struct lc_bike_sk * sk )

Obtain the reference to the BIKE key and its length.

Note
Only pointer references into the leancrypto data structure are returned which implies that any modification will modify the leancrypto key, too.
Parameters
[out]bike_keyBIKE key pointer
[out]bike_key_lenLength of the key buffer
[in]skBIKE secret key from which the references are obtained
Returns
0 on success, != 0 on error

◆ lc_bike_sk_size()

LC_PURE unsigned int lc_bike_sk_size ( enum lc_bike_type bike_type)

Return the size of the BIKE secret key.

Parameters
[in]bike_typeBIKE type for which the size is requested
Returns
requested size

◆ lc_bike_sk_type()

enum lc_bike_type lc_bike_sk_type ( const struct lc_bike_sk * sk)

Obtain BIKE type from secret key.

Parameters
[in]skSecret key from which the type is to be obtained
Returns
key type

◆ lc_bike_ss_load()

int lc_bike_ss_load ( struct lc_bike_ss * ss,
const uint8_t * src_key,
size_t src_key_len )

Load a BIKE shared secret provided with a buffer into the leancrypto data structure.

Parameters
[out]ssBIKE shared secret to be filled (the caller must have it allocated)
[in]src_keyBuffer that holds the shared secret to be imported
[in]src_key_lenBuffer length that holds the shared secret to be imported
Returns
0 on success or < 0 on error

◆ lc_bike_ss_ptr()

int lc_bike_ss_ptr ( uint8_t ** bike_ss,
size_t * bike_ss_len,
struct lc_bike_ss * ss )

Obtain the reference to the BIKE shared secret and its length.

Note
Only pointer references into the leancrypto data structure are returned which implies that any modification will modify the leancrypto shared secret, too.
Parameters
[out]bike_ssBIKE shared secret pointer
[out]bike_ss_lenLength of the shared secret buffer
[in]ssBIKE shared secret from which the references are obtained
Returns
0 on success, != 0 on error

◆ lc_bike_ss_size()

LC_PURE unsigned int lc_bike_ss_size ( enum lc_bike_type bike_type)

Return the size of the BIKE shared secret.

Parameters
[in]bike_typeBIKE type for which the size is requested
Returns
requested size

◆ lc_bike_ss_type()

enum lc_bike_type lc_bike_ss_type ( const struct lc_bike_ss * ss)

Obtain BIKE type from shared secret.

Parameters
[in]ssShared secret key from which the type is to be obtained
Returns
key type