Leancrypto 1.6.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
lc_ascon_lightweight.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 - 2025, Stephan Mueller <smueller@chronox.de>
3 *
4 * License: see LICENSE file in root directory
5 *
6 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
7 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
9 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
10 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
12 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
13 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
16 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 */
19
20#ifndef LC_ASCON_LIGHTWEIGHT_H
21#define LC_ASCON_LIGHTWEIGHT_H
22
23#include "lc_ascon_aead.h"
24#include "lc_ascon_hash.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31#define LC_AL_STATE_SIZE (LC_ASCON_HASH_STATE_SIZE + LC_ASCON_ALIGNMENT)
32#define LC_AL_CTX_SIZE \
33 (sizeof(struct lc_aead) + sizeof(struct lc_ascon_cryptor) + \
34 LC_AL_STATE_SIZE)
36
37/* Ascon-based AEAD-algorithm */
38extern const struct lc_aead *lc_ascon_aead;
39
47int lc_al_alloc(struct lc_aead_ctx **ctx);
48
54#define LC_AL_CTX_ON_STACK(name) \
55 _Pragma("GCC diagnostic push") \
56 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
57 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
58 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_AL_CTX_SIZE, \
59 LC_ASCON_ALIGNMENT); \
60 struct lc_aead_ctx *name = (struct lc_aead_ctx *)name##_ctx_buf; \
61 LC_ASCON_SET_CTX(name, lc_ascon_128a, lc_ascon_aead); \
62 struct lc_ascon_cryptor *__name_ascon_crypto = name->aead_state; \
63 __name_ascon_crypto->statesize = LC_ASCON_HASH_STATE_SIZE; \
64 __name_ascon_crypto->taglen = 16; \
65 _Pragma("GCC diagnostic pop")
66/* invocation of lc_ak_zero_free(name); not needed */
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* LC_ASCON_LIGHTWEIGHT_H */
int lc_al_alloc(struct lc_aead_ctx **ctx)
Allocate Ascon Lightweight cryptor context on heap.
const struct lc_aead * lc_ascon_aead