Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
Functions
cx_mlkem.c File Reference

ML-KEM key encapsulation mechanism (FIPS 203). More...

#include <string.h>
#include "cx_mlkem_internal.h"
#include "cx_mlkem_indcpa.h"
#include "cx_mlkem_util.h"
#include "cx_utils.h"
#include "lcx_rng.h"
Include dependency graph for cx_mlkem.c:

Go to the source code of this file.

Functions

cx_err_t MLKEM_crypto_kem_keypair (uint8_t *pk, size_t pk_len, uint8_t *sk, size_t sk_len, MLKEM_param_t param)
 Generates an ML-KEM key pair.
 
cx_err_t MLKEM_crypto_kem_enc (uint8_t *ct, size_t ct_len, uint8_t *ss, size_t ss_len, const uint8_t *pk, size_t pk_len, MLKEM_param_t param)
 ML-KEM encapsulation.
 
cx_err_t MLKEM_crypto_kem_dec (uint8_t *ss, size_t ss_len, const uint8_t *ct, size_t ct_len, const uint8_t *sk, size_t sk_len, MLKEM_param_t param)
 ML-KEM decapsulation.
 

Detailed Description

ML-KEM key encapsulation mechanism (FIPS 203).

Implements the top-level ML-KEM key generation, encapsulation, and decapsulation routines, including both randomized and derandomized variants.

Definition in file cx_mlkem.c.

Function Documentation

◆ MLKEM_crypto_kem_dec()

cx_err_t MLKEM_crypto_kem_dec ( uint8_t *  ss,
size_t  ss_len,
const uint8_t *  ct,
size_t  ct_len,
const uint8_t *  sk,
size_t  sk_len,
MLKEM_param_t  param 
)

ML-KEM decapsulation.

Recovers the shared secret from a ciphertext and a secret key.

Parameters
[out]ssShared secret output buffer.
[in]ss_lenSize of the shared secret buffer in bytes.
[in]ctCiphertext.
[in]ct_lenSize of the ciphertext in bytes.
[in]skSecret key.
[in]sk_lenSize of the secret key in bytes.
[in]paramML-KEM parameter set selector.
Returns
CX_OK on success, error code otherwise.

Definition at line 88 of file cx_mlkem.c.

◆ MLKEM_crypto_kem_enc()

cx_err_t MLKEM_crypto_kem_enc ( uint8_t *  ct,
size_t  ct_len,
uint8_t *  ss,
size_t  ss_len,
const uint8_t *  pk,
size_t  pk_len,
MLKEM_param_t  param 
)

ML-KEM encapsulation.

Produces a ciphertext and a shared secret from a public key using internal randomness.

Parameters
[out]ctCiphertext output buffer.
[in]ct_lenSize of the ciphertext buffer in bytes.
[out]ssShared secret output buffer.
[in]ss_lenSize of the shared secret buffer in bytes.
[in]pkPublic key.
[in]pk_lenSize of the public key in bytes.
[in]paramML-KEM parameter set selector.
Returns
CX_OK on success, error code otherwise.

Definition at line 59 of file cx_mlkem.c.

◆ MLKEM_crypto_kem_keypair()

cx_err_t MLKEM_crypto_kem_keypair ( uint8_t *  pk,
size_t  pk_len,
uint8_t *  sk,
size_t  sk_len,
MLKEM_param_t  param 
)

Generates an ML-KEM key pair.

Uses internal randomness to produce the key pair.

Parameters
[out]pkPublic key output buffer.
[in]pk_lenSize of the public key buffer in bytes.
[out]skSecret key output buffer.
[in]sk_lenSize of the secret key buffer in bytes.
[in]paramML-KEM parameter set selector.
Returns
CX_OK on success, error code otherwise.

Definition at line 32 of file cx_mlkem.c.