![]() |
PQLR
Postquantum Crypto Library by QAPP
|
Typedefs | |
typedef struct ml_kem_st * | ml_kem_t |
ML-KEM algorithm instance handle. More... | |
Enumerations | |
enum | ml_kem_parameterset_t { ml_kem_512 , ml_kem_768 , ml_kem_1024 , ml_kem_last } |
Possible ML-KEM parameters sets. More... | |
Functions | |
PQLR_API ml_kem_t | ml_kem_new (ml_kem_parameterset_t parameterset) |
Creates ML-KEM instance initialized by parameterset. More... | |
PQLR_API void | ml_kem_free (ml_kem_t ml_kem) |
Frees ML-KEM instance and all corresponding resources. More... | |
PQLR_API uint32_t | ml_kem_get_initiator_public_length (ml_kem_t ml_kem) |
Obtains initiator's public key length for the current ML-KEM instance. More... | |
PQLR_API uint32_t | ml_kem_get_initiator_secret_length (ml_kem_t ml_kem) |
Obtains initiator's secret key length for the current ML-KEM instance. More... | |
PQLR_API uint32_t | ml_kem_get_ciphertext_length (ml_kem_t ml_kem) |
Obtains ciphertext length for the current ML-KEM instance. More... | |
PQLR_API uint32_t | ml_kem_get_shared_secret_length (ml_kem_t ml_kem) |
Obtains shared secret length for the current ML-KEM instance. More... | |
PQLR_API pqlr_t | ml_kem_to_pqlr (ml_kem_t ml_kem) |
Gets pqlr instance linked to this ML-KEM instance. More... | |
PQLR_API ml_kem_t | ml_kem_duplicate (const ml_kem_t ml_kem) |
Duplicates context of ML-KEM instance. More... | |
PQLR_API void | ml_kem_keygen (const ml_kem_t ml_kem, uint8_t *public_key, uint8_t *secret_key) |
Initial step of key distribution. Generates a key pair for key distribution initiator. More... | |
PQLR_API void | ml_kem_key_encap (const ml_kem_t ml_kem, const uint8_t *public_key, uint8_t *ciphertext, uint8_t *session_key) |
Key encapsulation. More... | |
PQLR_API void | ml_kem_key_decap (const ml_kem_t ml_kem, const uint8_t *secret_key, const uint8_t *ciphertext, uint8_t *session_key) |
Key decapsulation. More... | |
This module provides ML-KEM algorithm implementation, which is finite state machine for secure distribution of secret between two counterparties. The distributed secret is theoretically tolerant to attacks performed by quantum computers. Entry point is ml_kem_keygen
Key distribution algorithm consists of sequential function calls on two sides: initiator (e.g. server side) and responder (e.g. client side).
public key
.public key
to responder.ciphertext
and session key
.session key
.session key
In order to use any ML-KEM key distribution functions, add the following include:
Example code is listed below:
typedef struct ml_kem_st* ml_kem_t |
ML-KEM algorithm instance handle.
Duplicates context of ML-KEM instance.
ml_kem | instance to duplicate |
Frees ML-KEM instance and all corresponding resources.
ml_kem | instance to free |
Obtains ciphertext length for the current ML-KEM instance.
ml_kem | initialized ML-KEM instance |
Obtains initiator's public key length for the current ML-KEM instance.
ml_kem | initialized ML-KEM instance |
Obtains initiator's secret key length for the current ML-KEM instance.
ml_kem | initialized ML-KEM instance |
Obtains shared secret length for the current ML-KEM instance.
ml_kem | initialized ML-KEM instance |
PQLR_API void ml_kem_key_decap | ( | const ml_kem_t | ml_kem, |
const uint8_t * | secret_key, | ||
const uint8_t * | ciphertext, | ||
uint8_t * | session_key | ||
) |
Key decapsulation.
ml_kem | ML-KEM algorithm context. If NULL , the fatal error occurs. | |
secret_key | Secret key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_initiator_secret_length . If NULL , the fatal error occurs. (ml_kem_keygen) | |
ciphertext | Ciphertext buffer. Must point to array of uint8_t with elements count at least ml_kem_get_ciphertext_length . If NULL , the fatal error occurs | |
[out] | session_key | Session key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_shared_secret_length . If NULL , the fatal error occurs. |
PQLR_API void ml_kem_key_encap | ( | const ml_kem_t | ml_kem, |
const uint8_t * | public_key, | ||
uint8_t * | ciphertext, | ||
uint8_t * | session_key | ||
) |
Key encapsulation.
ml_kem | ML-KEM algorithm context. If NULL , the fatal error occurs. | |
public_key | Public key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_initiator_public_length . If NULL , the fatal error occurs. | |
[out] | ciphertext | Ciphertext buffer. Must point to array of uint8_t with elements count at least ml_kem_get_ciphertext_length . If NULL , the fatal error occurs. |
[out] | session_key | Session key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_shared_secret_length . If NULL , the fatal error occurs. |
Initial step of key distribution. Generates a key pair for key distribution initiator.
ml_kem | ML-KEM algorithm context. If NULL , the fatal error occurs. | |
[out] | public_key | Public key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_initiator_public_length . If NULL , the fatal error occurs. |
[out] | secret_key | Secret key buffer. Must point to array of uint8_t with elements count at least ml_kem_get_initiator_secret_length . If NULL , the fatal error occurs. |
PQLR_API ml_kem_t ml_kem_new | ( | ml_kem_parameterset_t | parameterset | ) |
Creates ML-KEM instance initialized by parameterset.
parameterset | ML-KEM configuration parameters set (see ml_kem_parameterset_t for availible options). |
NULL
if out of memory Gets pqlr instance linked to this ML-KEM instance.
ml_kem | initialized ML-KEM instance |
NULL
if ml_kem is NULL