This module provides Kyber 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 kyber_keygen
Key distribution algorithm consists of sequential function calls on two sides: initiator (e.g. server side) and responder (e.g. client side).
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
void print_key(const char* message, uint8_t* key, uint32_t key_size)
{
uint8_t i = 0;
printf("%s", message);
for (; i < key_size; ++i) {
printf("%.2X", key[i]);
}
printf("\n");
}
int main(int argc, char* argv[])
{
uint8_t* public_key =
uint8_t* secret_key =
uint8_t* server_side_key = (uint8_t*)calloc(
uint8_t* client_side_key = (uint8_t*)calloc(
print_key(
"Server side: ", server_side_key,
print_key(
"Client side: ", client_side_key,
free(public_key);
free(secret_key);
free(server_side_key);
free(client_side_key);
free(ciphertext);
return 0;
}
PQLR_API void kyber_free(kyber_t kyber)
Frees kyber instance and all corresponding resources.
PQLR_API uint32_t kyber_get_ciphertext_length(kyber_t kyber)
Obtains ciphertext length for the current kyber instance.
PQLR_API uint32_t kyber_get_initiator_public_length(kyber_t kyber)
Obtains initiator's public key length for the current kyber instance.
PQLR_API void kyber_keygen(const kyber_t kyber, uint8_t *public_key, uint8_t *secret_key)
Initial step of key distribution. Generates a key pair for key distribution initiator.
struct kyber_st * kyber_t
Kyber algorithm instance handle.
Definition: kyber.h:55
PQLR_API uint32_t kyber_get_shared_secret_length(kyber_t kyber)
Obtains shared secret length for the current kyber instance.
PQLR_API uint32_t kyber_get_initiator_secret_length(kyber_t kyber)
Obtains initiator's secret key length for the current kyber instance.
PQLR_API void kyber_key_decap(const kyber_t kyber, const uint8_t *secret_key, const uint8_t *ciphertext, uint8_t *session_key)
Key decapsulation.
PQLR_API void kyber_key_encap(const kyber_t kyber, const uint8_t *public_key, uint8_t *ciphertext, uint8_t *session_key)
Key encapsulation.
PQLR_API kyber_t kyber_new(kyber_parameterset_t parameterset)
Creates kyber instance initialized by parameterset.
@ kyber512
Definition: kyber.h:48