Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 09:37:29

0001 /**
0002  * \file block_cipher.h
0003  *
0004  * \brief Internal abstraction layer.
0005  */
0006 /*
0007  *  Copyright The Mbed TLS Contributors
0008  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
0009  */
0010 #ifndef MBEDTLS_BLOCK_CIPHER_H
0011 #define MBEDTLS_BLOCK_CIPHER_H
0012 
0013 #include "mbedtls/private_access.h"
0014 
0015 #include "mbedtls/build_info.h"
0016 
0017 #if defined(MBEDTLS_AES_C)
0018 #include "mbedtls/aes.h"
0019 #endif
0020 #if defined(MBEDTLS_ARIA_C)
0021 #include "mbedtls/aria.h"
0022 #endif
0023 #if defined(MBEDTLS_CAMELLIA_C)
0024 #include "mbedtls/camellia.h"
0025 #endif
0026 
0027 #if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
0028 #include "psa/crypto_types.h"
0029 #endif
0030 
0031 #ifdef __cplusplus
0032 extern "C" {
0033 #endif
0034 
0035 typedef enum {
0036     MBEDTLS_BLOCK_CIPHER_ID_NONE = 0,  /**< Unset. */
0037     MBEDTLS_BLOCK_CIPHER_ID_AES,       /**< The AES cipher. */
0038     MBEDTLS_BLOCK_CIPHER_ID_CAMELLIA,  /**< The Camellia cipher. */
0039     MBEDTLS_BLOCK_CIPHER_ID_ARIA,      /**< The Aria cipher. */
0040 } mbedtls_block_cipher_id_t;
0041 
0042 /**
0043  * Used internally to indicate whether a context uses legacy or PSA.
0044  *
0045  * Internal use only.
0046  */
0047 typedef enum {
0048     MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY = 0,
0049     MBEDTLS_BLOCK_CIPHER_ENGINE_PSA,
0050 } mbedtls_block_cipher_engine_t;
0051 
0052 typedef struct {
0053     mbedtls_block_cipher_id_t MBEDTLS_PRIVATE(id);
0054 #if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
0055     mbedtls_block_cipher_engine_t MBEDTLS_PRIVATE(engine);
0056     mbedtls_svc_key_id_t MBEDTLS_PRIVATE(psa_key_id);
0057 #endif
0058     union {
0059         unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
0060 #if defined(MBEDTLS_AES_C)
0061         mbedtls_aes_context MBEDTLS_PRIVATE(aes);
0062 #endif
0063 #if defined(MBEDTLS_ARIA_C)
0064         mbedtls_aria_context MBEDTLS_PRIVATE(aria);
0065 #endif
0066 #if defined(MBEDTLS_CAMELLIA_C)
0067         mbedtls_camellia_context MBEDTLS_PRIVATE(camellia);
0068 #endif
0069     } MBEDTLS_PRIVATE(ctx);
0070 } mbedtls_block_cipher_context_t;
0071 
0072 #ifdef __cplusplus
0073 }
0074 #endif
0075 
0076 #endif /* MBEDTLS_BLOCK_CIPHER_H */