aes_alt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * \file aes_alt.h
  3. *
  4. * \brief This file contains alternate AES definitions and functions.
  5. *
  6. * The Advanced Encryption Standard (AES) specifies a FIPS-approved
  7. * cryptographic algorithm that can be used to protect electronic
  8. * data.
  9. *
  10. * The AES algorithm is a symmetric block cipher that can
  11. * encrypt and decrypt information. For more information, see
  12. * <em>FIPS Publication 197: Advanced Encryption Standard</em> and
  13. * <em>ISO/IEC 18033-2:2006: Information technology -- Security
  14. * techniques -- Encryption algorithms -- Part 2: Asymmetric
  15. * ciphers</em>.
  16. *
  17. * The AES-XTS block mode is standardized by NIST SP 800-38E
  18. * <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf>
  19. * and described in detail by IEEE P1619
  20. * <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>.
  21. */
  22. /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
  23. * SPDX-License-Identifier: Apache-2.0
  24. * Copyright 2018 NXP. Not a Contribution
  25. *
  26. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  27. * not use this file except in compliance with the License.
  28. * You may obtain a copy of the License at
  29. *
  30. * http://www.apache.org/licenses/LICENSE-2.0
  31. *
  32. * Unless required by applicable law or agreed to in writing, software
  33. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  34. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  35. * See the License for the specific language governing permissions and
  36. * limitations under the License.
  37. *
  38. * This file is part of Mbed TLS (https://tls.mbed.org)
  39. */
  40. /*
  41. * Fow HW integration change
  42. * Copyright (c) 2023 HPMicro
  43. *
  44. * SPDX-License-Identifier: BSD-3-Clause
  45. *
  46. */
  47. #ifndef AES_ALT_H
  48. #define AES_ALT_H
  49. #if !defined(MBEDTLS_CONFIG_FILE)
  50. #include "mbedtls/config.h"
  51. #else
  52. #include MBEDTLS_CONFIG_FILE
  53. #endif
  54. #include "hpm_common.h"
  55. #include "hpm_romapi.h"
  56. #include "hpm_sdp_drv.h"
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. #if defined(MBEDTLS_AES_ALT)
  61. /**
  62. * \brief The AES context-type definition.
  63. */
  64. typedef struct mbedtls_aes_context {
  65. int nr; /*!< The number of rounds. */
  66. uint32_t *rk; /*!< AES round keys. */
  67. uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
  68. hold 32 extra Bytes, which can be used for
  69. one of the following purposes:
  70. <ul><li>Alignment if VIA padlock is
  71. used.</li>
  72. <li>Simplifying key expansion in the 256-bit
  73. case by generating an extra round key.
  74. </li></ul> */
  75. } mbedtls_aes_context;
  76. #endif /* defined(MBEDTLS_AES_ALT) */
  77. #if defined(MBEDTLS_CIPHER_MODE_XTS)
  78. /**
  79. * \brief The AES XTS context-type definition.
  80. */
  81. typedef struct mbedtls_aes_xts_context {
  82. mbedtls_aes_context crypt; /*!< The AES context to use for AES block
  83. encryption or decryption. */
  84. mbedtls_aes_context tweak; /*!< The AES context used for tweak
  85. computation. */
  86. } mbedtls_aes_xts_context;
  87. #endif /* MBEDTLS_CIPHER_MODE_XTS */
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif /* AES_ALT_H */