block_cipher.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  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. #include "mbedtls/private_access.h"
  13. #include "mbedtls/build_info.h"
  14. #if defined(MBEDTLS_AES_C)
  15. #include "mbedtls/aes.h"
  16. #endif
  17. #if defined(MBEDTLS_ARIA_C)
  18. #include "mbedtls/aria.h"
  19. #endif
  20. #if defined(MBEDTLS_CAMELLIA_C)
  21. #include "mbedtls/camellia.h"
  22. #endif
  23. #if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
  24. #include "psa/crypto_types.h"
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. typedef enum {
  30. MBEDTLS_BLOCK_CIPHER_ID_NONE = 0, /**< Unset. */
  31. MBEDTLS_BLOCK_CIPHER_ID_AES, /**< The AES cipher. */
  32. MBEDTLS_BLOCK_CIPHER_ID_CAMELLIA, /**< The Camellia cipher. */
  33. MBEDTLS_BLOCK_CIPHER_ID_ARIA, /**< The Aria cipher. */
  34. } mbedtls_block_cipher_id_t;
  35. /**
  36. * Used internally to indicate whether a context uses legacy or PSA.
  37. *
  38. * Internal use only.
  39. */
  40. typedef enum {
  41. MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY = 0,
  42. MBEDTLS_BLOCK_CIPHER_ENGINE_PSA,
  43. } mbedtls_block_cipher_engine_t;
  44. typedef struct {
  45. mbedtls_block_cipher_id_t MBEDTLS_PRIVATE(id);
  46. #if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
  47. mbedtls_block_cipher_engine_t MBEDTLS_PRIVATE(engine);
  48. mbedtls_svc_key_id_t MBEDTLS_PRIVATE(psa_key_id);
  49. #endif
  50. union {
  51. unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
  52. #if defined(MBEDTLS_AES_C)
  53. mbedtls_aes_context MBEDTLS_PRIVATE(aes);
  54. #endif
  55. #if defined(MBEDTLS_ARIA_C)
  56. mbedtls_aria_context MBEDTLS_PRIVATE(aria);
  57. #endif
  58. #if defined(MBEDTLS_CAMELLIA_C)
  59. mbedtls_camellia_context MBEDTLS_PRIVATE(camellia);
  60. #endif
  61. } MBEDTLS_PRIVATE(ctx);
  62. } mbedtls_block_cipher_context_t;
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* MBEDTLS_BLOCK_CIPHER_H */