PQLR
Postquantum Crypto Library by QAPP
kem.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <pqlr/common/alg.h>
4 
5 #include <stddef.h>
6 #include <stdlib.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif // __cplusplus
11 
53 typedef struct pqlr_kem_st* pqlr_kem;
54 
64 
77 PQLR_API size_t pqlr_kem_get_algs(const char** algs, size_t count);
78 
90 
99 
108 
119 
130 
140 
150 
170 PQLR_API int pqlr_kem_keygen(const pqlr_kem kem, uint8_t* pk, uint8_t* sk);
171 
196  const pqlr_kem kem,
197  const uint8_t* pk,
198  uint8_t* ciphertext,
199  uint8_t* session_key);
200 
222  const pqlr_kem kem,
223  const uint8_t* sk,
224  const uint8_t* ciphertext,
225  uint8_t* session_key);
226 
231 #ifdef __cplusplus
232 } // extern "C"
233 #endif //__cplusplus
#define PQLR_API
Definition: api.h:22
struct pqlr_alg_st * pqlr_alg
PQLR algorithm instance handle.
Definition: alg.h:32
PQLR_API uint32_t pqlr_kem_get_ciphertext_length(const pqlr_kem kem)
Obtains ciphertext (request) length for the current pqlr_kem instance.
PQLR_API size_t pqlr_kem_num_algs(void)
Obtains the number of available PQLR KEM algorithms.
PQLR_API void pqlr_kem_free(pqlr_kem kem)
Frees pqlr_kem instance and all corresponding resources.
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.
PQLR_API pqlr_kem pqlr_kem_new(const pqlr_alg alg)
Creates pqlr_kem instance initialized by alg.
struct pqlr_kem_st * pqlr_kem
PQLR KEM algorithm instance handle.
Definition: kem.h:53
PQLR_API size_t pqlr_kem_get_algs(const char **algs, size_t count)
Fills the provided buffer with names of available KEM algorithms.
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.
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.
PQLR_API pqlr_kem pqlr_kem_duplicate(const pqlr_kem kem)
duplicates the context of pqlr_kem algorithm
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.
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.
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.