Leancrypto 0.12.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
ML-KEM / CRYSTALS-Kyber used in Integrated Encryption Schema

Functions

static int lc_kyber_ies_enc (const struct lc_kyber_pk *pk, struct lc_kyber_ct *ct, const uint8_t *plaintext, uint8_t *ciphertext, size_t datalen, const uint8_t *aad, size_t aadlen, uint8_t *tag, size_t taglen, struct lc_aead_ctx *aead)
 KyberIES encryption oneshot.
 
static int lc_kyber_ies_enc_init (struct lc_aead_ctx *aead, const struct lc_kyber_pk *pk, struct lc_kyber_ct *ct, const uint8_t *aad, size_t aadlen)
 KyberIES encryption stream operation initialization.
 
static int lc_kyber_ies_enc_update (struct lc_aead_ctx *aead, const uint8_t *plaintext, uint8_t *ciphertext, size_t datalen)
 KyberIES encryption stream operation add more data.
 
static int lc_kyber_ies_enc_final (struct lc_aead_ctx *aead, uint8_t *tag, size_t taglen)
 KyberIES encryption stream operation finalization / integrity test.
 
static int lc_kyber_ies_dec (const struct lc_kyber_sk *sk, const struct lc_kyber_ct *ct, const uint8_t *ciphertext, uint8_t *plaintext, size_t datalen, const uint8_t *aad, size_t aadlen, const uint8_t *tag, size_t taglen, struct lc_aead_ctx *aead)
 KyberIES decryption oneshot.
 
static int lc_kyber_ies_dec_init (struct lc_aead_ctx *aead, const struct lc_kyber_sk *sk, const struct lc_kyber_ct *ct, const uint8_t *aad, size_t aadlen)
 KyberIES decryption stream operation initialization.
 
static int lc_kyber_ies_dec_update (struct lc_aead_ctx *aead, const uint8_t *ciphertext, uint8_t *plaintext, size_t datalen)
 KyberIES decryption stream operation add more data.
 
static int lc_kyber_ies_dec_final (struct lc_aead_ctx *aead, const uint8_t *tag, size_t taglen)
 KyberIES decryption stream operation finalization / integrity test.
 

Detailed Description

Kyber Integrated Encryption Schema

This mechanism uses Kyber to encrypt arbitrary data. See KyberIES for the associated documentation.

Function Documentation

◆ lc_kyber_ies_dec()

static int lc_kyber_ies_dec ( const struct lc_kyber_sk * sk,
const struct lc_kyber_ct * ct,
const uint8_t * ciphertext,
uint8_t * plaintext,
size_t datalen,
const uint8_t * aad,
size_t aadlen,
const uint8_t * tag,
size_t taglen,
struct lc_aead_ctx * aead )
inlinestatic

KyberIES decryption oneshot.

The implementation supports an in-place data decryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]skKyber secret key of data owner
[in]ctKyber ciphertext received from the encryption operation
[in]ciphertextCiphertext data to be encrypted
[out]plaintextBuffer of equal size as ciphertext that will be filled with the decryption result
[in]datalenLength of the ciphertext buffer
[in]aadAdditional authenticate data to be processed - this is data which is not encrypted, but considered as part of the authentication.
[in]aadlenLength of the AAD buffer
[in]tagBuffer with the authentication tag
[in]taglenLength of the tag buffer
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
Returns
0 on success, < 0 on error (-EBADMSG on integrity error)

Definition at line 1812 of file lc_kyber.h.

◆ lc_kyber_ies_dec_final()

static int lc_kyber_ies_dec_final ( struct lc_aead_ctx * aead,
const uint8_t * tag,
size_t taglen )
inlinestatic

KyberIES decryption stream operation finalization / integrity test.

The implementation supports an in-place data decryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[in]tagBuffer with the authentication tag
[in]taglenLength of the tag buffer
Returns
0 on success, < 0 on error (-EBADMSG on integrity error)

Definition at line 1959 of file lc_kyber.h.

◆ lc_kyber_ies_dec_init()

static int lc_kyber_ies_dec_init ( struct lc_aead_ctx * aead,
const struct lc_kyber_sk * sk,
const struct lc_kyber_ct * ct,
const uint8_t * aad,
size_t aadlen )
inlinestatic

KyberIES decryption stream operation initialization.

The implementation supports an in-place data decryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

