![]() |
PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
typedef struct pqlr_kem_st * | pqlr_kem |
PQLR KEM algorithm instance handle. More... | |
Functions | |
PQLR_API size_t | pqlr_kem_num_algs (void) |
Obtains the number of available PQLR KEM algorithms. More... | |
PQLR_API size_t | pqlr_kem_get_algs (const char **algs, size_t count) |
Fills the provided buffer with names of available KEM algorithms. More... | |
PQLR_API pqlr_kem | pqlr_kem_new (const pqlr_alg alg) |
Creates pqlr_kem instance initialized by alg. More... | |
PQLR_API void | pqlr_kem_free (pqlr_kem kem) |
Frees pqlr_kem instance and all corresponding resources. More... | |
PQLR_API pqlr_kem | pqlr_kem_duplicate (const pqlr_kem kem) |
duplicates the context of pqlr_kem algorithm More... | |
PQLR_API uint32_t | pqlr_kem_get_initiator_public_length (const pqlr_kem kem) |
Obtains initiator's public key length for the current pqlr_kem instance. More... | |
PQLR_API uint32_t | pqlr_kem_get_initiator_secret_length (const pqlr_kem kem) |
Obtains initiator's secret key length for the current pqlr_kem instance. More... | |
PQLR_API uint32_t | pqlr_kem_get_ciphertext_length (const pqlr_kem kem) |
Obtains ciphertext (request) length for the current pqlr_kem instance. More... | |
PQLR_API uint32_t | pqlr_kem_get_shared_secret_length (const pqlr_kem kem) |
Obtains shared secret (key) length for the current pqlr_kem instance. More... | |
PQLR_API int | pqlr_kem_keygen (const pqlr_kem kem, uint8_t *pk, uint8_t *sk) |
Initial step of key distribution. Generates a key pair for key distribution initiator. More... | |
PQLR_API int | pqlr_kem_encap (const pqlr_kem kem, const uint8_t *pk, uint8_t *ciphertext, uint8_t *session_key) |
Second step of key distribution. Encapsulates key on the responder side. More... | |
PQLR_API int | pqlr_kem_decap (const pqlr_kem kem, const uint8_t *sk, const uint8_t *ciphertext, uint8_t *session_key) |
Last step of key distribution. Decapsulates key on the initiator side. More... | |
This module provides post-quantum key encapsulation mechanisms (KEM) for secure key distribution between two parties. The distributed secret is theoretically tolerant to attacks from both quantum and classical computers. Entry point is pqlr_kem_keygen
Key encapsulation mechanisms consist of sequential function calls on two sides named initiator
and responder
.
request
, key
request
to initiatorkey
key
In order to use any SABER key distribution functions, add the following include:
Example code is listed below:
typedef struct pqlr_kem_st* pqlr_kem |
PQLR KEM algorithm instance handle.
PQLR_API int pqlr_kem_decap | ( | const pqlr_kem | kem, |
const uint8_t * | sk, | ||
const uint8_t * | ciphertext, | ||
uint8_t * | session_key | ||
) |
Last step of key distribution. Decapsulates key on the initiator side.
[in] | kem | pqlr_kem algorithm context. If NULL , the fatal error occurs. |
[in] | sk | Secret key buffer ( pqlr_kem_keygen ). Must point to array of uint8_t with elements count at least pqlr_kem_get_initiator_secret_length . If NULL , the fatal error occurs. |
[in] | ciphertext | Encoded request from the responder. Must point to array of uint8_t , with elements count at least pqlr_kem_get_ciphertext_length . If NULL , the fatal error occurs. |
[out] | session_key | Distributed key, equal to the key to be obtained on the responder side. Must point to array of uint8_t , with elements count at least pqlr_kem_get_shared_secret_length . If NULL , the fatal error occurs. |
duplicates the context of pqlr_kem algorithm
[in] | kem | instance to duplicate |
PQLR_API int pqlr_kem_encap | ( | const pqlr_kem | kem, |
const uint8_t * | pk, | ||
uint8_t * | ciphertext, | ||
uint8_t * | session_key | ||
) |
Second step of key distribution. Encapsulates key on the responder side.
[in] | kem | pqlr_kem algorithm context. If NULL , the fatal error occurs. |
[in] | pk | Public key buffer ( pqlr_kem_keygen ). Must point to array of uint8_t with elements count at least pqlr_kem_get_initiator_public_length . If NULL , the fatal error occurs. |
[out] | ciphertext | Encoded request from the responder. Must point to array of uint8_t , with elements count at least pqlr_kem_get_ciphertext_length . If NULL , the fatal error occurs. |
[out] | session_key | Distributed key, equal to the key to be obtained on the initiator side. Must point to array of uint8_t , with elements count at least pqlr_kem_get_shared_secret_length . If NULL , the fatal error occurs. |
Frees pqlr_kem instance and all corresponding resources.
[in] | kem | instance to free |
PQLR_API size_t pqlr_kem_get_algs | ( | const char ** | algs, |
size_t | count | ||
) |
Fills the provided buffer with names of available KEM algorithms.
[out] | algs | Array of KEM names |
[in] | count | Array size |
Obtains ciphertext (request) length for the current pqlr_kem instance.
[in] | kem | initialized pqlr_kem instance |
Obtains initiator's public key length for the current pqlr_kem instance.
[in] | kem | initialized pqlr_kem instance |
Obtains initiator's secret key length for the current pqlr_kem instance.
[in] | kem | initialized pqlr_kem instance |
Obtains shared secret (key) length for the current pqlr_kem instance.
[in] | kem | initialized pqlr_kem instance |
Initial step of key distribution. Generates a key pair for key distribution initiator.
[in] | kem | pqlr_kem algorithm context. If NULL , the fatal error occurs. |
[out] | pk | Public key buffer. Must point to array of uint8_t with elements count at least pqlr_kem_get_initiator_public_length . If NULL , the fatal error occurs. |
[out] | sk | Secret key buffer. Must point to array of uint8_t with elements count at least pqlr_kem_get_initiator_secret_length . If NULL , the fatal error occurs. |
Creates pqlr_kem instance initialized by alg.
[in] | alg | Initialized PQLR KEM algorithm instance |
NULL
if out of memory PQLR_API size_t pqlr_kem_num_algs | ( | void | ) |
Obtains the number of available PQLR KEM algorithms.