Leancrypto 1.6.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
lc_aes_gcm.h File Reference
#include "lc_aead.h"
#include "lc_sym.h"
Include dependency graph for lc_aes_gcm.h:

Go to the source code of this file.

Macros

#define LC_AES_GCM_CTX_ON_STACK(name)
 Allocate stack memory for the AES GCM cryptor context.

Enumerations

enum  lc_aes_gcm_iv_type { lc_aes_gcm_iv_generate_new }

Functions

int lc_aes_gcm_alloc (struct lc_aead_ctx **ctx)
 Allocate AES GCM cryptor context on heap.
int lc_aes_gcm_generate_iv (struct lc_aead_ctx *ctx, const uint8_t *fixed_field, size_t fixed_field_len, uint8_t *iv, size_t ivlen, enum lc_aes_gcm_iv_type type)
 Generate IV, set the IV to the GCM state and return it to the caller.

Macro Definition Documentation

◆ LC_AES_GCM_CTX_ON_STACK

#define LC_AES_GCM_CTX_ON_STACK ( name)
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
LC_ALIGNED_BUFFER(name##_ctx_buf, LC_AES_GCM_CTX_SIZE, \
LC_MEM_COMMON_ALIGNMENT); \
struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
LC_AES_GCM_SET_CTX(name); \
lc_aead_zero(name); \
_Pragma("GCC diagnostic pop")
#define LC_ALIGNED_BUFFER(name, size, alignment)
Allocate aligned stack memory.

Allocate stack memory for the AES GCM cryptor context.

Parameters
[in]nameName of the stack variable

Definition at line 127 of file lc_aes_gcm.h.

Enumeration Type Documentation

◆ lc_aes_gcm_iv_type

Enumerator
lc_aes_gcm_iv_generate_new 

Definition at line 91 of file lc_aes_gcm.h.

Function Documentation

◆ lc_aes_gcm_alloc()

int lc_aes_gcm_alloc ( struct lc_aead_ctx ** ctx)

Allocate AES GCM cryptor context on heap.

Parameters
[out]ctxAllocated AES GCM cryptor context
Returns
0 on success, < 0 on error

◆ lc_aes_gcm_generate_iv()

int lc_aes_gcm_generate_iv ( struct lc_aead_ctx * ctx,
const uint8_t * fixed_field,
size_t fixed_field_len,
uint8_t * iv,
size_t ivlen,
enum lc_aes_gcm_iv_type type )

Generate IV, set the IV to the GCM state and return it to the caller.

The operation copies the fixed_field data into the IV.

Note
If fixed_field and iv are the same pointer, the fixed field data is not copied to the iv buffer.
If this API is used then the lc_aead_setkey should be invoked with NULL as IV.
If this API is to be used, it must be invoked after the API call of lc_aead_setkey.
Parameters
[in]ctxGCM context to set IV with
[in]fixed_fieldFixed field data
[in]fixed_field_lenLength of fixed field
[out]ivbuffer with fixed_field || random number
[in]ivlenof the IV to be generated
[in]typeIV generation type
Returns
0 on succes, < 0 on error