The aead context is initialized such that it can be used with lc_kyber_ies_dec_[update|final].

Parameters
[out]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[in]skKyber secret key of data owner
[in]ctKyber ciphertext received from the encryption operation
[in]aadAdditional authenticate data to be processed - this is data which is not encrypted, but considered as part of the authentication.
[in]aadlenLength of the AAD buffer
Returns
0 on success, < 0 on error

Definition at line 1876 of file lc_kyber.h.

◆ lc_kyber_ies_dec_update()

static int lc_kyber_ies_dec_update ( struct lc_aead_ctx * aead,
const uint8_t * ciphertext,
uint8_t * plaintext,
size_t datalen )
inlinestatic

KyberIES decryption stream operation add more data.

The implementation supports an in-place data decryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[in]ciphertextCiphertext data to be encrypted
[out]plaintextBuffer of equal size as ciphertext that will be filled with the decryption result
[in]datalenLength of the ciphertext buffer
Returns
0 on success, < 0 on error

Definition at line 1933 of file lc_kyber.h.

◆ lc_kyber_ies_enc()

static int lc_kyber_ies_enc ( const struct lc_kyber_pk * pk,
struct lc_kyber_ct * ct,
const uint8_t * plaintext,
uint8_t * ciphertext,
size_t datalen,
const uint8_t * aad,
size_t aadlen,
uint8_t * tag,
size_t taglen,
struct lc_aead_ctx * aead )
inlinestatic

KyberIES encryption oneshot.

The implementation supports an in-place data encryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]pkKyber public key of data owner
[out]ctKyber ciphertext to be sent to the decryption operation
[in]plaintextPlaintext data to be encrypted
[out]ciphertextBuffer of equal size as plaintext that will be filled with the encryption result
[in]datalenLength of the plaintext buffer
[in]aadAdditional authenticate data to be processed - this is data which is not encrypted, but considered as part of the authentication.
[in]aadlenLength of the AAD buffer
[out]tagBuffer that will be filled with the authentication tag
[in]taglenLength of the tag buffer
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
Returns
0 on success, < 0 on error

Definition at line 1623 of file lc_kyber.h.

◆ lc_kyber_ies_enc_final()

static int lc_kyber_ies_enc_final ( struct lc_aead_ctx * aead,
uint8_t * tag,
size_t taglen )
inlinestatic

KyberIES encryption stream operation finalization / integrity test.

The implementation supports an in-place data encryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[out]tagBuffer that will be filled with the authentication tag
[in]taglenLength of the tag buffer
Returns
0 on success, < 0 on error

Definition at line 1777 of file lc_kyber.h.

◆ lc_kyber_ies_enc_init()

static int lc_kyber_ies_enc_init ( struct lc_aead_ctx * aead,
const struct lc_kyber_pk * pk,
struct lc_kyber_ct * ct,
const uint8_t * aad,
size_t aadlen )
inlinestatic

KyberIES encryption stream operation initialization.

The implementation supports an in-place data encryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

The aead context is initialized such that it can be used with lc_kyber_ies_enc_[update|final].

Parameters
[out]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[in]pkKyber public key of data owner
[out]ctKyber ciphertext to be sent to the decryption operation
[in]aadAdditional authenticate data to be processed - this is data which is not encrypted, but considered as part of the authentication.
[in]aadlenLength of the AAD buffer
Returns
0 on success, < 0 on error

Definition at line 1691 of file lc_kyber.h.

◆ lc_kyber_ies_enc_update()

static int lc_kyber_ies_enc_update ( struct lc_aead_ctx * aead,
const uint8_t * plaintext,
uint8_t * ciphertext,
size_t datalen )
inlinestatic

KyberIES encryption stream operation add more data.

The implementation supports an in-place data encryption where the plaintext and ciphertext buffer pointers refer to the same memory location.

The function entirely operates on stack memory.

Parameters
[in]aeadAllocated AEAD algorithm - the caller only needs to provide an allocated but otherwise unused instance of an AEAD algorithm. This allows the caller to define the AEAD algorithm type. The caller must zeroize and release the context after completion.
[in]plaintextPlaintext data to be encrypted
[out]ciphertextBuffer of equal size as plaintext that will be filled with the encryption result
[in]datalenLength of the plaintext buffer
Returns
0 on success, < 0 on error

Definition at line 1751 of file lc_kyber.h.