Leancrypto 1.6.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
lc_ascon_keccak.h File Reference
#include "lc_ascon_aead.h"
#include "lc_sha3.h"
Include dependency graph for lc_ascon_keccak.h:

Go to the source code of this file.

Macros

#define LC_AK_CTX_ON_STACK(name, hash)
 Allocate stack memory for the Ascon-Keccak cryptor context using a 128 bit tag.
#define LC_AK_CTX_ON_STACK_TAGLEN(name, hash, tagsize)
 Allocate stack memory for the Ascon-Keccak cryptor context using a configured taglen.

Functions

int lc_ak_alloc (const struct lc_hash *hash, struct lc_aead_ctx **ctx)
 Allocate Ascon Keccak cryptor context on heap.
int lc_ak_alloc_taglen (const struct lc_hash *hash, uint8_t taglen, struct lc_aead_ctx **ctx)
 Allocate Ascon Keccak cryptor context on heap.

Variables

const struct lc_aead * lc_ascon_keccak_aead

Macro Definition Documentation

◆ LC_AK_CTX_ON_STACK

#define LC_AK_CTX_ON_STACK ( name,
hash )
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
LC_ALIGNED_BUFFER(name##_ctx_buf, \
LC_AK_CTX_SIZE(hash), \
LC_ASCON_ALIGNMENT); \
struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
LC_ASCON_SET_CTX(name, hash, lc_ascon_keccak_aead); \
struct lc_ascon_cryptor *__name_ascon_crypto = name->aead_state; \
__name_ascon_crypto->statesize = LC_SHA3_STATE_SIZE; \
__name_ascon_crypto->taglen = 16; \
_Pragma("GCC diagnostic pop")
#define LC_ALIGNED_BUFFER(name, size, alignment)
Allocate aligned stack memory.

Allocate stack memory for the Ascon-Keccak cryptor context using a 128 bit tag.

Note
This is defined for lc_sha3_512 and lc_sha3_256.
Parameters
[in]nameName of the stack variable
[in]hashHash implementation of type struct hash used for the Ascon-Keccak algorithm

Definition at line 82 of file lc_ascon_keccak.h.

◆ LC_AK_CTX_ON_STACK_TAGLEN

#define LC_AK_CTX_ON_STACK_TAGLEN ( name,
hash,
tagsize )
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
LC_ALIGNED_BUFFER(name##_ctx_buf, \
LC_AK_CTX_SIZE(hash), \
LC_ASCON_ALIGNMENT); \
struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
LC_ASCON_SET_CTX(name, hash, lc_ascon_keccak_aead); \
struct lc_ascon_cryptor *__name_ascon_crypto = name->aead_state; \
__name_ascon_crypto->statesize = LC_SHA3_STATE_SIZE; \
__name_ascon_crypto->taglen = tagsize; \
_Pragma("GCC diagnostic pop")

Allocate stack memory for the Ascon-Keccak cryptor context using a configured taglen.

Note
This is defined for lc_sha3_512 and lc_sha3_256.
Parameters
[in]nameName of the stack variable
[in]hashHash implementation of type struct hash used for the Ascon-Keccak algorithm
[in]tagsizeLength of the tag in bytes (between 16 and key size)

Definition at line 107 of file lc_ascon_keccak.h.

Function Documentation

◆ lc_ak_alloc()

int lc_ak_alloc ( const struct lc_hash * hash,
struct lc_aead_ctx ** ctx )

Allocate Ascon Keccak cryptor context on heap.

This allocation ensures the tag length to be 128 bits.

Note
This is defined for lc_sha3_512 and lc_sha3_256.
Parameters
[in]hashHash implementation of type struct hash used for the Ascon-Keccak algorithm
[out]ctxAllocated Ascon-Keccak cryptor context
Returns
0 on success, < 0 on error

◆ lc_ak_alloc_taglen()

int lc_ak_alloc_taglen ( const struct lc_hash * hash,
uint8_t taglen,
struct lc_aead_ctx ** ctx )

Allocate Ascon Keccak cryptor context on heap.

This allocation ensures the tag length requested by the caller.

Note
This is defined for lc_sha3_512 and lc_sha3_256.
Parameters
[in]hashHash implementation of type struct hash used for the Ascon-Keccak algorithm
[in]taglenLength of the tag in bytes (between 16 and key size)
[out]ctxAllocated Ascon-Keccak cryptor context
Returns
0 on success, < 0 on error

Variable Documentation

◆ lc_ascon_keccak_aead

const struct lc_aead* lc_ascon_keccak_aead
extern