blob: 154ae26e2d1ee1877073887c71ebf42030b3a943 [file] [log] [blame]
Manuel Pégourié-Gonnard21718762023-11-10 11:21:17 +01001/**
2 * \file block_cipher.h
3 *
4 * \brief Internal abstraction layer.
5 */
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 */
10#ifndef MBEDTLS_BLOCK_CIPHER_H
11#define MBEDTLS_BLOCK_CIPHER_H
12
13#include "mbedtls/private_access.h"
14
15#include "mbedtls/build_info.h"
16
17#if defined(MBEDTLS_AES_C)
18#include "mbedtls/aes.h"
19#endif
20#if defined(MBEDTLS_ARIA_C)
21#include "mbedtls/aria.h"
22#endif
23#if defined(MBEDTLS_CAMELLIA_C)
24#include "mbedtls/camellia.h"
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31typedef enum {
32 MBEDTLS_BLOCK_CIPHER_ID_NONE = 0, /**< Unset. */
33 MBEDTLS_BLOCK_CIPHER_ID_AES, /**< The AES cipher. */
34 MBEDTLS_BLOCK_CIPHER_ID_CAMELLIA, /**< The Camellia cipher. */
35 MBEDTLS_BLOCK_CIPHER_ID_ARIA, /**< The Aria cipher. */
36} mbedtls_block_cipher_id_t;
37
38typedef struct {
39 mbedtls_block_cipher_id_t MBEDTLS_PRIVATE(id);
40 union {
41 unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
42#if defined(MBEDTLS_AES_C)
43 mbedtls_aes_context MBEDTLS_PRIVATE(aes);
44#endif
45#if defined(MBEDTLS_ARIA_C)
46 mbedtls_aria_context MBEDTLS_PRIVATE(aria);
47#endif
48#if defined(MBEDTLS_CAMELLIA_C)
49 mbedtls_camellia_context MBEDTLS_PRIVATE(camellia);
50#endif
51 } MBEDTLS_PRIVATE(ctx);
52} mbedtls_block_cipher_context_t;
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif /* MBEDTLS_BLOCK_CIPHER_H */